Add files via upload

This commit is contained in:
公明
2026-02-08 20:38:50 +08:00
committed by GitHub
parent fd5d1dff10
commit 594b7676e1
4 changed files with 494 additions and 4 deletions
+318 -2
View File
@@ -488,8 +488,15 @@ header {
font-size: 1.5rem;
font-weight: 600;
letter-spacing: -0.5px;
margin: 0;
color: var(--text-primary);
}
.header-logo-link {
cursor: pointer;
transition: opacity 0.2s ease;
}
.header-logo-link:hover {
opacity: 0.85;
}
.header-right {
@@ -7920,6 +7927,315 @@ header {
color: var(--text-primary);
}
/* 仪表盘页面样式 */
.dashboard-page {
height: 100%;
display: flex;
flex-direction: column;
overflow: auto;
background: linear-gradient(180deg, #f0f4ff 0%, #f8fafc 24%, var(--bg-secondary) 100%);
}
.dashboard-page .page-header {
flex-shrink: 0;
}
.dashboard-content {
flex: 1;
padding: 20px 24px 32px;
overflow: auto;
}
.dashboard-cards {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 20px;
margin-bottom: 28px;
}
@media (max-width: 900px) {
.dashboard-cards { grid-template-columns: 1fr; }
}
.dashboard-card {
position: relative;
background: var(--bg-primary);
border-radius: 16px;
padding: 24px;
display: flex;
align-items: center;
gap: 20px;
cursor: pointer;
transition: transform 0.25s ease, box-shadow 0.25s ease;
box-shadow: 0 4px 14px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
border: 1px solid rgba(0,0,0,0.06);
overflow: hidden;
}
.dashboard-card:hover {
transform: translateY(-4px);
box-shadow: 0 12px 28px rgba(0,0,0,0.1), 0 4px 12px rgba(0,0,0,0.06);
}
.dashboard-card-glow {
position: absolute;
top: -40%;
right: -20%;
width: 60%;
height: 100%;
border-radius: 50%;
opacity: 0.08;
pointer-events: none;
}
.dashboard-card-tasks .dashboard-card-glow { background: radial-gradient(circle, #0066ff 0%, transparent 70%); }
.dashboard-card-vulns .dashboard-card-glow { background: radial-gradient(circle, #dc3545 0%, transparent 70%); }
.dashboard-card-chat .dashboard-card-glow { background: radial-gradient(circle, #0d9488 0%, transparent 70%); }
.dashboard-card-icon {
width: 56px;
height: 56px;
border-radius: 14px;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
transition: transform 0.25s ease;
}
.dashboard-card:hover .dashboard-card-icon {
transform: scale(1.08);
}
.dashboard-card-tasks .dashboard-card-icon {
background: linear-gradient(145deg, #e0edff 0%, #cce0ff 100%);
color: #0066ff;
}
.dashboard-card-vulns .dashboard-card-icon {
background: linear-gradient(145deg, #ffebee 0%, #ffcdd2 100%);
color: #c62828;
}
.dashboard-card-chat .dashboard-card-icon {
background: linear-gradient(145deg, #e0f2f1 0%, #b2dfdb 100%);
color: #0d9488;
}
.dashboard-card-body {
min-width: 0;
}
.dashboard-card-value {
font-size: 2rem;
font-weight: 800;
color: var(--text-primary);
line-height: 1.1;
letter-spacing: -0.03em;
}
.dashboard-card-label {
font-size: 0.9rem;
color: var(--text-secondary);
margin-top: 4px;
font-weight: 500;
}
.dashboard-card-desc {
font-size: 0.8rem;
color: var(--text-muted);
margin-top: 2px;
}
.dashboard-card-cta {
font-size: 1.15rem;
font-weight: 700;
color: var(--text-primary);
}
.dashboard-card-hint {
font-size: 0.75rem;
color: var(--text-muted);
margin-top: 6px;
opacity: 0.9;
}
.dashboard-section {
margin-bottom: 28px;
}
.dashboard-section-chart {
background: var(--bg-primary);
border-radius: 16px;
padding: 22px 24px;
box-shadow: 0 2px 12px rgba(0,0,0,0.04);
border: 1px solid rgba(0,0,0,0.05);
}
.dashboard-section-title {
display: flex;
align-items: center;
gap: 10px;
font-size: 1rem;
font-weight: 600;
color: var(--text-primary);
margin: 0 0 16px 0;
}
.dashboard-section-dot {
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--accent-color);
flex-shrink: 0;
}
.dashboard-chart-wrap {
display: flex;
flex-direction: column;
gap: 16px;
}
.dashboard-stacked-bar {
display: flex;
width: 100%;
height: 28px;
border-radius: 14px;
overflow: hidden;
background: var(--bg-tertiary);
box-shadow: inset 0 1px 2px rgba(0,0,0,0.06);
}
.dashboard-bar-seg {
height: 100%;
min-width: 2px;
transition: width 0.4s ease;
}
.dashboard-bar-seg.seg-critical { background: linear-gradient(90deg, #b91c1c, #dc2626); }
.dashboard-bar-seg.seg-high { background: linear-gradient(90deg, #ea580c, #f97316); }
.dashboard-bar-seg.seg-medium { background: linear-gradient(90deg, #ca8a04, #eab308); }
.dashboard-bar-seg.seg-low { background: linear-gradient(90deg, #059669, #10b981); }
.dashboard-bar-seg.seg-info { background: linear-gradient(90deg, #4b5563, #6b7280); }
.dashboard-legend {
display: flex;
flex-wrap: wrap;
gap: 20px 28px;
}
.dashboard-legend-item {
display: inline-flex;
align-items: center;
gap: 8px;
font-size: 0.875rem;
}
.dashboard-legend-dot {
width: 10px;
height: 10px;
border-radius: 50%;
flex-shrink: 0;
}
.dashboard-legend-dot.critical { background: #dc2626; }
.dashboard-legend-dot.high { background: #f97316; }
.dashboard-legend-dot.medium { background: #eab308; }
.dashboard-legend-dot.low { background: #10b981; }
.dashboard-legend-dot.info { background: #6b7280; }
.dashboard-legend-label {
color: var(--text-secondary);
}
.dashboard-legend-value {
font-weight: 700;
color: var(--text-primary);
min-width: 1.5em;
}
.dashboard-quick-links {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
.dashboard-quick-link {
display: inline-flex;
align-items: center;
gap: 10px;
padding: 12px 20px;
background: var(--bg-primary);
border: 1px solid var(--border-color);
border-radius: 12px;
color: var(--text-primary);
font-size: 0.9rem;
font-weight: 500;
text-decoration: none;
cursor: pointer;
transition: all 0.2s ease;
box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.dashboard-quick-link:hover {
border-color: var(--accent-color);
background: rgba(0, 102, 255, 0.06);
color: var(--accent-color);
box-shadow: 0 4px 12px rgba(0, 102, 255, 0.12);
}
.dashboard-quick-icon {
display: flex;
align-items: center;
justify-content: center;
color: var(--text-secondary);
}
.dashboard-quick-link:hover .dashboard-quick-icon {
color: var(--accent-color);
}
.dashboard-cta-block {
margin-top: 8px;
padding: 24px;
background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
border: 1px solid rgba(14, 165, 233, 0.2);
border-radius: 16px;
}
.dashboard-cta-inner {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: 16px;
}
.dashboard-cta-text {
font-size: 1rem;
font-weight: 600;
color: var(--text-primary);
margin: 0;
}
.dashboard-cta-btn {
padding: 12px 24px;
background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
border: none;
border-radius: 12px;
color: #fff;
font-size: 0.95rem;
font-weight: 600;
cursor: pointer;
transition: transform 0.15s, box-shadow 0.2s;
box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35);
}
.dashboard-cta-btn:hover {
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(2, 132, 199, 0.4);
}
.vulnerability-controls {
margin-bottom: 24px;
}
+58
View File
@@ -0,0 +1,58 @@
// 仪表盘页面:拉取运行中任务、漏洞统计并渲染
async function refreshDashboard() {
const runningEl = document.getElementById('dashboard-running-tasks');
const vulnTotalEl = document.getElementById('dashboard-vuln-total');
const severityIds = ['critical', 'high', 'medium', 'low', 'info'];
if (runningEl) runningEl.textContent = '…';
if (vulnTotalEl) vulnTotalEl.textContent = '…';
severityIds.forEach(s => {
const el = document.getElementById('dashboard-severity-' + s);
if (el) el.textContent = '0';
const barEl = document.getElementById('dashboard-bar-' + s);
if (barEl) barEl.style.width = '0%';
});
if (typeof apiFetch === 'undefined') {
if (runningEl) runningEl.textContent = '-';
if (vulnTotalEl) vulnTotalEl.textContent = '-';
return;
}
try {
const [tasksRes, vulnRes] = await Promise.all([
apiFetch('/api/agent-loop/tasks').then(r => r.ok ? r.json() : null).catch(() => null),
apiFetch('/api/vulnerabilities/stats').then(r => r.ok ? r.json() : null).catch(() => null)
]);
if (tasksRes && Array.isArray(tasksRes.tasks)) {
if (runningEl) runningEl.textContent = String(tasksRes.tasks.length);
} else {
if (runningEl) runningEl.textContent = '-';
}
if (vulnRes && typeof vulnRes.total === 'number') {
if (vulnTotalEl) vulnTotalEl.textContent = String(vulnRes.total);
const bySeverity = vulnRes.by_severity || {};
const total = vulnRes.total || 0;
severityIds.forEach(sev => {
const count = bySeverity[sev] || 0;
const el = document.getElementById('dashboard-severity-' + sev);
if (el) el.textContent = String(count);
const barEl = document.getElementById('dashboard-bar-' + sev);
if (barEl) barEl.style.width = total > 0 ? (count / total * 100) + '%' : '0%';
});
} else {
if (vulnTotalEl) vulnTotalEl.textContent = '-';
severityIds.forEach(sev => {
const barEl = document.getElementById('dashboard-bar-' + sev);
if (barEl) barEl.style.width = '0%';
});
}
} catch (e) {
console.warn('仪表盘拉取统计失败', e);
if (runningEl) runningEl.textContent = '-';
if (vulnTotalEl) vulnTotalEl.textContent = '-';
}
}
+6 -1
View File
@@ -8,7 +8,7 @@ function initRouter() {
if (hash) {
const hashParts = hash.split('?');
const pageId = hashParts[0];
if (pageId && ['chat', 'vulnerabilities', 'mcp-monitor', 'mcp-management', 'knowledge-management', 'knowledge-retrieval-logs', 'roles-management', 'skills-monitor', 'skills-management', 'settings', 'tasks'].includes(pageId)) {
if (pageId && ['dashboard', 'chat', 'vulnerabilities', 'mcp-monitor', 'mcp-management', 'knowledge-management', 'knowledge-retrieval-logs', 'roles-management', 'skills-monitor', 'skills-management', 'settings', 'tasks'].includes(pageId)) {
switchPage(pageId);
// 如果是chat页面且带有conversation参数,加载对应对话
@@ -237,6 +237,11 @@ function showSubmenuPopup(navItem, menuId) {
// 初始化页面
function initPage(pageId) {
switch(pageId) {
case 'dashboard':
if (typeof refreshDashboard === 'function') {
refreshDashboard();
}
break;
case 'chat':
// 对话页面已由chat.js初始化
break;
+112 -1
View File
@@ -29,7 +29,7 @@
<div class="container">
<header>
<div class="header-content">
<div class="logo">
<div class="logo header-logo-link" onclick="switchPage('dashboard')" role="button" title="返回仪表盘">
<img src="/static/logo.png" alt="CyberStrikeAI Logo" style="width: 32px; height: 32px; margin-right: 8px;">
<h1>CyberStrikeAI</h1>
</div>
@@ -71,6 +71,17 @@
</svg>
</div>
<nav class="main-sidebar-nav">
<div class="nav-item" data-page="dashboard">
<div class="nav-item-content" data-title="仪表盘" onclick="switchPage('dashboard')">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<rect x="3" y="3" width="7" height="9"></rect>
<rect x="14" y="3" width="7" height="5"></rect>
<rect x="14" y="12" width="7" height="9"></rect>
<rect x="3" y="16" width="7" height="5"></rect>
</svg>
<span>仪表盘</span>
</div>
</div>
<div class="nav-item" data-page="chat">
<div class="nav-item-content" data-title="对话" onclick="switchPage('chat')">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
@@ -192,6 +203,105 @@
<!-- 内容区域 -->
<div class="content-area">
<!-- 仪表盘页面 -->
<div id="page-dashboard" class="page">
<div class="dashboard-page">
<div class="page-header">
<h2>仪表盘</h2>
<div class="page-header-actions">
<button class="btn-secondary" onclick="refreshDashboard()" title="刷新数据">刷新</button>
</div>
</div>
<div class="dashboard-content">
<div class="dashboard-cards" id="dashboard-cards">
<div class="dashboard-card dashboard-card-tasks" onclick="switchPage('tasks')">
<div class="dashboard-card-glow"></div>
<div class="dashboard-card-icon">
<svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 11l3 3L22 4"></path><path d="M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"></path></svg>
</div>
<div class="dashboard-card-body">
<div class="dashboard-card-value" id="dashboard-running-tasks">-</div>
<div class="dashboard-card-label">运行中任务</div>
<div class="dashboard-card-hint">点击查看任务管理</div>
</div>
</div>
<div class="dashboard-card dashboard-card-vulns" onclick="switchPage('vulnerabilities')">
<div class="dashboard-card-glow"></div>
<div class="dashboard-card-icon">
<svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"></path></svg>
</div>
<div class="dashboard-card-body">
<div class="dashboard-card-value" id="dashboard-vuln-total">-</div>
<div class="dashboard-card-label">漏洞总数</div>
<div class="dashboard-card-hint">点击查看漏洞管理</div>
</div>
</div>
<div class="dashboard-card dashboard-card-chat" onclick="switchPage('chat')">
<div class="dashboard-card-glow"></div>
<div class="dashboard-card-icon">
<svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path></svg>
</div>
<div class="dashboard-card-body">
<div class="dashboard-card-cta">开始对话</div>
<div class="dashboard-card-desc">与 AI 进行安全测试</div>
<div class="dashboard-card-hint">立即开始</div>
</div>
</div>
</div>
<div class="dashboard-section dashboard-section-chart">
<h3 class="dashboard-section-title"><span class="dashboard-section-dot"></span>漏洞严重程度分布</h3>
<div class="dashboard-chart-wrap">
<div class="dashboard-stacked-bar" id="dashboard-stacked-bar">
<span class="dashboard-bar-seg seg-critical" id="dashboard-bar-critical" style="width: 0%"></span>
<span class="dashboard-bar-seg seg-high" id="dashboard-bar-high" style="width: 0%"></span>
<span class="dashboard-bar-seg seg-medium" id="dashboard-bar-medium" style="width: 0%"></span>
<span class="dashboard-bar-seg seg-low" id="dashboard-bar-low" style="width: 0%"></span>
<span class="dashboard-bar-seg seg-info" id="dashboard-bar-info" style="width: 0%"></span>
</div>
<div class="dashboard-legend" id="dashboard-vuln-bars">
<div class="dashboard-legend-item"><span class="dashboard-legend-dot critical"></span><span class="dashboard-legend-label">严重</span><span class="dashboard-legend-value" id="dashboard-severity-critical">0</span></div>
<div class="dashboard-legend-item"><span class="dashboard-legend-dot high"></span><span class="dashboard-legend-label">高危</span><span class="dashboard-legend-value" id="dashboard-severity-high">0</span></div>
<div class="dashboard-legend-item"><span class="dashboard-legend-dot medium"></span><span class="dashboard-legend-label">中危</span><span class="dashboard-legend-value" id="dashboard-severity-medium">0</span></div>
<div class="dashboard-legend-item"><span class="dashboard-legend-dot low"></span><span class="dashboard-legend-label">低危</span><span class="dashboard-legend-value" id="dashboard-severity-low">0</span></div>
<div class="dashboard-legend-item"><span class="dashboard-legend-dot info"></span><span class="dashboard-legend-label">信息</span><span class="dashboard-legend-value" id="dashboard-severity-info">0</span></div>
</div>
</div>
</div>
<div class="dashboard-section">
<h3 class="dashboard-section-title"><span class="dashboard-section-dot"></span>快捷入口</h3>
<div class="dashboard-quick-links">
<a class="dashboard-quick-link" onclick="switchPage('tasks')">
<span class="dashboard-quick-icon"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 11l3 3L22 4"></path><path d="M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"></path></svg></span>
<span>任务管理</span>
</a>
<a class="dashboard-quick-link" onclick="switchPage('vulnerabilities')">
<span class="dashboard-quick-icon"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"></path></svg></span>
<span>漏洞管理</span>
</a>
<a class="dashboard-quick-link" onclick="switchPage('chat')">
<span class="dashboard-quick-icon"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path></svg></span>
<span>对话</span>
</a>
<a class="dashboard-quick-link" onclick="switchPage('mcp-monitor')">
<span class="dashboard-quick-icon"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M13 2L3 14h9l-1 8 10-12h-9l1-8z"></path></svg></span>
<span>MCP 监控</span>
</a>
<a class="dashboard-quick-link" onclick="switchPage('skills-monitor')">
<span class="dashboard-quick-icon"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"></path><polyline points="14 2 14 8 20 8"></polyline></svg></span>
<span>Skills 监控</span>
</a>
</div>
</div>
<div class="dashboard-cta-block">
<div class="dashboard-cta-inner">
<p class="dashboard-cta-text">准备好开始安全测试?</p>
<button class="dashboard-cta-btn" onclick="switchPage('chat')">前往对话 →</button>
</div>
</div>
</div>
</div>
</div>
<!-- 对话页面 -->
<div id="page-chat" class="page active">
<div class="chat-page-layout">
@@ -1701,6 +1811,7 @@ version: 1.0.0<br>
<script src="/static/js/builtin-tools.js"></script>
<script src="/static/js/auth.js"></script>
<script src="/static/js/router.js"></script>
<script src="/static/js/dashboard.js"></script>
<script src="/static/js/monitor.js"></script>
<script src="/static/js/chat.js"></script>
<script src="/static/js/settings.js"></script>