feat: 安全加固检查与评分(加权安全评分+加固建议+详情页评分展示)

This commit is contained in:
gouki
2026-08-02 22:26:10 +00:00
parent f3e700f3f4
commit dd2638601a
3 changed files with 103 additions and 5 deletions
+15 -5
View File
@@ -155,13 +155,14 @@ async function deleteProvider(p) {
async function viewServer(a) {
store.view = 'servers';
try {
const [metrics, info, checks] = await Promise.all([
const [metrics, info, checks, security] = await Promise.all([
Api.get('/monitor/' + a.id + '/metrics?limit=200'),
Api.get('/monitor/' + a.id + '/info'),
Api.get('/monitor/' + a.id + '/security'),
Api.get('/monitor/' + a.id + '/security-score'),
]);
store.serverMetrics = { asset: a, metrics, info, checks };
} catch (e) { store.serverMetrics = { asset: a, metrics: [], info: null, checks: [] }; }
store.serverMetrics = { asset: a, metrics, info, checks, security };
} catch (e) { store.serverMetrics = { asset: a, metrics: [], info: null, checks: [], security: null }; }
}
/* ---------------- 设置 ---------------- */
@@ -533,7 +534,13 @@ const ServersView = {
<canvas id="metricsChart" height="90"></canvas>
</div>
<div class="bg-white dark:bg-slate-900 rounded-xl border border-slate-200 dark:border-slate-800 p-4">
<h3 class="font-semibold mb-2 text-sm">安全检查</h3>
<div class="flex justify-between items-center mb-2">
<h3 class="font-semibold text-sm">安全检查</h3>
<div v-if="m.security && m.security.score !== null && m.security.score !== undefined" class="flex items-center gap-2">
<span class="text-xs text-slate-500">安全评分</span>
<span class="text-lg font-bold" :class="scoreClass(m.security.level)">{{ m.security.score }}</span>
</div>
</div>
<div class="space-y-2">
<div v-for="c in m.checks" :key="c.id" class="flex items-start gap-2 text-sm">
<span class="text-xs px-2 py-0.5 rounded-full shrink-0" :class="Fmt.checkBadge(c.status)">{{ c.status }}</span>
@@ -579,7 +586,10 @@ const ServersView = {
}
watch(m, () => { nextTick(renderChart); }, { deep: true });
onMounted(() => { nextTick(renderChart); });
return { store, Fmt, m, latest };
function scoreClass(level) {
return { good: 'text-emerald-600 dark:text-emerald-400', warning: 'text-amber-600 dark:text-amber-400', risk: 'text-red-600 dark:text-red-400', unknown: 'text-slate-400' }[level] || 'text-slate-400';
}
return { store, Fmt, m, latest, scoreClass };
},
};