This commit is contained in:
2026-05-06 10:28:16 +08:00
parent 06b3e54a39
commit 20451904bd
5 changed files with 111 additions and 24 deletions
+22 -1
View File
@@ -918,6 +918,20 @@ const MoldInsightView = {
const uploadFile = async () => {
if (!state.selectedFile) return;
if (!appState.token) {
state.error = '请先登录后再上传文件';
addNotification('请先登录', 'warning');
router.push('/login');
return;
}
if (appState.token === 'demo') {
state.error = '演示模式不支持文件上传,请使用完整账户登录';
addNotification('演示模式不支持上传', 'warning');
return;
}
state.uploading = true;
state.error = "";
state.progress = 0;
@@ -929,9 +943,16 @@ const MoldInsightView = {
try {
const res = await fetch("/api/upload", {
method: "POST",
headers: appState.token ? { 'Authorization': `Bearer ${appState.token}` } : {},
headers: { 'Authorization': `Bearer ${appState.token}` },
body: formData
});
if (res.status === 401) {
clearAuth();
state.error = '登录已过期,请重新登录';
addNotification('登录已过期,请重新登录', 'warning');
router.push('/login');
return;
}
if (!res.ok) throw new Error(`上传失败: ${res.status}`);
const data = await res.json();
state.currentTask = { task_id: data.task_id, status: "processing", filename: data.file_info?.filename };