feat(audit): F1+F2 告警静默规则标记完成 + 审计日志CSV导出实现

F1 告警静默规则 [done]:
- 后端 alert_silence.go: CRUD + Toggle (onetime/daily/weekly 三模式)
- 告警引擎 isSilenced 集成 (alert_engine.go)
- 前端 SilenceRuleTab + SilenceDialog
- 路由 /alerts/silences 已注册

F2 审计日志导出 [done]:
- 重写 ExportAuditLogs: 真正的 CSV 导出 (encoding/csv + UTF-8 BOM)
- 支持 module/action/username/startTime/endTime 筛选
- 导出限制 10000 条防溢出,自动记录审计日志
- JSON 格式向后兼容 (format=json)
- 前端 exportLogs 传递查询参数

同时包含累积的前期工作:
- 目录重构 internal/ -> controller/model/router (v0.55-v0.57)
- 后端分层架构 dto/repository/service/utils
- 审计模块全功能 (终端审计/操作审计/登录日志)
- asciicast v2 录制格式
- SFTP 文件浏览器
- StatStrip 紧凑统计条
- 在线会话自动刷新
- LiveMonitor WebSocket 诊断修复

验证: go build ✅ | npm run build ✅ | Docker 部署 ✅ | 10 回归端点 ✅ | CSV 导出 ✅ | 静默 CRUD ✅
This commit is contained in:
attacker committed 2026-06-25 20:16:30 +08:00
1 parent e57718998a
commit 77c234b060
314 files changed
+10050 -4065

No files matched your search

+55
View File
@@ -0,0 +1,55 @@
// 紧凑型统计条 — 替代 4~5 个大卡片的笨重布局
// 一行显示所有统计项,带颜色区分
import { cn } from '@/lib/utils';
interface StatItem {
label: string;
value: number | string;
color?: string; // tailwind text class or hex
icon?: React.ReactNode;
}
interface StatStripProps {
items: StatItem[];
className?: string;
}
const colorMap: Record<string, { text: string; bg: string }> = {
blue: { text: 'text-blue-400', bg: 'bg-blue-500/20' },
emerald: { text: 'text-emerald-400', bg: 'bg-emerald-500/20' },
amber: { text: 'text-amber-400', bg: 'bg-amber-500/20' },
red: { text: 'text-red-400', bg: 'bg-red-500/20' },
purple: { text: 'text-purple-400', bg: 'bg-purple-500/20' },
cyan: { text: 'text-cyan-400', bg: 'bg-cyan-500/20' },
muted: { text: 'text-[var(--dg-text-secondary)]', bg: 'bg-[var(--dg-bg-tertiary)]' },
};
export function StatStrip({ items, className }: StatStripProps) {
return (
<div className={cn(
'flex items-center gap-1.5 px-3 py-2 rounded-lg',
'bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)]',
'overflow-x-auto',
className,
)}>
{items.map((item, i) => {
const clr = colorMap[item.color || 'muted'] || colorMap.muted;
return (
<div key={i} className="flex items-center gap-1.5 shrink-0">
{i > 0 && (
<span className="w-px h-5 bg-[var(--dg-border)] mx-1 shrink-0" />
)}
<span className={cn(
'w-1.5 h-1.5 rounded-full shrink-0',
clr.bg.replace('/20', '').replace('bg-', 'bg-') || 'bg-slate-500',
)}
style={{ backgroundColor: item.color?.startsWith('#') ? item.color : undefined }}
/>
<span className="text-xs text-[var(--dg-text-muted)]">{item.label}</span>
<span className={cn('text-sm font-semibold', clr.text)}>{item.value}</span>
</div>
);
})}
</div>
);
}