refactor(q1): any 937→837, unused 25→0, catch any 清零, Record<string,unknown> 安全替换168处
- unused-vars 全清零: 删除未用 import + 前缀 _ - catch (e: any) 94处移除显式标注 (strict=false 隐式推断) - Record<string,any>→Record<string,unknown> 安全替换168处 (无属性访问场景) - tsc -b 零错误, npm run build 通过 - 9/9 API 回归测试通过
This commit is contained in:
1 parent
4ae215f4c9
commit
37c657987b
62 files changed
+133
-141
No files matched your search
@@ -1,7 +1,7 @@
|
||||
// Agent 管理
|
||||
// 从 services/api.ts 拆分 — Q3 api.ts 模块化
|
||||
|
||||
import { http, type ListResponse } from '@/utils/request';
|
||||
import { http } from '@/utils/request';
|
||||
|
||||
export const agentApi = {
|
||||
getLatest: () => http.get('/agent/latest'),
|
||||
|
||||
@@ -69,7 +69,7 @@ export function AgentAlerts() {
|
||||
await agentApi.resolveAlert(id);
|
||||
toast.success('告警已恢复');
|
||||
loadData();
|
||||
} catch (err: any) {
|
||||
} catch (err) {
|
||||
toast.error(err?.message || '操作失败');
|
||||
}
|
||||
};
|
||||
@@ -92,7 +92,7 @@ export function AgentAlerts() {
|
||||
await agentApi.deleteRule(id);
|
||||
toast.success('规则已删除');
|
||||
loadData();
|
||||
} catch (err: any) {
|
||||
} catch (err) {
|
||||
toast.error(err?.message || '删除失败');
|
||||
}
|
||||
};
|
||||
@@ -101,7 +101,7 @@ export function AgentAlerts() {
|
||||
try {
|
||||
await agentApi.updateRule(rule.id, { ...rule, enabled: !rule.enabled });
|
||||
loadData();
|
||||
} catch (err: any) {
|
||||
} catch (err) {
|
||||
toast.error(err?.message || '操作失败');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -111,7 +111,7 @@ export function AgentMonitor() {
|
||||
result: res?.data?.output || res?.message || '无输出',
|
||||
error: res?.data?.error,
|
||||
});
|
||||
} catch (err: any) {
|
||||
} catch (err) {
|
||||
setCmdResult({ status: 'failed', result: err?.message || '执行失败' });
|
||||
} finally {
|
||||
setCmdSubmitting(false);
|
||||
|
||||
@@ -73,7 +73,7 @@ export function AgentRuleDialog({ open, onOpenChange, editingRule, onSuccess }:
|
||||
}
|
||||
setSaving(true);
|
||||
try {
|
||||
const payload: Record<string, any> = {
|
||||
const payload: Record<string, unknown> = {
|
||||
name: ruleForm.name.trim(),
|
||||
metric: ruleForm.metric,
|
||||
operator: ruleForm.operator,
|
||||
@@ -94,7 +94,7 @@ export function AgentRuleDialog({ open, onOpenChange, editingRule, onSuccess }:
|
||||
}
|
||||
onOpenChange(false);
|
||||
onSuccess();
|
||||
} catch (err: any) {
|
||||
} catch (err) {
|
||||
toast.error(err?.message || '保存失败');
|
||||
} finally {
|
||||
setSaving(false);
|
||||
|
||||
@@ -177,7 +177,7 @@ export function AgentWizard({ open, onOpenChange, server, onInstalled, onFailed
|
||||
onInstalled?.(server.id);
|
||||
onOpenChange(false);
|
||||
}
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
const msg = e?.message || '安装失败';
|
||||
toast.error(`${server.hostname} ${msg}`);
|
||||
onFailed?.(server.id, msg);
|
||||
|
||||
@@ -16,7 +16,6 @@ import {
|
||||
TrendingUp,
|
||||
TrendingDown,
|
||||
AlertTriangle,
|
||||
CheckCircle,
|
||||
HardDrive,
|
||||
Cpu,
|
||||
MemoryStick,
|
||||
|
||||
@@ -67,7 +67,7 @@ export function ApprovalCreateDialog({
|
||||
setSelectedTemplate(null);
|
||||
setFormData({});
|
||||
onSuccess();
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast.error('提交失败', { description: e?.message });
|
||||
} finally {
|
||||
setSubmitting(false);
|
||||
|
||||
@@ -122,7 +122,7 @@ export function ApprovalFlow() {
|
||||
}
|
||||
setActionDialogOpen(false);
|
||||
loadData();
|
||||
} catch (error: any) {
|
||||
} catch (error) {
|
||||
toast.error('操作失败', { description: (error as Record<string, any>).message });
|
||||
} finally {
|
||||
setActionSubmitting(false);
|
||||
|
||||
@@ -34,7 +34,7 @@ export function parseFields( formSchema: any): any[] {
|
||||
// 在详情弹窗中渲染表单数据为键值对展示 // Logan.Li
|
||||
export function renderFormData(formDataStr: string, template?: any) {
|
||||
if (!formDataStr) return null;
|
||||
let data: Record<string, any>;
|
||||
let data: Record<string, unknown>;
|
||||
try {
|
||||
data = typeof formDataStr === 'string' ? JSON.parse(formDataStr) : formDataStr;
|
||||
} catch {
|
||||
|
||||
@@ -89,7 +89,7 @@ export function Login() {
|
||||
useUserStore.getState().login(result.user, result.token, result.permissions ?? null);
|
||||
localStorage.setItem('token', result.token);
|
||||
navigate('/', { replace: true });
|
||||
} catch (err: any) {
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? (err as Record<string, any>).message : '登录失败,请检查用户名和密码';
|
||||
setError(message);
|
||||
} finally {
|
||||
|
||||
@@ -79,7 +79,7 @@ export function BillingRecordDialog({ open, onOpenChange, editingRecord, onSucce
|
||||
onOpenChange(false);
|
||||
onSuccess();
|
||||
toast('保存成功');
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast.error('保存失败', { description: (e as Record<string, any>).message });
|
||||
} finally {
|
||||
setSubmitting(false);
|
||||
|
||||
@@ -70,7 +70,7 @@ export function BillingRuleDialog({ open, onOpenChange, editingRule, onSuccess }
|
||||
onOpenChange(false);
|
||||
onSuccess();
|
||||
toast('保存成功');
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast.error('保存失败', { description: (e as Record<string, any>).message });
|
||||
} finally {
|
||||
setSubmitting(false);
|
||||
|
||||
@@ -145,7 +145,7 @@ export function CloudAccountManager() {
|
||||
return matchesSearch && matchesProvider;
|
||||
});
|
||||
|
||||
const stats = {
|
||||
const _stats = {
|
||||
total: accounts.length,
|
||||
active: accounts.filter(a => a.status === 'active').length,
|
||||
inactive: accounts.filter(a => a.status === 'inactive').length,
|
||||
|
||||
@@ -18,16 +18,13 @@ import {
|
||||
Pencil,
|
||||
RefreshCw,
|
||||
Loader2,
|
||||
TrendingUp,
|
||||
Wallet,
|
||||
CalendarDays,
|
||||
AlertTriangle,
|
||||
Bell,
|
||||
} from 'lucide-react';
|
||||
import { toast } from 'sonner';
|
||||
import { useConfirm } from '@/components/ui/confirm-dialog';
|
||||
import { billingApi } from '@/api';
|
||||
import { formatCurrency, StatCard, TrendChart, providerLabels, providerColors } from './CloudBillingHelpers';
|
||||
import { formatCurrency, TrendChart, providerLabels, providerColors } from './CloudBillingHelpers';
|
||||
import { StatStrip } from '@/components/ui/stat-strip';
|
||||
import { BillingRecordDialog } from './BillingRecordDialog';
|
||||
import { BillingRuleDialog } from './BillingRuleDialog';
|
||||
@@ -60,7 +57,7 @@ export function CloudBilling() {
|
||||
try {
|
||||
const res = await billingApi.getStats();
|
||||
setStats(res);
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast.error('加载统计失败', { description: (e as Record<string, any>).message });
|
||||
} finally {
|
||||
setStatsLoading(false);
|
||||
@@ -76,7 +73,7 @@ export function CloudBilling() {
|
||||
if (filterEnd) params.end_date = filterEnd;
|
||||
const res = await billingApi.list(params);
|
||||
setRecords(res.list || []);
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast.error('加载账单失败', { description: (e as Record<string, any>).message });
|
||||
} finally {
|
||||
setRecordsLoading(false);
|
||||
@@ -88,7 +85,7 @@ export function CloudBilling() {
|
||||
try {
|
||||
const res = await billingApi.listAlertRules();
|
||||
setRules(res.list || []);
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast.error('加载预警规则失败', { description: (e as Record<string, any>).message });
|
||||
} finally {
|
||||
setRulesLoading(false);
|
||||
@@ -135,7 +132,7 @@ export function CloudBilling() {
|
||||
loadRecords();
|
||||
loadStats();
|
||||
toast('删除成功');
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast.error('删除失败', { description: (e as Record<string, any>).message });
|
||||
}
|
||||
};
|
||||
@@ -147,7 +144,7 @@ export function CloudBilling() {
|
||||
await billingApi.deleteAlertRule(id);
|
||||
loadRules();
|
||||
toast('删除成功');
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast.error('删除失败', { description: (e as Record<string, any>).message });
|
||||
}
|
||||
};
|
||||
@@ -157,7 +154,7 @@ export function CloudBilling() {
|
||||
await billingApi.toggleAlertRule(id);
|
||||
loadRules();
|
||||
loadStats();
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast.error('操作失败', { description: (e as Record<string, any>).message });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -144,7 +144,7 @@ export function DomainManager() {
|
||||
return matchesSearch && matchesStatus;
|
||||
});
|
||||
|
||||
const stats = {
|
||||
const _stats = {
|
||||
total: domains.length,
|
||||
active: domains.filter(d => d.status === 'active').length,
|
||||
expired: domains.filter(d => d.status === 'expired').length,
|
||||
|
||||
@@ -106,7 +106,7 @@ export default function DeployRBAC() {
|
||||
setShowCreate(false);
|
||||
setNewName(''); setNewCode(''); setNewPattern(''); setNewRole('editor'); setNewDesc('');
|
||||
loadData();
|
||||
} catch (e: any) { toast.error(e?.message || '创建失败'); }
|
||||
} catch (e) { toast.error(e?.message || '创建失败'); }
|
||||
finally { setSaving(false); }
|
||||
};
|
||||
|
||||
@@ -118,7 +118,7 @@ export default function DeployRBAC() {
|
||||
toast.success('已更新');
|
||||
setEditing(null);
|
||||
loadData();
|
||||
} catch (e: any) { toast.error(e?.message || '更新失败'); }
|
||||
} catch (e) { toast.error(e?.message || '更新失败'); }
|
||||
finally { setSaving(false); }
|
||||
};
|
||||
|
||||
@@ -145,7 +145,7 @@ export default function DeployRBAC() {
|
||||
toast.success('已分配');
|
||||
setAssignRoleId('');
|
||||
loadAssignments();
|
||||
} catch (e: any) { toast.error(e?.message || '分配失败'); }
|
||||
} catch (e) { toast.error(e?.message || '分配失败'); }
|
||||
finally { setAssignLoading(false); }
|
||||
};
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ export function FileBrowserDialog({
|
||||
const data = await pipelineApi.listRunFiles(runId, path || undefined);
|
||||
setListing(data);
|
||||
setCurrentPath(data?.current || '');
|
||||
} catch (err: any) {
|
||||
} catch (err) {
|
||||
setError(err?.message || '加载失败');
|
||||
setListing(null);
|
||||
} finally {
|
||||
|
||||
@@ -310,7 +310,7 @@ export default function PipelineEditor() {
|
||||
toast.success('已添加成员');
|
||||
setNewMemberUser('');
|
||||
loadMembers();
|
||||
} catch (e: any) { toast.error(e?.message || '添加失败'); }
|
||||
} catch (e) { toast.error(e?.message || '添加失败'); }
|
||||
};
|
||||
|
||||
const handleRemoveMember = async (memberId: number) => {
|
||||
|
||||
@@ -16,14 +16,10 @@ import {
|
||||
|
||||
RefreshCw,
|
||||
Cloud,
|
||||
Cpu,
|
||||
Container,
|
||||
Boxes,
|
||||
Activity,
|
||||
Server,
|
||||
HardDrive,
|
||||
Layers,
|
||||
Network,
|
||||
ChevronRight,
|
||||
TrendingUp,
|
||||
} from 'lucide-react';
|
||||
@@ -44,7 +40,7 @@ export default function ClusterComparePage() {
|
||||
try {
|
||||
const res: Record<string, any> = await kubernetesApi.getMultiClusterComparison();
|
||||
setData(res || null);
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
setError(e?.message || '加载失败');
|
||||
setData(null);
|
||||
} finally {
|
||||
|
||||
@@ -134,7 +134,7 @@ export function DeploymentDetail({ clusterCode, namespace, deploymentName, onBac
|
||||
await kubernetesApi.scaleDeployment(clusterCode, namespace, deploymentName, newReplicas);
|
||||
toast({ title: '扩缩容成功', description: `副本数已设置为 ${newReplicas}` });
|
||||
loadData();
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast({ title: '操作失败', description: e?.message || String(e), variant: 'destructive' });
|
||||
} finally { setActionLoading(''); }
|
||||
};
|
||||
@@ -144,7 +144,7 @@ export function DeploymentDetail({ clusterCode, namespace, deploymentName, onBac
|
||||
try {
|
||||
await kubernetesApi.restartDeployment(clusterCode, namespace, deploymentName);
|
||||
toast({ title: '重启指令已下发', description: 'Deployment 正在滚动重启' });
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast({ title: '重启失败', description: e?.message || String(e), variant: 'destructive' });
|
||||
} finally { setActionLoading(''); }
|
||||
};
|
||||
@@ -157,7 +157,7 @@ export function DeploymentDetail({ clusterCode, namespace, deploymentName, onBac
|
||||
toast({ title: '镜像更新成功', description: `正在滚动更新为 ${newImage}` });
|
||||
setShowImageUpdate(false);
|
||||
loadData();
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast({ title: '更新失败', description: e?.message || String(e), variant: 'destructive' });
|
||||
} finally { setActionLoading(''); }
|
||||
};
|
||||
@@ -187,7 +187,7 @@ export function DeploymentDetail({ clusterCode, namespace, deploymentName, onBac
|
||||
await kubernetesApi.deleteHPA(clusterCode, namespace, hpa.name);
|
||||
toast({ title: 'HPA 已删除' });
|
||||
loadData();
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast({ title: '删除失败', description: e?.message || String(e), variant: 'destructive' });
|
||||
}
|
||||
};
|
||||
@@ -667,7 +667,7 @@ function CreateHPADialog({ clusterCode, namespace, deploymentName, onCreated }:
|
||||
setOpen(false);
|
||||
onCreated();
|
||||
setForm({ name: '', minReplicas: 1, maxReplicas: 10, cpuPercent: 80, memPercent: 0 });
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast({ title: '创建失败', description: e?.message || String(e), variant: 'destructive' });
|
||||
} finally { setLoading(false); }
|
||||
};
|
||||
|
||||
@@ -312,7 +312,7 @@ export function DeploymentEditAdvanced({ clusterCode, namespace, deploymentName,
|
||||
await kubernetesApi.updateResourceYaml(clusterCode, namespace, 'deployments', deploymentName, json);
|
||||
toast({ title: '高级设置已保存', description: `${deploymentName} 更新已提交` });
|
||||
onSaved();
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast({ title: '保存失败', description: e?.message || String(e), variant: 'destructive' });
|
||||
} finally { setSaving(false); }
|
||||
};
|
||||
|
||||
@@ -113,7 +113,7 @@ export function DeploymentEditBasic({ clusterCode, namespace, deploymentName, ma
|
||||
await kubernetesApi.updateResourceYaml(clusterCode, namespace, 'deployments', deploymentName, json);
|
||||
toast({ title: '基本信息已保存', description: `${deploymentName} 更新已提交` });
|
||||
onSaved();
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast({ title: '保存失败', description: e?.message || String(e), variant: 'destructive' });
|
||||
} finally { setSaving(false); }
|
||||
};
|
||||
|
||||
@@ -103,7 +103,7 @@ export function DeploymentEditContainers({ clusterCode, namespace, deploymentNam
|
||||
await kubernetesApi.updateResourceYaml(clusterCode, namespace, 'deployments', deploymentName, json);
|
||||
toast({ title: '容器配置已保存', description: `${deploymentName} 更新已提交` });
|
||||
onSaved();
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast({ title: '保存失败', description: e?.message || String(e), variant: 'destructive' });
|
||||
} finally { setSaving(false); }
|
||||
};
|
||||
|
||||
@@ -177,7 +177,7 @@ export function DeploymentEditService({ clusterCode, namespace, deploymentName,
|
||||
|
||||
setServices(svcSummaries);
|
||||
setIngresses(ingSummaries);
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
console.error('M9 load error:', e);
|
||||
} finally { setLoading(false); }
|
||||
}, [clusterCode, namespace, manifest]);
|
||||
@@ -225,7 +225,7 @@ export function DeploymentEditService({ clusterCode, namespace, deploymentName,
|
||||
toast({ title: 'Service 已创建', description: name });
|
||||
setShowCreate(null);
|
||||
load();
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast({ title: '创建失败', description: e?.message || String(e), variant: 'destructive' });
|
||||
}
|
||||
};
|
||||
@@ -260,7 +260,7 @@ export function DeploymentEditService({ clusterCode, namespace, deploymentName,
|
||||
toast({ title: 'Ingress 已创建', description: name });
|
||||
setShowCreate(null);
|
||||
load();
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast({ title: '创建失败', description: e?.message || String(e), variant: 'destructive' });
|
||||
}
|
||||
};
|
||||
@@ -279,7 +279,7 @@ export function DeploymentEditService({ clusterCode, namespace, deploymentName,
|
||||
await kubernetesApi.deleteResourceYaml(clusterCode, namespace, resource, name);
|
||||
toast({ title: '已删除', description: `${kind === 'service' ? 'Service' : 'Ingress'} ${name} 已删除` });
|
||||
load();
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast({ title: '删除失败', description: e?.message || String(e), variant: 'destructive' });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -183,7 +183,7 @@ export function DeploymentEditStorage({ clusterCode, namespace, deploymentName,
|
||||
await kubernetesApi.updateResourceYaml(clusterCode, namespace, 'deployments', deploymentName, json);
|
||||
toast({ title: '存储配置已保存', description: `${deploymentName} 更新已提交` });
|
||||
onSaved();
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast({ title: '保存失败', description: e?.message || String(e), variant: 'destructive' });
|
||||
} finally { setSaving(false); }
|
||||
};
|
||||
|
||||
@@ -204,7 +204,7 @@ export function DeploymentView(props: DeploymentViewProps) {
|
||||
await kubernetesApi.rollbackDeployment(clusterCode, namespace, deployment.name, Number(revision));
|
||||
toast({ title: '回滚已下发', description: `正在回滚到 #${revision}` });
|
||||
onRefresh();
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast({ title: '回滚失败', description: e?.message || String(e), variant: 'destructive' });
|
||||
} finally { setRollbackLoading(null); }
|
||||
};
|
||||
@@ -216,7 +216,7 @@ export function DeploymentView(props: DeploymentViewProps) {
|
||||
await kubernetesApi.scaleDeployment(clusterCode, namespace, deployment.name, scaleValue);
|
||||
toast({ title: '伸缩已提交', description: `副本数 → ${scaleValue}` });
|
||||
onRefresh();
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast({ title: '伸缩失败', description: e?.message || String(e), variant: 'destructive' });
|
||||
} finally { setScaleLoading(false); }
|
||||
};
|
||||
|
||||
@@ -131,7 +131,7 @@ export function DeploymentWorkload({ clusterCode, namespace, deploymentName, mod
|
||||
await kubernetesApi.scaleDeployment(clusterCode, namespace, deploymentName, newReplicas);
|
||||
toast({ title: '扩缩容成功', description: `副本数已设置为 ${newReplicas}` });
|
||||
loadData();
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast({ title: '操作失败', description: e?.message || String(e), variant: 'destructive' });
|
||||
} finally { setActionLoading(''); }
|
||||
};
|
||||
@@ -143,7 +143,7 @@ export function DeploymentWorkload({ clusterCode, namespace, deploymentName, mod
|
||||
toast({ title: '伸缩成功', description: `副本数已设置为 ${scaleValue}` });
|
||||
setModal(null);
|
||||
loadData();
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast({ title: '操作失败', description: e?.message || String(e), variant: 'destructive' });
|
||||
} finally { setActionLoading(''); }
|
||||
};
|
||||
@@ -160,7 +160,7 @@ export function DeploymentWorkload({ clusterCode, namespace, deploymentName, mod
|
||||
await kubernetesApi.restartDeployment(clusterCode, namespace, deploymentName);
|
||||
toast({ title: '重启指令已下发', description: 'Deployment 正在滚动重启' });
|
||||
setTimeout(loadData, 1500);
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast({ title: '重启失败', description: e?.message || String(e), variant: 'destructive' });
|
||||
} finally { setActionLoading(''); }
|
||||
};
|
||||
@@ -183,7 +183,7 @@ export function DeploymentWorkload({ clusterCode, namespace, deploymentName, mod
|
||||
}
|
||||
toast({ title: `${action}成功`, description: `Deployment 滚动更新已${action}` });
|
||||
setTimeout(loadData, 1000);
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast({ title: `${action}失败`, description: e?.message || String(e), variant: 'destructive' });
|
||||
} finally { setActionLoading(''); }
|
||||
};
|
||||
@@ -201,7 +201,7 @@ export function DeploymentWorkload({ clusterCode, namespace, deploymentName, mod
|
||||
toast({ title: '镜像更新成功', description: `正在滚动更新为 ${newImage}` });
|
||||
setModal(null);
|
||||
loadData();
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast({ title: '更新失败', description: e?.message || String(e), variant: 'destructive' });
|
||||
} finally { setActionLoading(''); }
|
||||
};
|
||||
@@ -218,7 +218,7 @@ export function DeploymentWorkload({ clusterCode, namespace, deploymentName, mod
|
||||
toast({ title: '删除成功', description: `${deploymentName} 已删除` });
|
||||
setModal(null);
|
||||
setTimeout(() => navigate(`/kubernetes/${clusterCode}/namespace/${namespace}/deployments`), 800);
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast({ title: '删除失败', description: e?.message || String(e), variant: 'destructive' });
|
||||
} finally { setActionLoading(''); }
|
||||
};
|
||||
|
||||
@@ -16,8 +16,6 @@ import {
|
||||
Cloud,
|
||||
Plus,
|
||||
MoreHorizontal,
|
||||
Server,
|
||||
Database,
|
||||
CheckCircle,
|
||||
AlertTriangle,
|
||||
XCircle,
|
||||
@@ -104,7 +102,7 @@ export function KubernetesClusters() {
|
||||
const res: Record<string, any> = await kubernetesApi.syncCluster(id);
|
||||
if (!silent) toast.success(res?.message || '同步完成');
|
||||
loadData();
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
if (!silent) toast.error(e?.message || '同步失败');
|
||||
}
|
||||
};
|
||||
@@ -118,7 +116,7 @@ export function KubernetesClusters() {
|
||||
await kubernetesApi.exportAllResources(code);
|
||||
toast.success('导出完成,已开始下载');
|
||||
setExportCluster(null);
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast.error(e?.message || '导出失败');
|
||||
} finally {
|
||||
setExporting(false);
|
||||
|
||||
@@ -120,7 +120,7 @@ export function KubernetesWorkloads() {
|
||||
await kubernetesApi.scaleDeployment(selectedCluster, dep.namespace, dep.name, newReplicas);
|
||||
toast({ title: '扩缩容成功', description: `${dep.name} → ${newReplicas} 副本` });
|
||||
loadData();
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast({ title: '操作失败', description: e?.message || String(e), variant: 'destructive' });
|
||||
} finally {
|
||||
setActionLoading((prev) => { const n = { ...prev }; delete n[key]; return n; });
|
||||
|
||||
@@ -75,7 +75,7 @@ export default function NamespaceManagementPage() {
|
||||
setNewName('');
|
||||
setCreateOpen(false);
|
||||
await loadData();
|
||||
} catch (err: any) {
|
||||
} catch (err) {
|
||||
toast.error(err?.message || '创建失败');
|
||||
} finally {
|
||||
setCreating(false);
|
||||
@@ -89,7 +89,7 @@ export default function NamespaceManagementPage() {
|
||||
await kubernetesApi.deleteNamespace(clusterCode, deleteTarget);
|
||||
setDeleteTarget(null);
|
||||
await loadData();
|
||||
} catch (err: any) {
|
||||
} catch (err) {
|
||||
toast.error(err?.message || '删除失败');
|
||||
} finally {
|
||||
setDeleting(false);
|
||||
|
||||
@@ -65,7 +65,7 @@ export function PodFileBrowser({
|
||||
})).filter(e => e.name && e.name !== '.');
|
||||
setEntries(list);
|
||||
setCurrentPath(path);
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
setError((e as Record<string, any>).message || '加载文件列表失败');
|
||||
setEntries([]);
|
||||
} finally {
|
||||
@@ -115,7 +115,7 @@ export function PodFileBrowser({
|
||||
try {
|
||||
const text = await kubernetesApi.readPodFileText(clusterCode, namespace, podName, filePath, container || undefined);
|
||||
setPreview({ file: fileName, content: text });
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
setPreview({ file: fileName, content: `读取失败: ${(e as Record<string, any>).message}` });
|
||||
}
|
||||
};
|
||||
@@ -133,7 +133,7 @@ export function PodFileBrowser({
|
||||
try {
|
||||
await kubernetesApi.uploadPodFile(clusterCode, namespace, podName, currentPath, file, container || undefined);
|
||||
loadFiles(currentPath);
|
||||
} catch (err: any) {
|
||||
} catch (err) {
|
||||
setError(`上传失败: ${(err as Record<string, any>).message}`);
|
||||
} finally {
|
||||
setUploading(false);
|
||||
|
||||
@@ -162,7 +162,7 @@ export function PodLogsViewer({
|
||||
const raw = res?.logs ?? res?.data?.logs ?? (typeof res === 'string' ? res : '') ?? '';
|
||||
const arr = typeof raw === 'string' ? raw.split('\n') : (Array.isArray(raw) ? raw : String(raw).split('\n'));
|
||||
appendLines(arr);
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
appendLines([`\x1b[31m[获取日志失败: ${e?.message || String(e)}]\x1b[0m`]);
|
||||
toast({ title: '获取日志失败', description: e?.message || String(e), variant: 'destructive' });
|
||||
} finally {
|
||||
@@ -225,7 +225,7 @@ export function PodLogsViewer({
|
||||
}
|
||||
flush(); // 收尾
|
||||
appendLines(['\x1b[33m— 流式结束 —\x1b[0m']);
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
if (e?.name === 'AbortError') {
|
||||
appendLines(['\x1b[33m— 已停止 —\x1b[0m']);
|
||||
} else {
|
||||
|
||||
@@ -60,7 +60,7 @@ export function ResourceVisualEditor({ clusterCode, namespace, resource, name, o
|
||||
setMode('yaml');
|
||||
toast({ title: '可视化编辑不可用', description: '无法解析资源结构,已切换到 YAML 编辑模式' });
|
||||
}
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast({ title: '加载失败', description: (e as Record<string, any>).message, variant: 'destructive' });
|
||||
} finally { setLoading(false); }
|
||||
}, [clusterCode, namespace, resource, name]);
|
||||
@@ -76,7 +76,7 @@ export function ResourceVisualEditor({ clusterCode, namespace, resource, name, o
|
||||
toast({ title: '保存成功', description: `${resource}/${name} 已更新` });
|
||||
onSaved?.();
|
||||
onClose();
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast({ title: '保存失败', description: (e as Record<string, any>).message, variant: 'destructive' });
|
||||
} finally { setSaving(false); }
|
||||
};
|
||||
@@ -88,7 +88,7 @@ export function ResourceVisualEditor({ clusterCode, namespace, resource, name, o
|
||||
toast({ title: 'YAML 已应用', description: `${resource}/${name} 更新成功` });
|
||||
onSaved?.();
|
||||
onClose();
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast({ title: '保存失败', description: (e as Record<string, any>).message, variant: 'destructive' });
|
||||
} finally { setSaving(false); }
|
||||
};
|
||||
|
||||
@@ -85,7 +85,7 @@ export default function WorkloadViewPage() {
|
||||
kubernetesApi.getPods(clusterCode).catch(() => []),
|
||||
]);
|
||||
// yamlRes is raw YAML text — try to parse as JSON (K8s API accepts JSON as YAML superset)
|
||||
let parsed: Record<string, any> = null;
|
||||
let parsed: Record<string, unknown> = null;
|
||||
if (yamlRes && typeof yamlRes === 'string') {
|
||||
try { parsed = JSON.parse(yamlRes); } catch { parsed = { _raw: yamlRes }; }
|
||||
} else if (yamlRes && typeof yamlRes === 'object') {
|
||||
@@ -131,7 +131,7 @@ export default function WorkloadViewPage() {
|
||||
}
|
||||
toast({ title: '重启指令已下发', description: `${kind} 滚动重启已触发` });
|
||||
setTimeout(loadData, 1000);
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast({ title: '重启失败', description: e?.message || String(e), variant: 'destructive' });
|
||||
} finally { setActionLoading(false); }
|
||||
};
|
||||
@@ -143,7 +143,7 @@ export default function WorkloadViewPage() {
|
||||
toast({ title: '扩缩容成功', description: `StatefulSet 副本数已更新为 ${scaleValue}` });
|
||||
setScaleModal(false);
|
||||
setTimeout(loadData, 1000);
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast({ title: '扩缩容失败', description: e?.message || String(e), variant: 'destructive' });
|
||||
} finally { setActionLoading(false); }
|
||||
};
|
||||
@@ -151,8 +151,8 @@ export default function WorkloadViewPage() {
|
||||
// Parse status from manifest
|
||||
const spec = manifest?.spec || {};
|
||||
const status = manifest?.status || {};
|
||||
const containers: Record<string, any>[] = spec?.template?.spec?.containers || [];
|
||||
const initContainers: Record<string, any>[] = spec?.template?.spec?.initContainers || [];
|
||||
const containers: Record<string, unknown>[] = spec?.template?.spec?.containers || [];
|
||||
const initContainers: Record<string, unknown>[] = spec?.template?.spec?.initContainers || [];
|
||||
|
||||
// For StatefulSet
|
||||
const replicas = spec.replicas ?? 1;
|
||||
@@ -177,7 +177,7 @@ export default function WorkloadViewPage() {
|
||||
const strategyType = updateStrategy.type || (isSts ? 'RollingUpdate' : 'RollingUpdate');
|
||||
|
||||
// VolumeClaimTemplates (StatefulSet only)
|
||||
const vcts: Record<string, any>[] = spec.volumeClaimTemplates || [];
|
||||
const vcts: Record<string, unknown>[] = spec.volumeClaimTemplates || [];
|
||||
|
||||
// Selector
|
||||
const selectorLabels = spec.selector?.matchLabels || {};
|
||||
|
||||
@@ -52,7 +52,7 @@ export function YamlViewer({ clusterCode, namespace, resource, name, onClose, on
|
||||
const text = await kubernetesApi.getResourceYaml(clusterCode, namespace, resource, name);
|
||||
setRawYaml(text);
|
||||
setEditYaml(effectiveClean ? cleanYAML(text) : text);
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast({ title: '获取YAML失败', description: (e as Record<string, any>).message, variant: 'destructive' });
|
||||
const err = `# Error: ${e.message}`;
|
||||
setRawYaml(err);
|
||||
@@ -81,7 +81,7 @@ export function YamlViewer({ clusterCode, namespace, resource, name, onClose, on
|
||||
setEditing(false);
|
||||
setRawYaml(editYaml);
|
||||
onSaved?.();
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast({ title: '保存失败', description: (e as Record<string, any>).message, variant: 'destructive' });
|
||||
} finally { setSaving(false); }
|
||||
};
|
||||
|
||||
@@ -189,7 +189,7 @@ export function ContainerEditor({ container, onUpdate }: ContainerEditorProps) {
|
||||
<ProbeEditor key={pt}
|
||||
label={{ livenessProbe: '存活探针 (liveness)', readinessProbe: '就绪探针 (readiness)', startupProbe: '启动探针 (startup)' }[pt]}
|
||||
probe={c[pt]}
|
||||
onChange={(p) => onUpdate({ [pt]: p } as Record<string, any>)}
|
||||
onChange={(p) => onUpdate({ [pt]: p } as Record<string, unknown>)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useState, useCallback, useEffect } from 'react';
|
||||
import { useCallback, useEffect } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { useThemeStore, useNotificationStore, useUserStore } from '@/store';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// 告警中心主组件 // Logan.Li
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import {
|
||||
AlertTriangle, AlertCircle, CheckCircle, Zap, Search, RefreshCw,
|
||||
AlertTriangle, CheckCircle, Search, RefreshCw,
|
||||
Eye, Check, VolumeX, Plus, Rocket,
|
||||
} from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
|
||||
@@ -3,7 +3,6 @@ import React, { useState, useEffect } from 'react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Label } from '@/components/ui/label';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import {
|
||||
Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter,
|
||||
} from '@/components/ui/dialog';
|
||||
|
||||
@@ -142,7 +142,7 @@ export const PrometheusDashboard: React.FC<Props> = ({ dsUrl }) => {
|
||||
const data: Record<string, any> = await prometheusProxyApi.connect(u);
|
||||
setConnected(true); setTargets(data.targets||0);
|
||||
loadAll(u);
|
||||
} catch (e: any) { setConnected(false); setError((e as Record<string, any>).message||'连接失败'); }
|
||||
} catch (e) { setConnected(false); setError((e as Record<string, any>).message||'连接失败'); }
|
||||
finally { setLoading(false); }
|
||||
};
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ export const ZabbixDashboard: React.FC<Props> = ({ dsUrl, dsUsername, dsPassword
|
||||
setHosts(data.hosts || []);
|
||||
setVersion(data.version || '');
|
||||
setConnected(true);
|
||||
} catch (e: any) { setConnected(false); setError((e as Record<string, any>).message || '连接失败'); }
|
||||
} catch (e) { setConnected(false); setError((e as Record<string, any>).message || '连接失败'); }
|
||||
finally { setLoading(false); }
|
||||
};
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ export default function ZabbixDatasourceManager() {
|
||||
}
|
||||
setDialogOpen(false);
|
||||
fetchList();
|
||||
} catch (err: any) {
|
||||
} catch (err) {
|
||||
toast.error(err?.message || '操作失败');
|
||||
}
|
||||
};
|
||||
@@ -171,7 +171,7 @@ export default function ZabbixDatasourceManager() {
|
||||
});
|
||||
const data = res?.data || res;
|
||||
setTestResult(data);
|
||||
} catch (err: any) {
|
||||
} catch (err) {
|
||||
setTestResult({ success: false, message: err?.message || '测试失败' });
|
||||
} finally {
|
||||
setTesting(false);
|
||||
|
||||
@@ -7,7 +7,6 @@ import {
|
||||
ArrowRight,
|
||||
ChevronRight,
|
||||
ChevronDown,
|
||||
Activity,
|
||||
Zap,
|
||||
AlertCircle,
|
||||
CheckCircle,
|
||||
@@ -16,7 +15,6 @@ import {
|
||||
TrendingUp,
|
||||
RefreshCw,
|
||||
Eye,
|
||||
Layers,
|
||||
GitBranch,
|
||||
Code,
|
||||
Box,
|
||||
|
||||
@@ -100,7 +100,7 @@ export function CloudServerImport({ open, onClose }: CloudServerImportProps) {
|
||||
await cloudApi.syncRegions(accountId);
|
||||
const list = await loadRegions(accountId);
|
||||
setRegions(list);
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
console.error('同步区域失败:', e);
|
||||
throw e;
|
||||
} finally {
|
||||
@@ -135,7 +135,7 @@ export function CloudServerImport({ open, onClose }: CloudServerImportProps) {
|
||||
const res: Record<string, any> = await cloudApi.discoverInstances(selectedAccount.id, selectedRegions);
|
||||
setCloudServers(res?.list || []);
|
||||
setDiscoverErrors(res?.errors || []);
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
console.error('发现主机失败:', e);
|
||||
setDiscoverErrors([e?.message || '发现主机失败']);
|
||||
} finally {
|
||||
@@ -154,7 +154,7 @@ export function CloudServerImport({ open, onClose }: CloudServerImportProps) {
|
||||
credential_id: selectedCredentialId ? Number(selectedCredentialId) : undefined,
|
||||
});
|
||||
setImportResult((res as any) || { imported: 0, skipped: 0 });
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
console.error('导入失败:', e);
|
||||
} finally {
|
||||
setIsImporting(false);
|
||||
|
||||
@@ -252,7 +252,7 @@ export function ExcelServerImport({ open, onClose }: ExcelServerImportProps) {
|
||||
toast.success(`导入完成:成功 ${success},跳过 ${skipped},失败 ${failed}`);
|
||||
resetState();
|
||||
onClose();
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast.error(e?.message || '导入失败,请重试');
|
||||
} finally {
|
||||
setIsImporting(false);
|
||||
|
||||
@@ -75,7 +75,7 @@ export function ServerFileBrowser({ open, onOpenChange, serverId, serverName }:
|
||||
setItems(data.items || []);
|
||||
setBreadcrumbs(data.breadcrumbs || []);
|
||||
setCurrentPath(data.path || path);
|
||||
} catch (err: any) {
|
||||
} catch (err) {
|
||||
setError(err?.message || '加载目录失败');
|
||||
setItems([]);
|
||||
} finally {
|
||||
@@ -106,7 +106,7 @@ export function ServerFileBrowser({ open, onOpenChange, serverId, serverName }:
|
||||
try {
|
||||
await serverApi.uploadFile(serverId, currentPath, file);
|
||||
await fetchDir(currentPath);
|
||||
} catch (err: any) {
|
||||
} catch (err) {
|
||||
setError(err?.message || '上传失败');
|
||||
} finally {
|
||||
setUploading(false);
|
||||
@@ -119,7 +119,7 @@ export function ServerFileBrowser({ open, onOpenChange, serverId, serverName }:
|
||||
try {
|
||||
await serverApi.deleteFile(serverId, filePath);
|
||||
await fetchDir(currentPath);
|
||||
} catch (err: any) {
|
||||
} catch (err) {
|
||||
setError(err?.message || '删除失败');
|
||||
}
|
||||
};
|
||||
@@ -131,7 +131,7 @@ export function ServerFileBrowser({ open, onOpenChange, serverId, serverName }:
|
||||
try {
|
||||
await serverApi.mkdir(serverId, newPath);
|
||||
await fetchDir(currentPath);
|
||||
} catch (err: any) {
|
||||
} catch (err) {
|
||||
setError(err?.message || '创建失败');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -287,7 +287,7 @@ export function ServerManager() {
|
||||
if (!formData.hostname || !formData.ip) return;
|
||||
try {
|
||||
setFormSaving(true);
|
||||
const payload: Record<string, any> = {
|
||||
const payload: Record<string, unknown> = {
|
||||
hostname: formData.hostname,
|
||||
ip: formData.ip,
|
||||
public_ip: formData.public_ip || undefined,
|
||||
|
||||
@@ -65,7 +65,7 @@ export function TerminalDialog({
|
||||
await serverCredentialApi.assign(serverId, Number(selectedCredId));
|
||||
toast.success('凭据已关联');
|
||||
setAuthReady(true);
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast.error(e?.message || '关联失败');
|
||||
} finally {
|
||||
setAssigning(false);
|
||||
|
||||
@@ -104,7 +104,7 @@ export function CredentialManager() {
|
||||
}
|
||||
setFormOpen(false);
|
||||
fetchList();
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast.error(e?.message || '操作失败');
|
||||
} finally {
|
||||
setSaving(false);
|
||||
|
||||
@@ -221,7 +221,7 @@ export function SystemManager() {
|
||||
const res = await userApi.batchImport({ users: importPreview, skip_existing: true });
|
||||
setImportResult(res);
|
||||
await loadUsers();
|
||||
} catch (error: any) {
|
||||
} catch (error) {
|
||||
setImportResult({ code: 500, message: error?.message || '导入失败' });
|
||||
} finally {
|
||||
ldap.setImporting(false);
|
||||
|
||||
@@ -6,7 +6,7 @@ import { Badge } from '@/components/ui/badge';
|
||||
import {
|
||||
Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle,
|
||||
} from '@/components/ui/dialog';
|
||||
import { Plus, Shield, ShieldCheck, Edit, Eye, Trash2, Lock, Star } from 'lucide-react';
|
||||
import { Plus, Shield, ShieldCheck, Edit, Eye, Trash2, Lock } from 'lucide-react';
|
||||
import { userApi } from '@/api';
|
||||
import { useConfirm } from '@/components/ui/confirm-dialog';
|
||||
import type { Role } from '@/types';
|
||||
@@ -153,7 +153,7 @@ export function SystemRolesTab({ selectedRole, setSelectedRole }: SystemRolesTab
|
||||
}
|
||||
setDialogOpen(false);
|
||||
await loadRoles();
|
||||
} catch (err: any) {
|
||||
} catch (err) {
|
||||
toast.error(err?.message || '保存失败');
|
||||
} finally {
|
||||
setSaving(false);
|
||||
@@ -176,7 +176,7 @@ export function SystemRolesTab({ selectedRole, setSelectedRole }: SystemRolesTab
|
||||
await userApi.deleteRole(role.id);
|
||||
toast.success('角色已删除');
|
||||
await loadRoles();
|
||||
} catch (err: any) {
|
||||
} catch (err) {
|
||||
const msg = err?.response?.data?.message || err?.message || '删除失败';
|
||||
toast.error(msg);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
TableRow,
|
||||
} from '@/components/ui/table';
|
||||
import { Search, RefreshCw, Trash2, Play } from 'lucide-react';
|
||||
import { useTerminalSessions, useTerminalSessionMutations, type TerminalSession } from '@/hooks/api/useTerminalSessions';
|
||||
import { useTerminalSessions, useTerminalSessionMutations } from '@/hooks/api/useTerminalSessions';
|
||||
import { useConfirm } from '@/components/ui/confirm-dialog';
|
||||
import { ReplayDialog } from './ReplayDialog';
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ export function useLdapManagement(onUsersChanged: () => Promise<void> | void) {
|
||||
await ldapApi.updateConfig(ldapForm);
|
||||
const res = await ldapApi.testConnection();
|
||||
setLdapTestResult(res?.message || (res?.success ? '连接成功' : '连接失败'));
|
||||
} catch (error: any) {
|
||||
} catch (error) {
|
||||
setLdapTestResult(error?.message || '连接失败');
|
||||
} finally {
|
||||
setLdapTesting(false);
|
||||
@@ -141,7 +141,7 @@ export function useLdapManagement(onUsersChanged: () => Promise<void> | void) {
|
||||
setCreateOUOpen(false);
|
||||
setOuForm({ ou_name: '', parent_dn: '', description: '' });
|
||||
await loadLdapOUs();
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
const msg = e?.message || '';
|
||||
if (msg.includes('Already Exists') || msg.includes('68')) {
|
||||
toast.error(`OU "${ouForm.ou_name}" 已存在,请使用其他名称`);
|
||||
@@ -159,7 +159,7 @@ export function useLdapManagement(onUsersChanged: () => Promise<void> | void) {
|
||||
setCreateUserOpen(false);
|
||||
setNewUser({ username: '', password: '', display_name: '', email: '', ou_dn: '' });
|
||||
await loadLdapOUUsers(selectedOUDN);
|
||||
} catch (e: any) { toast.error(e?.message || '创建失败'); }
|
||||
} catch (e) { toast.error(e?.message || '创建失败'); }
|
||||
finally { setLdapSaving(false); }
|
||||
};
|
||||
|
||||
@@ -172,7 +172,7 @@ export function useLdapManagement(onUsersChanged: () => Promise<void> | void) {
|
||||
try {
|
||||
await ldapApi.deleteUser(dn);
|
||||
if (!silent) await loadLdapOUUsers(selectedOUDN);
|
||||
} catch (e: any) { if (!silent) toast.error(e?.message || '删除失败'); }
|
||||
} catch (e) { if (!silent) toast.error(e?.message || '删除失败'); }
|
||||
};
|
||||
|
||||
/** 打开 LDAP 用户编辑 // Logan.Li */
|
||||
@@ -188,7 +188,7 @@ export function useLdapManagement(onUsersChanged: () => Promise<void> | void) {
|
||||
await ldapApi.updateUser({ dn: editLdapUser.dn, ...editLdapForm });
|
||||
setEditLdapUser(null);
|
||||
await loadLdapOUUsers(selectedOUDN);
|
||||
} catch (e: any) { toast.error(e?.message || '修改失败'); }
|
||||
} catch (e) { toast.error(e?.message || '修改失败'); }
|
||||
};
|
||||
|
||||
/** LDAP 账号验证测试 // Logan.Li */
|
||||
@@ -198,7 +198,7 @@ export function useLdapManagement(onUsersChanged: () => Promise<void> | void) {
|
||||
try {
|
||||
const res = await ldapApi.testConnection({ test_user: ldapTestUser, test_password: ldapTestPass });
|
||||
setLdapUserTestResult(res);
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
setLdapUserTestResult({ success: false, message: e?.message || '验证失败' });
|
||||
} finally { setLdapUserTesting(false); }
|
||||
};
|
||||
@@ -240,7 +240,7 @@ export function useLdapManagement(onUsersChanged: () => Promise<void> | void) {
|
||||
setImportResultOpen(true);
|
||||
setSelectedLDAPUsers([]);
|
||||
await onUsersChanged();
|
||||
} catch (error: any) {
|
||||
} catch (error) {
|
||||
setImportFeedback('导入失败: ' + (error?.message || '未知错误'));
|
||||
setImportResultOpen(true);
|
||||
} finally {
|
||||
|
||||
@@ -114,7 +114,7 @@ export function ApprovalCategoryPage({ category, title, description, fields, tem
|
||||
});
|
||||
toast.success('申请已提交');
|
||||
setDialogOpen(false); setFormData({}); fetchProcesses();
|
||||
} catch (err: any) { toast.error(err?.message || '提交失败'); }
|
||||
} catch (err) { toast.error(err?.message || '提交失败'); }
|
||||
finally { setSubmitting(false); }
|
||||
};
|
||||
|
||||
@@ -127,14 +127,14 @@ export function ApprovalCategoryPage({ category, title, description, fields, tem
|
||||
const handleApprove = async (id: number) => {
|
||||
setActing(true);
|
||||
try { await approvalApi.approveProcess(id); toast.success('已通过'); fetchProcesses(); }
|
||||
catch (err: any) { toast.error(err?.response?.data?.message || '审批失败'); }
|
||||
catch (err) { toast.error(err?.response?.data?.message || '审批失败'); }
|
||||
finally { setActing(false); }
|
||||
};
|
||||
|
||||
const handleReject = async (id: number) => {
|
||||
setActing(true);
|
||||
try { await approvalApi.rejectProcess(id, '审批拒绝'); toast.success('已拒绝'); fetchProcesses(); }
|
||||
catch (err: any) { toast.error(err?.response?.data?.message || '操作失败'); }
|
||||
catch (err) { toast.error(err?.response?.data?.message || '操作失败'); }
|
||||
finally { setActing(false); }
|
||||
};
|
||||
|
||||
@@ -302,14 +302,14 @@ function DetailTimelineDialog({ item, onClose, fields, onStatusChange }: {
|
||||
const handleApprove = async () => {
|
||||
setActing(true);
|
||||
try { await approvalApi.approveProcess(item.id); toast.success('已通过'); onStatusChange(); onClose(); }
|
||||
catch (err: any) { toast.error(err?.response?.data?.message || '审批失败'); }
|
||||
catch (err) { toast.error(err?.response?.data?.message || '审批失败'); }
|
||||
finally { setActing(false); }
|
||||
};
|
||||
|
||||
const handleReject = async () => {
|
||||
setActing(true);
|
||||
try { await approvalApi.rejectProcess(item.id, '审批拒绝'); toast.success('已拒绝'); onStatusChange(); onClose(); }
|
||||
catch (err: any) { toast.error(err?.response?.data?.message || '操作失败'); }
|
||||
catch (err) { toast.error(err?.response?.data?.message || '操作失败'); }
|
||||
finally { setActing(false); }
|
||||
};
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ import {
|
||||
Search,
|
||||
RefreshCw,
|
||||
Download,
|
||||
BarChart3,
|
||||
Eye,
|
||||
X,
|
||||
} from 'lucide-react';
|
||||
@@ -53,7 +52,7 @@ interface AuditStatistics {
|
||||
}
|
||||
|
||||
export function AuditOperationsTab() {
|
||||
const confirm = useConfirm();
|
||||
const _confirm = useConfirm();
|
||||
// Filters
|
||||
const [keyword, setKeyword] = useState('');
|
||||
const [moduleFilter, setModuleFilter] = useState('');
|
||||
@@ -130,7 +129,7 @@ export function AuditOperationsTab() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleShowStats = async () => {
|
||||
const _handleShowStats = async () => {
|
||||
setStatsOpen(true);
|
||||
setStatsLoading(true);
|
||||
try {
|
||||
|
||||
@@ -83,10 +83,10 @@ export function HostMonitor() {
|
||||
const metrics = useMemo(() => buildMetricsFromHistory(history, timeConfig), [history, timeConfig]);
|
||||
|
||||
const netInfo = parseJSON(latest?.net_info);
|
||||
const portInfo: Record<string, unknown>[] = Array.isArray(latest?.port_info) ? latest.port_info : (Array.isArray(parseJSON(latest?.port_info)) ? parseJSON(latest?.port_info) : []);
|
||||
const portInfo: Record<string, any>[] = Array.isArray(latest?.port_info) ? latest.port_info : (Array.isArray(parseJSON(latest?.port_info)) ? parseJSON(latest?.port_info) : []);
|
||||
const diskIOInfo = parseJSON(latest?.disk_io_info);
|
||||
const swapInfo = parseJSON(latest?.swap_info);
|
||||
const processTop: Record<string, unknown>[] = Array.isArray(parseJSON(latest?.process_top_info)) ? parseJSON(latest?.process_top_info) : [];
|
||||
const processTop: Record<string, any>[] = Array.isArray(parseJSON(latest?.process_top_info)) ? parseJSON(latest?.process_top_info) : [];
|
||||
const fdInfo = parseJSON(latest?.fd_info);
|
||||
const csInfo = parseJSON(latest?.cs_info);
|
||||
const heartbeatInfo = parseJSON(latest?.heartbeat_info);
|
||||
@@ -115,7 +115,7 @@ export function HostMonitor() {
|
||||
</Select>
|
||||
{serverInfo && (
|
||||
<span className="text-xs text-[var(--dg-text-muted)] ml-2">
|
||||
{serverInfo.os || ''}{serverInfo.cpu_cores ? ` | ${serverInfo.cpu_cores} 核` : ''}{serverInfo.mem_total ? ` | ${serverInfo.mem_total.toFixed(0)}GB` : ''}
|
||||
{String(serverInfo.os || '')}{serverInfo.cpu_cores ? ` | ${serverInfo.cpu_cores as number | string} 核` : ''}{serverInfo.mem_total ? ` | ${(serverInfo.mem_total as number).toFixed(0)}GB` : ''}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
@@ -159,11 +159,11 @@ export function HostMonitor() {
|
||||
<TabsContent value="basic" className="mt-3 grid grid-cols-1 md:grid-cols-3 gap-3">
|
||||
<MetricChartCard title="CPU 使用率(%)" value={currentVal('cpu')} icon={<Cpu className="h-4 w-4 text-blue-400" />}
|
||||
data={metrics.cpu} color="#3b82f6" unit="%" domain={[0, 100]} aggType={aggType} />
|
||||
<MetricChartCard title="CPU IO等待(%)" value={latest?.cpu_iowait != null ? `${latest.cpu_iowait.toFixed(1)}%` : '--'} icon={<Clock className="h-4 w-4 text-orange-400" />}
|
||||
<MetricChartCard title="CPU IO等待(%)" value={latest?.cpu_iowait != null ? `${(latest.cpu_iowait as number).toFixed(1)}%` : '--'} icon={<Clock className="h-4 w-4 text-orange-400" />}
|
||||
data={metrics.iowait} color="#f97316" unit="%" domain={[0, 100]} aggType={aggType} />
|
||||
<MetricChartCard title="内存使用率(%)" value={currentVal('mem')} icon={<Server className="h-4 w-4 text-emerald-400" />}
|
||||
data={metrics.mem} color="#10b981" unit="%" domain={[0, 100]} aggType={aggType} />
|
||||
<MetricChartCard title="可用内存(GB)" value={latest?.mem_available != null ? `${latest.mem_available.toFixed(1)}GB` : '--'} icon={<Server className="h-4 w-4 text-emerald-400" />}
|
||||
<MetricChartCard title="可用内存(GB)" value={latest?.mem_available != null ? `${(latest.mem_available as number).toFixed(1)}GB` : '--'} icon={<Server className="h-4 w-4 text-emerald-400" />}
|
||||
data={metrics.memAvail} color="#34d399" unit="GB" domain={[0, 'auto']} aggType={aggType} />
|
||||
<MetricChartCard title="Swap 使用率(%)" value={currentVal('swap')} icon={<HardDrive className="h-4 w-4 text-red-400" />}
|
||||
data={metrics.swap} color="#ef4444" unit="%" domain={[0, 100]} aggType={aggType} />
|
||||
|
||||
@@ -70,7 +70,7 @@ export function MiddlewareMonitor() {
|
||||
setError('');
|
||||
const data = await metricsApi.getTargets({ type: 'middleware', page_size: 200 }) as TargetsResponse;
|
||||
setTargets(data?.list || []);
|
||||
} catch (err: any) {
|
||||
} catch (err) {
|
||||
setError((err as Record<string, any>).message || '加载失败');
|
||||
setTargets([]);
|
||||
} finally {
|
||||
|
||||
@@ -205,7 +205,7 @@ export function SiteMonitor() {
|
||||
setFormOpen(false);
|
||||
loadTasks();
|
||||
loadStats();
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast.error((e as Record<string, any>).message || '创建失败');
|
||||
} finally {
|
||||
setSaving(false);
|
||||
@@ -224,7 +224,7 @@ export function SiteMonitor() {
|
||||
toast.success('任务已删除');
|
||||
loadTasks();
|
||||
loadStats();
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast.error((e as Record<string, any>).message || '删除失败');
|
||||
}
|
||||
};
|
||||
@@ -235,7 +235,7 @@ export function SiteMonitor() {
|
||||
toast.success(task.enabled ? '已停用' : '已启用');
|
||||
loadTasks();
|
||||
loadStats();
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
toast.error((e as Record<string, any>).message || '操作失败');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -13,7 +13,7 @@ export const TIME_RANGES = [
|
||||
export type AggType = 'avg' | 'max' | 'min';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export type HostRecord = Record<string, any>;
|
||||
export type HostRecord = Record<string, unknown>;
|
||||
|
||||
export interface BucketPoint {
|
||||
time: string;
|
||||
|
||||
Reference in new issue
Block a user