From 53910e5f20e4ad6719fc57ade336f5421569d302 Mon Sep 17 00:00:00 2001 From: Audit Bot Date: Mon, 29 Jun 2026 10:48:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=89=8D=E7=AB=AF=E4=BA=A4=E4=BA=92?= =?UTF-8?q?=E5=85=A8=E9=9D=A2=E5=AE=A1=E8=AE=A1=20=E2=80=94=20=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0422=E4=BF=AE=E5=A4=8D=20+=20=E8=BF=9B=E5=BA=A6?= =?UTF-8?q?=E5=8F=8D=E9=A6=88=20+=20=E9=98=B2=E9=87=8D=E5=A4=8D=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🔴 P0 Bug: - AssetLibrary: handleUpload 补充 project_id,调用 getOrCreateDefaultProject() 解决 422 🟡 P0 交互: - AssetLibrary: 上传时显示 Spin + 禁用 Dragger + 文案提示「正在上传」 - client.ts: 新增 413/415/503 状态码专属提示 🔵 全面交互排查: - GeneratePage: 生成中禁用步骤导航按钮防误操作 - Billing: 自动续费 Switch 添加 loading 状态防连点 - TemplateLibrary: 收藏按钮 mutation 进行中 disabled 防重复 - TitleLibrary: 空状态增加「新建标题」和「批量导入」引导按钮 --- apps/web/src/api/client.ts | 13 ++++++++-- apps/web/src/pages/assets/AssetLibrary.tsx | 26 ++++++++++++++----- apps/web/src/pages/generate/GeneratePage.tsx | 4 +-- apps/web/src/pages/subscription/Billing.tsx | 5 ++++ .../src/pages/templates/TemplateLibrary.tsx | 1 + apps/web/src/pages/titles/TitleLibrary.tsx | 16 +++++++++++- 6 files changed, 54 insertions(+), 11 deletions(-) diff --git a/apps/web/src/api/client.ts b/apps/web/src/api/client.ts index 042e54a64..a6de7f408 100644 --- a/apps/web/src/api/client.ts +++ b/apps/web/src/api/client.ts @@ -54,11 +54,20 @@ apiClient.interceptors.response.use( handled = true; } else { const status = error.response?.status; - if (status && status >= 500) { + if (status === 413) { + message.error('文件过大,请缩小后重试'); + handled = true; + } else if (status === 415) { + message.error('不支持的文件格式'); + handled = true; + } else if (status === 503) { + message.error('服务暂不可用,请稍后再试'); + handled = true; + } else if (status && status >= 500) { message.error('服务器繁忙,请稍后再试'); handled = true; } - // 4xx 且无具体信息时不弹通用提示,由各组件自行处理 + // 其他 4xx 且无具体信息时不弹通用提示,由各组件自行处理 } // 标记已展示过提示,组件 onError 可据此跳过重复 toast diff --git a/apps/web/src/pages/assets/AssetLibrary.tsx b/apps/web/src/pages/assets/AssetLibrary.tsx index e3506f61a..173f620b4 100644 --- a/apps/web/src/pages/assets/AssetLibrary.tsx +++ b/apps/web/src/pages/assets/AssetLibrary.tsx @@ -38,6 +38,7 @@ import { deleteAsset, uploadAsset, } from '@/api/assets'; +import { getOrCreateDefaultProject } from '@/api/projects'; const { Title, Text } = Typography; const { Dragger } = Upload; @@ -71,6 +72,7 @@ const AssetLibrary: React.FC = () => { const [newLibKind, setNewLibKind] = useState<'video' | 'voice' | 'image'>( 'video' ); + const [uploading, setUploading] = useState(false); // 获取素材库列表 const { data: libraries = [], isLoading: libsLoading } = useQuery({ @@ -125,10 +127,19 @@ const AssetLibrary: React.FC = () => { message.warning('请先选择素材库'); return false; } - const formData = new FormData(); - formData.append('file', file); - formData.append('library_id', activeLibrary); - await uploadMutation.mutateAsync(formData); + setUploading(true); + try { + const project = await getOrCreateDefaultProject(); + const formData = new FormData(); + formData.append('file', file); + formData.append('library_id', activeLibrary); + formData.append('project_id', project.id); + await uploadMutation.mutateAsync(formData); + } catch { + // uploadMutation.onError 已处理错误提示 + } finally { + setUploading(false); + } return false; }; @@ -205,12 +216,15 @@ const AssetLibrary: React.FC = () => { beforeUpload={handleUpload} showUploadList={false} multiple + disabled={uploading || uploadMutation.isPending} style={{ marginBottom: 24 }} >

- + {uploading ? : } +

+

+ {uploading ? '正在上传,请稍候...' : '点击或拖拽文件到此区域上传'}

-

点击或拖拽文件到此区域上传

支持 {kindLabel[currentLib?.kind || 'video']} 格式文件

diff --git a/apps/web/src/pages/generate/GeneratePage.tsx b/apps/web/src/pages/generate/GeneratePage.tsx index 2002645ae..8f5fc8279 100644 --- a/apps/web/src/pages/generate/GeneratePage.tsx +++ b/apps/web/src/pages/generate/GeneratePage.tsx @@ -326,14 +326,14 @@ const GeneratePage: React.FC = () => { }} > + + + )} + ) : (