api.ts 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. 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(upCdn) || image.startsWith(imageDrive)) {
  11. await axios.delete('/file' + image.replace(upCdn || imageDrive, ''));
  12. } else {
  13. await axios.delete(`${image}`);
  14. }
  15. return true;
  16. }
  17. export async function getFolders(query: any) {
  18. const folder: any = await axios.post('/api/data/folders/get', {
  19. query,
  20. });
  21. if (folder.error) {
  22. return;
  23. } else {
  24. return folder;
  25. }
  26. }
  27. export async function updateFolders(data: any) {
  28. const folder: any = await axios.post('/api/data/folders/update', data);
  29. if (folder.error) {
  30. return;
  31. } else {
  32. return folder;
  33. }
  34. }
  35. export async function addCollection(collection: string, data: any) {
  36. return await axios.post(`/api/data/${collection}/add`, data);
  37. }
  38. export async function updateCollection(collection: string, data: any) {
  39. return await axios.post(`/api/data/${collection}/update`, data);
  40. }
  41. export async function getCollectionList(
  42. collection: string,
  43. data: any,
  44. config: any
  45. ) {
  46. return await axios.post(`/api/data/${collection}/list`, data, config);
  47. }
  48. export async function getLe5leV(id: string) {
  49. return await axios.post('/api/data/le5leV/get', {
  50. id,
  51. });
  52. }
  53. export async function getComponents(id: string) {
  54. return await axios.post(`/api/data/le5leV-components/get`, {
  55. id,
  56. });
  57. }
  58. export async function getComponentsList(data: any, config: any) {
  59. return await axios.post('/api/data/le5leV-components/list', data, config);
  60. }
  61. export async function getLe5le3d(id: string) {
  62. return await axios.post(`/api/data/le5le3d/get`, {
  63. id,
  64. });
  65. }
  66. export async function getProjectsList(data: any, config: any) {
  67. return await axios.post('/api/data/le5leV/list', data, config);
  68. }