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();