api.ts 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. //所有的接口请求
  2. import axios from 'axios';
  3. const isProd =
  4. import.meta.env.BASE_URL.indexOf('https://assets.le5lecdn.com') === 0;
  5. export const cdn = isProd ? 'https://assets.le5lecdn.com' : '';
  6. export const upCdn = isProd ? 'https://drive.le5lecdn.com' : '';
  7. export const imageDrive = 'https://drive.le5lecdn.com';
  8. //https://v.le5le.com/file/2023/0828/1/1/thumb.07c0a78f.png
  9. export async function delImage(image: string) {
  10. if (image.startsWith('/file') || image.startsWith('/api')) {
  11. await axios.delete(`${image}`);
  12. } else if (image.startsWith(upCdn) || image.startsWith(imageDrive)) {
  13. await axios.delete('/api/file' + image.replace(upCdn || imageDrive, ''));
  14. } else {
  15. await axios.delete(`${image}`);
  16. }
  17. return true;
  18. }
  19. export async function getFolders(query: any) {
  20. const folder: any = await axios.post('/api/data/folders/get', {
  21. query,
  22. });
  23. if (folder.error) {
  24. return;
  25. } else {
  26. return folder;
  27. }
  28. }
  29. export async function updateFolders(data: any) {
  30. const folder: any = await axios.post('/api/data/folders/update', data);
  31. if (folder.error) {
  32. return;
  33. } else {
  34. return folder;
  35. }
  36. }
  37. export async function addCollection(collection: string, data: any) {
  38. return await axios.post(`/api/data/${collection}/add`, data);
  39. }
  40. export async function updateCollection(collection: string, data: any) {
  41. return await axios.post(`/api/data/${collection}/update`, data);
  42. }
  43. export async function getCollectionList(
  44. collection: string,
  45. data: any,
  46. config: any
  47. ) {
  48. return await axios.post(`/api/data/${collection}/list`, data, config);
  49. }
  50. export async function getLe5leV(id: string, projection?: any, historyId?: string) {
  51. return await axios.post('/api/data/v/get', {
  52. id,
  53. projection,
  54. historyId
  55. });
  56. }
  57. export async function getComponents(id: string) {
  58. return await axios.post(`/api/data/v.component/get`, {
  59. id,
  60. });
  61. }
  62. export async function getComponentsList(data: any, config: any) {
  63. return await axios.post('/api/data/v.component/list', data, config);
  64. }
  65. export async function getLe5le3d(id: string, projection?: any) {
  66. return await axios.post(`/api/data/3d/get`, {
  67. id,
  68. projection,
  69. });
  70. }
  71. export async function getProjectsList(data: any, config: any) {
  72. return await axios.post('/api/data/v/list', data, config);
  73. }
  74. export async function getLe5le2d(id: string, projection?: any) {
  75. return await axios.post('/api/data/2d/get', {
  76. id,
  77. projection,
  78. });
  79. }