From c5270f82c1f6b6cadcdc5952eb242e1a1b824cff Mon Sep 17 00:00:00 2001 From: logan Date: Sun, 31 May 2026 14:34:21 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=89=B9=E9=87=8F=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=94=B9=E7=94=A8=20ConfirmDialog=20?= =?UTF-8?q?=E6=9B=BF=E4=BB=A3=E6=B5=8F=E8=A7=88=E5=99=A8=E5=8E=9F=E7=94=9F?= =?UTF-8?q?=20confirm()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - handleBatchAction 删除分支改为 setDeleteConfirm 弹 ConfirmDialog - 确认后执行删除,取消则关闭弹框 --- frontend/src/pages/UsersPage.tsx | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/frontend/src/pages/UsersPage.tsx b/frontend/src/pages/UsersPage.tsx index 41f84bf..d7e16f7 100644 --- a/frontend/src/pages/UsersPage.tsx +++ b/frontend/src/pages/UsersPage.tsx @@ -216,7 +216,20 @@ export default function UsersPage() { const handleBatchAction = async (action: string) => { const ids = Array.from(selectedIds); if (ids.length === 0) return; - if (action === 'delete' && !confirm(`确定删除选中的 ${ids.length} 个用户?此操作不可恢复。`)) return; + if (action === 'delete') { + setDeleteConfirm({ + msg: `确定删除选中的 ${ids.length} 个用户?此操作不可恢复。`, + onConfirm: async () => { + try { + await Promise.all(ids.map(id => userApi.delete(id))); + toast('success', `已删除 ${ids.length} 个用户`); + setSelectedIds(new Set()); + fetchUsers(); + } catch { toast('error', '批量删除失败'); } + }, + }); + return; + } try { if (action === 'enable') { await Promise.all(ids.map(id => userApi.update(id, { is_active: true }))); @@ -224,9 +237,6 @@ export default function UsersPage() { } else if (action === 'disable') { await Promise.all(ids.map(id => userApi.update(id, { is_active: false }))); toast('success', `已禁用 ${ids.length} 个用户`); - } else if (action === 'delete') { - await Promise.all(ids.map(id => userApi.delete(id))); - toast('success', `已删除 ${ids.length} 个用户`); } setSelectedIds(new Set()); fetchUsers();