api.ts 1.6 KB

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