api.ts 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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('/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) {
  51. return await axios.post('/api/data/v/get', {
  52. id,
  53. projection,
  54. });
  55. }
  56. export async function getComponents(id: string) {
  57. return await axios.post(`/api/data/v.component/get`, {
  58. id,
  59. });
  60. }
  61. export async function getComponentsList(data: any, config: any) {
  62. return await axios.post('/api/data/v.component/list', data, config);
  63. }
  64. export async function getLe5le3d(id: string, projection?: any) {
  65. return await axios.post(`/api/data/3d/get`, {
  66. id,
  67. projection,
  68. });
  69. }
  70. export async function getProjectsList(data: any, config: any) {
  71. return await axios.post('/api/data/v/list', data, config);
  72. }
  73. export async function getLe5le2d(id: string, projection?: any) {
  74. return await axios.post('/api/data/2d/get', {
  75. id,
  76. projection,
  77. });
  78. }