From 49c8440fe1b10cfec81e8e5a1f6cb7eeadbbaf8b Mon Sep 17 00:00:00 2001 From: Audit Bot Date: Sun, 28 Jun 2026 15:41:10 +0800 Subject: [PATCH] =?UTF-8?q?fix(phase2):=20=E4=BF=AE=E5=A4=8D=20PR#75=20?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=AE=A1=E8=AE=A1=20P1=20=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit P1-1: DuplicationUpload 使用 navigate 替代 window.location.href,避免整页刷新 P1-2: DuplicationResults 批量删除使用 Promise.allSettled,部分失败时正确反馈结果 Co-Authored-By: Claude Fable 5 --- .../pages/duplication/DuplicationResults.tsx | 20 ++++++++++--------- .../pages/duplication/DuplicationUpload.tsx | 6 +++--- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/apps/web/src/pages/duplication/DuplicationResults.tsx b/apps/web/src/pages/duplication/DuplicationResults.tsx index 59b91edb7..d0aac3af0 100644 --- a/apps/web/src/pages/duplication/DuplicationResults.tsx +++ b/apps/web/src/pages/duplication/DuplicationResults.tsx @@ -118,16 +118,18 @@ const DuplicationResults: React.FC = () => { /** 批量删除 */ const handleBatchDelete = async () => { - try { - await Promise.all( - selectedRowKeys.map((key) => deleteDuplicationRecord(String(key))) - ); - message.success(`已删除 ${selectedRowKeys.length} 条记录`); - setSelectedRowKeys([]); - queryClient.invalidateQueries({ queryKey: ['duplication-records'] }); - } catch { - message.error('批量删除失败'); + const results = await Promise.allSettled( + selectedRowKeys.map((key) => deleteDuplicationRecord(String(key))) + ); + const succeeded = results.filter((r) => r.status === 'fulfilled').length; + const failed = results.length - succeeded; + if (failed === 0) { + message.success(`已删除 ${succeeded} 条记录`); + } else { + message.warning(`删除完成:${succeeded} 条成功,${failed} 条失败`); } + setSelectedRowKeys([]); + queryClient.invalidateQueries({ queryKey: ['duplication-records'] }); }; const columns: ColumnsType = [ diff --git a/apps/web/src/pages/duplication/DuplicationUpload.tsx b/apps/web/src/pages/duplication/DuplicationUpload.tsx index 5bd1344e9..22b8336b4 100644 --- a/apps/web/src/pages/duplication/DuplicationUpload.tsx +++ b/apps/web/src/pages/duplication/DuplicationUpload.tsx @@ -22,6 +22,7 @@ import { LoadingOutlined, } from '@ant-design/icons'; import { uploadForDuplication } from '@/api/duplication'; +import { useNavigate } from 'react-router-dom'; import type { UploadFile } from 'antd/es/upload'; const { Title, Text, Paragraph } = Typography; @@ -33,6 +34,7 @@ const ACCEPT_FORMATS = '.mp4,.avi,.mov,.mkv,.wmv,.flv,.webm'; const MAX_FILE_SIZE = 2 * 1024 * 1024 * 1024; const DuplicationUpload: React.FC = () => { + const navigate = useNavigate(); const [fileList, setFileList] = useState([]); const [uploadResult, setUploadResult] = useState<{ id: string; @@ -150,9 +152,7 @@ const DuplicationUpload: React.FC = () => { type="primary" key="view" icon={} - onClick={() => - (window.location.href = `/duplication/results`) - } + onClick={() => navigate('/duplication/results')} > 查看结果 ,