diff --git a/frontend/src/layouts/components/UserPanel.tsx b/frontend/src/layouts/components/UserPanel.tsx index 457db168..3e53ed6d 100644 --- a/frontend/src/layouts/components/UserPanel.tsx +++ b/frontend/src/layouts/components/UserPanel.tsx @@ -7,16 +7,7 @@ import type { MenuProps } from 'antd'; import { logout } from '@/store/userSlice'; import type { RootState } from '@/store'; import { useToast } from '@/components/ui/use-toast'; -import { - AlertDialog, - AlertDialogAction, - AlertDialogCancel, - AlertDialogContent, - AlertDialogDescription, - AlertDialogFooter, - AlertDialogHeader, - AlertDialogTitle, -} from '@/components/ui/alert-dialog'; +import { ConfirmDialog } from '@/components/ui/confirm-dialog'; import { AlertCircle } from 'lucide-react'; import { shallowEqual } from 'react-redux'; @@ -44,12 +35,8 @@ const UserPanel: React.FC = React.memo(() => { setLogoutDialogOpen(true); }; - const confirmLogout = () => { + const confirmLogout = async () => { dispatch(logout()); - toast({ - title: '退出成功', - description: '已成功退出系统', - }); navigate('/login', { replace: true }); }; @@ -92,25 +79,25 @@ const UserPanel: React.FC = React.memo(() => { {/* 退出登录确认对话框 */} - - - - - - 确认退出 - - - 确定要退出系统吗? - - - - setLogoutDialogOpen(false)}> - 取消 - - 确定 - - - + + + 确认退出 + + } + description="确定要退出系统吗?" + onConfirm={confirmLogout} + onSuccess={() => { + toast({ + title: '退出成功', + description: '已成功退出系统', + }); + }} + confirmText="确定" + /> ); }); diff --git a/frontend/src/pages/Deploy/Application/List/components/CategoryManageDialog.tsx b/frontend/src/pages/Deploy/Application/List/components/CategoryManageDialog.tsx index 21e9d49e..26a453f4 100644 --- a/frontend/src/pages/Deploy/Application/List/components/CategoryManageDialog.tsx +++ b/frontend/src/pages/Deploy/Application/List/components/CategoryManageDialog.tsx @@ -6,16 +6,7 @@ import { DialogBody, DialogTitle, } from "@/components/ui/dialog"; -import { - AlertDialog, - AlertDialogAction, - AlertDialogCancel, - AlertDialogContent, - AlertDialogDescription, - AlertDialogFooter, - AlertDialogHeader, - AlertDialogTitle, -} from "@/components/ui/alert-dialog"; +import { ConfirmDialog } from '@/components/ui/confirm-dialog'; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { @@ -175,25 +166,7 @@ const CategoryManageDialog: React.FC = ({ // 确认删除 const confirmDelete = async () => { if (!deleteRecord) return; - - try { - await deleteCategory(deleteRecord.id); - toast({ - title: "删除成功", - description: `分类 "${deleteRecord.name}" 已删除`, - }); - loadCategories(); - onSuccess?.(); - setDeleteDialogOpen(false); - setDeleteRecord(null); - } catch (error) { - console.error('删除失败:', error); - toast({ - variant: "destructive", - title: "删除失败", - description: error instanceof Error ? error.message : '未知错误', - }); - } + await deleteCategory(deleteRecord.id); }; // 保存 @@ -516,53 +489,52 @@ const CategoryManageDialog: React.FC = ({ {/* 删除确认对话框 */} - - - - 确认删除分类 - -
-

您确定要删除以下分类吗?此操作无法撤销。

- {deleteRecord && ( -
-
- 分类名称: - {deleteRecord.name} -
-
- 分类代码: - - {deleteRecord.code} - -
- {deleteRecord.icon && ( -
- 图标: - -
- )} - {deleteRecord.description && ( -
- 描述: - {deleteRecord.description} -
- )} -
- )} + { + toast({ + title: "删除成功", + description: `分类 "${deleteRecord?.name}" 已删除`, + }); + setDeleteRecord(null); + loadCategories(); + onSuccess?.(); + }} + variant="destructive" + confirmText="确认删除" + > + {deleteRecord && ( +
+
+ 分类名称: + {deleteRecord.name} +
+
+ 分类代码: + + {deleteRecord.code} + +
+ {deleteRecord.icon && ( +
+ 图标: +
- - - - 取消 - - 确认删除 - - - - + )} + {deleteRecord.description && ( +
+ 描述: + {deleteRecord.description} +
+ )} +
+ )} +
); }; diff --git a/frontend/src/pages/Deploy/NotificationChannel/List/index.tsx b/frontend/src/pages/Deploy/NotificationChannel/List/index.tsx index f360fe3e..32e49905 100644 --- a/frontend/src/pages/Deploy/NotificationChannel/List/index.tsx +++ b/frontend/src/pages/Deploy/NotificationChannel/List/index.tsx @@ -17,16 +17,7 @@ import { TableRow, } from '@/components/ui/table'; import { Badge } from '@/components/ui/badge'; -import { - AlertDialog, - AlertDialogAction, - AlertDialogCancel, - AlertDialogContent, - AlertDialogDescription, - AlertDialogFooter, - AlertDialogHeader, - AlertDialogTitle, -} from '@/components/ui/alert-dialog'; +import { ConfirmDialog } from '@/components/ui/confirm-dialog'; import { useToast } from '@/components/ui/use-toast'; import { DataTablePagination } from '@/components/ui/pagination'; import { DEFAULT_PAGE_SIZE, DEFAULT_CURRENT } from '@/utils/page'; @@ -176,20 +167,7 @@ const NotificationChannelList: React.FC = () => { // 删除 const handleDelete = async () => { if (!deleteId) return; - - try { - await deleteChannel(deleteId); - toast({ title: '删除成功' }); - setDeleteDialogOpen(false); - setDeleteId(null); - loadData(); - } catch (error: any) { - toast({ - variant: 'destructive', - title: '删除失败', - description: error.response?.data?.message || error.message, - }); - } + await deleteChannel(deleteId); }; // 启用/禁用 @@ -477,20 +455,22 @@ const NotificationChannelList: React.FC = () => { /> {/* 删除确认对话框 */} - - - - 确认删除 - - 确定要删除这个通知渠道吗?此操作不可撤销。 - - - - setDeleteId(null)}>取消 - 删除 - - - + { + toast({ title: '删除成功' }); + setDeleteId(null); + loadData(); + }} + onCancel={() => setDeleteId(null)} + variant="destructive" + confirmText="删除" + />
); }; diff --git a/frontend/src/pages/Deploy/ScheduleJob/List/components/CategoryManageDialog.tsx b/frontend/src/pages/Deploy/ScheduleJob/List/components/CategoryManageDialog.tsx index d2ca31ba..3d6d7928 100644 --- a/frontend/src/pages/Deploy/ScheduleJob/List/components/CategoryManageDialog.tsx +++ b/frontend/src/pages/Deploy/ScheduleJob/List/components/CategoryManageDialog.tsx @@ -6,16 +6,7 @@ import { DialogBody, DialogTitle, } from '@/components/ui/dialog'; -import { - AlertDialog, - AlertDialogAction, - AlertDialogCancel, - AlertDialogContent, - AlertDialogDescription, - AlertDialogFooter, - AlertDialogHeader, - AlertDialogTitle, -} from '@/components/ui/alert-dialog'; +import { ConfirmDialog } from '@/components/ui/confirm-dialog'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { @@ -180,25 +171,7 @@ const CategoryManageDialog: React.FC = ({ // 确认删除 const confirmDelete = async () => { if (!deleteRecord) return; - - try { - await deleteJobCategory(deleteRecord.id); - toast({ - title: '删除成功', - description: `分类 "${deleteRecord.name}" 已删除`, - }); - loadCategories(); - onSuccess?.(); - setDeleteDialogOpen(false); - setDeleteRecord(null); - } catch (error) { - console.error('删除失败:', error); - toast({ - variant: 'destructive', - title: '删除失败', - description: error instanceof Error ? error.message : '未知错误', - }); - } + await deleteJobCategory(deleteRecord.id); }; // 保存 @@ -542,21 +515,30 @@ const CategoryManageDialog: React.FC = ({ /> {/* 删除确认对话框 */} - - - - 确认删除 - - 确定要删除分类 {deleteRecord?.name} 吗? - 此操作无法撤销。 - - - - 取消 - 确认删除 - - - + + 确定要删除分类 {deleteRecord?.name} 吗? + 此操作无法撤销。 + + } + item={deleteRecord} + onConfirm={confirmDelete} + onSuccess={() => { + toast({ + title: '删除成功', + description: `分类 "${deleteRecord?.name}" 已删除`, + }); + setDeleteRecord(null); + loadCategories(); + onSuccess?.(); + }} + variant="destructive" + confirmText="确认删除" + /> ); }; diff --git a/frontend/src/pages/Deploy/ScheduleJob/List/index.tsx b/frontend/src/pages/Deploy/ScheduleJob/List/index.tsx index 9d8bef2b..b0aac419 100644 --- a/frontend/src/pages/Deploy/ScheduleJob/List/index.tsx +++ b/frontend/src/pages/Deploy/ScheduleJob/List/index.tsx @@ -20,16 +20,7 @@ import CategoryManageDialog from './components/CategoryManageDialog'; import JobLogDialog from './components/JobLogDialog'; import JobEditDialog from './components/JobEditDialog'; import Dashboard from './components/Dashboard'; -import { - AlertDialog, - AlertDialogAction, - AlertDialogCancel, - AlertDialogContent, - AlertDialogDescription, - AlertDialogFooter, - AlertDialogHeader, - AlertDialogTitle, -} from '@/components/ui/alert-dialog'; +import { ConfirmDialog } from '@/components/ui/confirm-dialog'; import dayjs from 'dayjs'; /** @@ -123,22 +114,7 @@ const ScheduleJobList: React.FC = () => { // 确认删除 const confirmDelete = async () => { if (!deleteJob) return; - try { - await deleteScheduleJob(deleteJob.id); - toast({ - title: '删除成功', - description: `任务 "${deleteJob.jobName}" 已删除`, - }); - loadData(); - setDeleteDialogOpen(false); - setDeleteJob(null); - } catch (error) { - toast({ - variant: 'destructive', - title: '删除失败', - description: error instanceof Error ? error.message : '未知错误', - }); - } + await deleteScheduleJob(deleteJob.id); }; // 暂停任务 @@ -612,55 +588,53 @@ const ScheduleJobList: React.FC = () => { /> {/* 删除确认对话框 */} - - - - 确认删除定时任务 - -
-

您确定要删除以下定时任务吗?此操作无法撤销。

- {deleteJob && ( -
-
- 任务名称: - {deleteJob.jobName} -
-
- Bean名称: - - {deleteJob.beanName} - -
-
- 方法名称: - - {deleteJob.methodName} - -
- {deleteJob.cronExpression && ( -
- Cron表达式: - - {deleteJob.cronExpression} - -
- )} -
- )} + { + toast({ + title: '删除成功', + description: `任务 "${deleteJob?.jobName}" 已删除`, + }); + setDeleteJob(null); + loadData(); + }} + variant="destructive" + confirmText="确认删除" + > + {deleteJob && ( +
+
+ 任务名称: + {deleteJob.jobName} +
+
+ Bean名称: + + {deleteJob.beanName} + +
+
+ 方法名称: + + {deleteJob.methodName} + +
+ {deleteJob.cronExpression && ( +
+ Cron表达式: + + {deleteJob.cronExpression} +
- - - - 取消 - - 确认删除 - - - - + )} +
+ )} +
{/* 仪表盘视图 */} diff --git a/frontend/src/pages/Form/Definition/List/components/CategoryManageDialog.tsx b/frontend/src/pages/Form/Definition/List/components/CategoryManageDialog.tsx index b13636a0..e74764e6 100644 --- a/frontend/src/pages/Form/Definition/List/components/CategoryManageDialog.tsx +++ b/frontend/src/pages/Form/Definition/List/components/CategoryManageDialog.tsx @@ -6,16 +6,7 @@ import { DialogBody, DialogTitle, } from "@/components/ui/dialog"; -import { - AlertDialog, - AlertDialogAction, - AlertDialogCancel, - AlertDialogContent, - AlertDialogDescription, - AlertDialogFooter, - AlertDialogHeader, - AlertDialogTitle, -} from "@/components/ui/alert-dialog"; +import { ConfirmDialog } from '@/components/ui/confirm-dialog'; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { @@ -172,25 +163,7 @@ const CategoryManageDialog: React.FC = ({ // 确认删除 const confirmDelete = async () => { if (!deleteRecord) return; - - try { - await deleteCategory(deleteRecord.id); - toast({ - title: "删除成功", - description: `分类 "${deleteRecord.name}" 已删除`, - }); - loadCategories(); - onSuccess?.(); - setDeleteDialogOpen(false); - setDeleteRecord(null); - } catch (error) { - console.error('删除失败:', error); - toast({ - variant: "destructive", - title: "删除失败", - description: error instanceof Error ? error.message : '未知错误', - }); - } + await deleteCategory(deleteRecord.id); }; // 保存 @@ -509,53 +482,52 @@ const CategoryManageDialog: React.FC = ({ {/* 删除确认对话框 */} - - - - 确认删除分类 - -
-

您确定要删除以下分类吗?此操作无法撤销。

- {deleteRecord && ( -
-
- 分类名称: - {deleteRecord.name} -
-
- 分类代码: - - {deleteRecord.code} - -
- {deleteRecord.icon && ( -
- 图标: - -
- )} - {deleteRecord.description && ( -
- 描述: - {deleteRecord.description} -
- )} -
- )} + { + toast({ + title: "删除成功", + description: `分类 "${deleteRecord?.name}" 已删除`, + }); + setDeleteRecord(null); + loadCategories(); + onSuccess?.(); + }} + variant="destructive" + confirmText="确认删除" + > + {deleteRecord && ( +
+
+ 分类名称: + {deleteRecord.name} +
+
+ 分类代码: + + {deleteRecord.code} + +
+ {deleteRecord.icon && ( +
+ 图标: +
- - - - 取消 - - 确认删除 - - - - + )} + {deleteRecord.description && ( +
+ 描述: + {deleteRecord.description} +
+ )} +
+ )} +
); }; diff --git a/frontend/src/pages/Resource/Server/List/components/CategoryManageDialog.tsx b/frontend/src/pages/Resource/Server/List/components/CategoryManageDialog.tsx index 79404bcd..4fe88ee0 100644 --- a/frontend/src/pages/Resource/Server/List/components/CategoryManageDialog.tsx +++ b/frontend/src/pages/Resource/Server/List/components/CategoryManageDialog.tsx @@ -33,7 +33,7 @@ import { TableRow, } from '@/components/ui/table'; import { useToast } from '@/components/ui/use-toast'; -import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from '@/components/ui/alert-dialog'; +import { ConfirmDialog } from '@/components/ui/confirm-dialog'; import { DataTablePagination } from '@/components/ui/pagination'; import { DEFAULT_PAGE_SIZE, DEFAULT_CURRENT } from '@/utils/page'; import type { ServerCategoryResponse } from '../types'; @@ -159,25 +159,7 @@ export const CategoryManageDialog: React.FC = ({ const confirmDelete = async () => { if (!categoryToDelete) return; - - try { - await deleteServerCategory(categoryToDelete.id); - toast({ - title: '删除成功', - description: `分类"${categoryToDelete.name}"已删除`, - }); - loadCategories(); - onSuccess?.(); - } catch (error) { - toast({ - variant: 'destructive', - title: '删除失败', - description: '删除服务器分类失败', - }); - } finally { - setDeleteConfirmOpen(false); - setCategoryToDelete(null); - } + await deleteServerCategory(categoryToDelete.id); }; // 提交表单 @@ -499,20 +481,25 @@ export const CategoryManageDialog: React.FC = ({ {/* 删除确认对话框 */} - - - - 确认删除 - - 确定要删除分类"{categoryToDelete?.name}"吗?此操作无法撤销。 - - - - 取消 - 确定 - - - + { + toast({ + title: '删除成功', + description: `分类"${categoryToDelete?.name}"已删除`, + }); + setCategoryToDelete(null); + loadCategories(); + onSuccess?.(); + }} + variant="destructive" + confirmText="确定" + /> ); }; diff --git a/frontend/src/pages/Resource/Server/List/index.tsx b/frontend/src/pages/Resource/Server/List/index.tsx index 0afc2f0b..1afe0c75 100644 --- a/frontend/src/pages/Resource/Server/List/index.tsx +++ b/frontend/src/pages/Resource/Server/List/index.tsx @@ -29,16 +29,7 @@ import { import { TooltipProvider, } from '@/components/ui/tooltip'; -import { - AlertDialog, - AlertDialogAction, - AlertDialogCancel, - AlertDialogContent, - AlertDialogDescription, - AlertDialogFooter, - AlertDialogHeader, - AlertDialogTitle, -} from '@/components/ui/alert-dialog'; +import { ConfirmDialog } from '@/components/ui/confirm-dialog'; import { useToast } from '@/components/ui/use-toast'; import { DataTablePagination } from '@/components/ui/pagination'; import { Input } from '@/components/ui/input'; @@ -215,25 +206,7 @@ const ServerList: React.FC = () => { const confirmDelete = async () => { if (!serverToDelete) return; - - try { - await deleteServer(serverToDelete.id); - toast({ - title: '删除成功', - description: `服务器"${serverToDelete.serverName}"已删除`, - }); - loadServers(); - loadStats(); - } catch (error: any) { - toast({ - variant: 'destructive', - title: '删除失败', - description: error.response?.data?.message || '删除失败', - }); - } finally { - setDeleteDialogOpen(false); - setServerToDelete(null); - } + await deleteServer(serverToDelete.id); }; // 成功回调 @@ -600,20 +573,25 @@ const ServerList: React.FC = () => { /> {/* 删除确认对话框 */} - - - - 确认删除 - - 确定要删除服务器"{serverToDelete?.serverName}"吗?此操作无法撤销。 - - - - 取消 - 确定 - - - + { + toast({ + title: '删除成功', + description: `服务器"${serverToDelete?.serverName}"已删除`, + }); + setServerToDelete(null); + loadServers(); + loadStats(); + }} + variant="destructive" + confirmText="确定" + /> ); }; diff --git a/frontend/src/pages/Workflow/Definition/List/components/CategoryManageDialog.tsx b/frontend/src/pages/Workflow/Definition/List/components/CategoryManageDialog.tsx index 4964bd90..edb98ef8 100644 --- a/frontend/src/pages/Workflow/Definition/List/components/CategoryManageDialog.tsx +++ b/frontend/src/pages/Workflow/Definition/List/components/CategoryManageDialog.tsx @@ -6,16 +6,7 @@ import { DialogBody, DialogTitle, } from "@/components/ui/dialog"; -import { - AlertDialog, - AlertDialogAction, - AlertDialogCancel, - AlertDialogContent, - AlertDialogDescription, - AlertDialogFooter, - AlertDialogHeader, - AlertDialogTitle, -} from "@/components/ui/alert-dialog"; +import { ConfirmDialog } from '@/components/ui/confirm-dialog'; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { @@ -190,25 +181,7 @@ const CategoryManageDialog: React.FC = ({ // 确认删除 const confirmDelete = async () => { if (!deleteRecord) return; - - try { - await deleteWorkflowCategory(deleteRecord.id); - toast({ - title: "删除成功", - description: `分类 "${deleteRecord.name}" 已删除`, - }); - loadCategories(); - onSuccess?.(); - setDeleteDialogOpen(false); - setDeleteRecord(null); - } catch (error) { - console.error('删除失败:', error); - toast({ - variant: "destructive", - title: "删除失败", - description: error instanceof Error ? error.message : '未知错误', - }); - } + await deleteWorkflowCategory(deleteRecord.id); }; // 保存 @@ -588,53 +561,52 @@ const CategoryManageDialog: React.FC = ({ {/* 删除确认对话框 */} - - - - 确认删除分类 - -
-

您确定要删除以下分类吗?此操作无法撤销。

- {deleteRecord && ( -
-
- 分类名称: - {deleteRecord.name} -
-
- 分类代码: - - {deleteRecord.code} - -
- {deleteRecord.icon && ( -
- 图标: - -
- )} - {deleteRecord.description && ( -
- 描述: - {deleteRecord.description} -
- )} -
- )} + { + toast({ + title: "删除成功", + description: `分类 "${deleteRecord?.name}" 已删除`, + }); + setDeleteRecord(null); + loadCategories(); + onSuccess?.(); + }} + variant="destructive" + confirmText="确认删除" + > + {deleteRecord && ( +
+
+ 分类名称: + {deleteRecord.name} +
+
+ 分类代码: + + {deleteRecord.code} + +
+ {deleteRecord.icon && ( +
+ 图标: +
- - - - 取消 - - 确认删除 - - - - + )} + {deleteRecord.description && ( +
+ 描述: + {deleteRecord.description} +
+ )} +
+ )} +
); };