1
This commit is contained in:
@@ -139,13 +139,16 @@ export async function uploadPdf(file: File, configKey: string): Promise<{ url: s
|
||||
formData.append('file', file);
|
||||
formData.append('config_key', configKey);
|
||||
const token = localStorage.getItem('auth_token');
|
||||
const baseUrl = (import.meta as any).env?.VITE_API_URL || 'http://localhost:8000/api';
|
||||
const res = await fetch(`${baseUrl}/admin/upload-pdf`, {
|
||||
const baseUrl = import.meta.env.VITE_API_BASE || 'http://localhost:8000';
|
||||
const res = await fetch(`${baseUrl}/api/admin/upload-pdf`, {
|
||||
method: 'POST',
|
||||
headers: token ? { 'Authorization': `Bearer ${token}` } : {},
|
||||
body: formData,
|
||||
});
|
||||
if (!res.ok) throw new Error('上传失败');
|
||||
if (!res.ok) {
|
||||
const text = await res.text();
|
||||
throw new Error(text || '上传失败');
|
||||
}
|
||||
return res.json();
|
||||
}
|
||||
|
||||
@@ -153,13 +156,16 @@ export async function uploadLogo(file: File): Promise<{ url: string }> {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
const token = localStorage.getItem('auth_token');
|
||||
const baseUrl = (import.meta as any).env?.VITE_API_URL || 'http://localhost:8000/api';
|
||||
const res = await fetch(`${baseUrl}/admin/upload-logo`, {
|
||||
const baseUrl = import.meta.env.VITE_API_BASE || 'http://localhost:8000';
|
||||
const res = await fetch(`${baseUrl}/api/admin/upload-logo`, {
|
||||
method: 'POST',
|
||||
headers: token ? { 'Authorization': `Bearer ${token}` } : {},
|
||||
body: formData,
|
||||
});
|
||||
if (!res.ok) throw new Error('上传失败');
|
||||
if (!res.ok) {
|
||||
const text = await res.text();
|
||||
throw new Error(text || '上传失败');
|
||||
}
|
||||
return res.json();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user