fix: 全部页面 confirm() 替换为 ConfirmDialog 组件 — 9个页面统一回调模式

This commit is contained in:
logan committed 2026-05-27 21:25:14 +08:00
1 parent 41dab3deab
commit 7f6a4bb6df
9 files changed
+153 -62

No files matched your search

+12 -5
View File
@@ -2,6 +2,7 @@ import { useState, useEffect, useCallback } from 'react';
import { Bell, Webhook, Check, Settings, TestTube, ToggleLeft, ToggleRight, Loader2, AlertCircle, Plus, Trash2 } from 'lucide-react';
import { Card, CardContent } from '@/components/ui/card';
import { notificationApi } from '@/api/notification';
import { ConfirmDialog } from '@/components/ConfirmDialog';
interface NotificationChannel {
id: number;
@@ -25,6 +26,7 @@ export default function NotificationsPage() {
const [error, setError] = useState<string | null>(null);
const [testingId, setTestingId] = useState<number | null>(null);
const [testResult, setTestResult] = useState<{ id: number; success: boolean; message: string } | null>(null);
const [deleteConfirm, setDeleteConfirm] = useState<{msg: string; onConfirm: () => void} | null>(null);
const fetchChannels = useCallback(async () => {
try {
@@ -67,11 +69,8 @@ export default function NotificationsPage() {
}, []);
const handleDelete = useCallback(async (id: number) => {
if (!confirm('确认删除该通知渠道?')) return;
try {
await notificationApi.delete(id);
setChannels(prev => prev.filter(c => c.id !== id));
} catch {}
setDeleteConfirm({msg: '确认删除该通知渠道?', onConfirm: async () => { try { await notificationApi.delete(id); setChannels(prev => prev.filter(c => c.id !== id)); } catch {} }});
return;
}, []);
if (loading) {
@@ -175,6 +174,14 @@ export default function NotificationsPage() {
</div>
</>
)}
<ConfirmDialog
open={!!deleteConfirm}
title={deleteConfirm?.msg || '确认操作'}
variant="danger"
confirmText="确定"
onConfirm={() => { deleteConfirm?.onConfirm(); }}
onCancel={() => setDeleteConfirm(null)}
/>
</div>
);
}