refactor: 移除SQL审计+站内导航,AIOps子菜单6→3精简,服务器批量删除加确认框
- 移除SQL审计菜单和路由 - 移除站内导航菜单和路由 - AIOps智能子菜单从6个精简为3个:智能助手、告警分析、容量预测 - 移除智能运维中心(空壳)、故障诊断(与告警分析重复)、脚本生成(并入助手) - 服务器删除/批量删除添加Dialog确认框 - 删除/批量删除添加toast成功反馈
This commit is contained in:
1 parent
3be53b89fa
commit
d1415561ef
3 files changed
+25
-19
No files matched your search
@@ -46,6 +46,8 @@ import {
|
||||
RefreshCw,
|
||||
} from 'lucide-react';
|
||||
import { serverApi } from '@/services/api';
|
||||
import { useConfirm } from '@/components/ui/confirm-dialog';
|
||||
import { toast } from 'sonner';
|
||||
import type { Server as ServerType } from '@/types';
|
||||
import { CloudServerImport } from './CloudServerImport';
|
||||
import { TerminalDialog } from './TerminalDialog';
|
||||
@@ -53,6 +55,7 @@ import { ExcelServerImport } from './ExcelServerImport';
|
||||
import { ServerForm, EMPTY_FORM, type ServerFormData } from './ServerForm';
|
||||
|
||||
export function ServerManager() {
|
||||
const confirm = useConfirm();
|
||||
const [servers, setServers] = useState<any[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [selectedServers, setSelectedServers] = useState<string[]>([]);
|
||||
@@ -136,23 +139,42 @@ export function ServerManager() {
|
||||
};
|
||||
|
||||
const handleDelete = async (id: string) => {
|
||||
const server = servers.find((s) => String(s.id) === String(id));
|
||||
const ok = await confirm({
|
||||
title: '删除服务器',
|
||||
description: `确定删除「${server?.hostname || id}」吗?此操作不可撤销。`,
|
||||
confirmText: '删除',
|
||||
variant: 'destructive',
|
||||
});
|
||||
if (!ok) return;
|
||||
try {
|
||||
await serverApi.deleteServer(id);
|
||||
toast.success('服务器已删除');
|
||||
loadData();
|
||||
} catch (e) {
|
||||
console.error('删除服务器失败:', e);
|
||||
toast.error('删除失败');
|
||||
}
|
||||
};
|
||||
|
||||
// 批量删除
|
||||
const handleBatchDelete = async () => {
|
||||
if (selectedServers.length === 0) return;
|
||||
const ok = await confirm({
|
||||
title: '批量删除服务器',
|
||||
description: `确定删除选中的 ${selectedServers.length} 台服务器吗?此操作不可撤销。`,
|
||||
confirmText: '批量删除',
|
||||
variant: 'destructive',
|
||||
});
|
||||
if (!ok) return;
|
||||
try {
|
||||
await serverApi.batchDelete(selectedServers.map((id) => Number(id)));
|
||||
toast.success(`已删除 ${selectedServers.length} 台服务器`);
|
||||
setSelectedServers([]);
|
||||
loadData();
|
||||
} catch (e) {
|
||||
console.error('批量删除失败:', e);
|
||||
toast.error('批量删除失败');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user