This commit is contained in:
2026-06-18 16:45:47 +08:00
parent f9b3a51391
commit cffebebf19
3 changed files with 14 additions and 8 deletions
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -28,7 +28,7 @@
} }
})(); })();
</script> </script>
<script type="module" crossorigin src="/assets/index-CXwDXEM6.js"></script> <script type="module" crossorigin src="/assets/index-CeOAp-xS.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-D7ShJUt4.css"> <link rel="stylesheet" crossorigin href="/assets/index-D7ShJUt4.css">
</head> </head>
<body> <body>
+12 -6
View File
@@ -139,13 +139,16 @@ export async function uploadPdf(file: File, configKey: string): Promise<{ url: s
formData.append('file', file); formData.append('file', file);
formData.append('config_key', configKey); formData.append('config_key', configKey);
const token = localStorage.getItem('auth_token'); const token = localStorage.getItem('auth_token');
const baseUrl = (import.meta as any).env?.VITE_API_URL || 'http://localhost:8000/api'; const baseUrl = import.meta.env.VITE_API_BASE || 'http://localhost:8000';
const res = await fetch(`${baseUrl}/admin/upload-pdf`, { const res = await fetch(`${baseUrl}/api/admin/upload-pdf`, {
method: 'POST', method: 'POST',
headers: token ? { 'Authorization': `Bearer ${token}` } : {}, headers: token ? { 'Authorization': `Bearer ${token}` } : {},
body: formData, body: formData,
}); });
if (!res.ok) throw new Error('上传失败'); if (!res.ok) {
const text = await res.text();
throw new Error(text || '上传失败');
}
return res.json(); return res.json();
} }
@@ -153,13 +156,16 @@ export async function uploadLogo(file: File): Promise<{ url: string }> {
const formData = new FormData(); const formData = new FormData();
formData.append('file', file); formData.append('file', file);
const token = localStorage.getItem('auth_token'); const token = localStorage.getItem('auth_token');
const baseUrl = (import.meta as any).env?.VITE_API_URL || 'http://localhost:8000/api'; const baseUrl = import.meta.env.VITE_API_BASE || 'http://localhost:8000';
const res = await fetch(`${baseUrl}/admin/upload-logo`, { const res = await fetch(`${baseUrl}/api/admin/upload-logo`, {
method: 'POST', method: 'POST',
headers: token ? { 'Authorization': `Bearer ${token}` } : {}, headers: token ? { 'Authorization': `Bearer ${token}` } : {},
body: formData, body: formData,
}); });
if (!res.ok) throw new Error('上传失败'); if (!res.ok) {
const text = await res.text();
throw new Error(text || '上传失败');
}
return res.json(); return res.json();
} }