diff --git a/src/api/apps.ts b/src/api/apps.ts index 1269819..0c89d85 100644 --- a/src/api/apps.ts +++ b/src/api/apps.ts @@ -55,8 +55,15 @@ export function copyApp(data: any) { } // 导入应用 -export function importApp(file: File) { - return axios.post(`${urlPrefix}/apps/import`, { file }); +export function importApp(params: { file: File, projectId: string }) { + const formData = new FormData(); + formData.append('file', params.file); + + return axios.post(`${urlPrefix}/apps/import/${params.projectId}`, formData, { + headers: { + 'Content-Type': 'multipart/form-data' + } + }); } // 导出应用 diff --git a/src/pages/ideContainer/sideBar.tsx b/src/pages/ideContainer/sideBar.tsx index 74fee80..1cd9da9 100644 --- a/src/pages/ideContainer/sideBar.tsx +++ b/src/pages/ideContainer/sideBar.tsx @@ -1017,7 +1017,10 @@ const SideBar: React.FC = ({ try { setImporting(true); - const res: any = await importApp(importFile); + const res: any = await importApp({ + file: importFile, + projectId: info.id + }); if (res.code === 200) { Message.success('应用导入成功');