From 7a63b2b0c69a7f337368ed4572ede8d55e907691 Mon Sep 17 00:00:00 2001 From: admin Date: Wed, 11 Nov 2026 09:58:18 +0800 Subject: [PATCH] =?UTF-8?q?feat(portal):=20=E9=97=A8=E6=88=B7=E6=94=B9?= =?UTF-8?q?=E9=80=A0=E6=88=90=E5=B7=A5=E4=BD=9C=E5=8F=B0=E5=B9=B6=E7=BB=9F?= =?UTF-8?q?=E4=B8=80=E5=85=A8=E5=B1=80=E8=A7=86=E8=A7=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Dashboard: 从平铺按钮列表改为「左侧动态导航 + 右侧概览面板」工作台 · 菜单仍全动态来自 currentUser().menuList,前端不硬编码任何菜单项 · 侧栏按目录分组,带图标块/选中态/实时计数徽标 · 概览面板全部取自真实接口:Engine/Info、Flow/FlowRun/List、 Device/List、ChainBlock/List;任一接口失败只显示 —,不伪造计数 · 新增最近运行实例表格、TEE 节点与链上存证真源速览 - ui.ts: 补齐门户设计令牌(顶栏/侧栏/统计卡/面板/徽标/键值行) - portal.css: hover 等伪类样式(内联 style 表达不了的部分) - Login: 改为左品牌介绍 + 右登录卡,与门户同一视觉语言 - CrudPage: 头部加「← 门户」入口与面包屑路径,表格横向滚动不再裁切 - .env.example: 补齐真源配置项(control-plane/FISCO/两方会话) --- .env.example | 41 ++ src/frontend/src/components/CrudPage.tsx | 92 ++-- src/frontend/src/views/Dashboard.tsx | 547 ++++++++++++++++++++++- src/frontend/src/views/Login.tsx | 180 ++++++-- src/frontend/src/views/portal.css | 22 + src/frontend/src/views/ui.ts | 254 +++++++++++ 6 files changed, 1049 insertions(+), 87 deletions(-) create mode 100644 src/frontend/src/views/portal.css diff --git a/.env.example b/.env.example index 79f5109..53dbce5 100644 --- a/.env.example +++ b/.env.example @@ -4,3 +4,44 @@ PGLLITE_DIR=memory:// # 迁 JNPF 前关掉自动建表:PG_SYNC=false PG_SYNC=true PORT=30000 + +# --------------------------------------------------------------------------- +# ★ 真源配置(不配 = 退化成 mock,界面会显示「模拟数据」) +# 两个兄弟模块走 ssw-mpc 真实接口:设备注册读 control-plane,链上存证读 outbox + FISCO 链 +# --------------------------------------------------------------------------- + +# 设备注册真源:ssw-mpc control-plane 的 /nodes(当前在线清单,TTL 90s) +MPC_CONTROL_PLANE_URL=http://192.168.1.102:3020 +# 控制面共享密钥:必须是**原文**(不是 hex)。默认从 /cluster.secret 读; +# 也可在这里给文件路径:MPC_HOSTD_SHARED_SECRET_FILE=/path/to/cluster.secret +MPC_HOSTD_SHARED_SECRET_FILE=../ssw-mpc/.mpc-state/cluster.secret + +# 链上存证真源:FISCO 国密链 + ssw-mpc outbox +MPC_FISCO_CHAIN_CONFIG=../ssw-mpc/tools/fisco-realnode/example.chain.json +MPC_FISCO_OUTBOX=.mpc-state/chain-outbox.txt +MPC_FISCO_NODE=node0 + +# --------------------------------------------------------------------------- +# ★ 两方会话算子(prep.intersect / model.lr.train 走真密态时必需) +# 对端不在场时后端会自动降级 partial + 写明原因,不会硬失败 +# --------------------------------------------------------------------------- + +# 参与方(≥2 个),会话算子按此下发 --sites +MPC_SITES=alice,bob +# 共享主种子:必须是 64 位十六进制(32 字节),各方一致。 +# 不给 ⇒ 各方各自随机 ⇒ PSI 交集必空。 +MPC_SEED= +# 连接参数:--listen 与 --connect 二选一(都给反而非法) +MPC_SESSION_LISTEN= +MPC_SESSION_CONNECT= +# 训练超参:各方必须完全一致,否则报「open_batch 第 0 个值长度不一致」 +MPC_SESSION_EPOCHS=20 +MPC_SESSION_LR=0.1 +# 声明各方 agent 进程在场(1=在场) +MPC_AGENT_PRESENT= + +# --------------------------------------------------------------------------- +# 执行驱动:默认 simulation(纯本地);真实执行需 MPC_DRIVER=mpc + MPC_REAL_EXEC=1 +# --------------------------------------------------------------------------- +MPC_DRIVER=simulation +MPC_REAL_EXEC=0 diff --git a/src/frontend/src/components/CrudPage.tsx b/src/frontend/src/components/CrudPage.tsx index 516e330..588a5cf 100644 --- a/src/frontend/src/components/CrudPage.tsx +++ b/src/frontend/src/components/CrudPage.tsx @@ -1,4 +1,5 @@ import { useEffect, useState } from 'react'; +import { useNavigate } from 'react-router-dom'; import { wrap, card, btn, btnDanger, btnGhost, input, tableStyle, th, td } from '../views/ui'; export interface Field { key: string; label: string } @@ -38,6 +39,7 @@ export default function CrudPage({ title, entity, columns, fields, api, readonly, filterKey, apiBase, sync, syncLabel, syncExtra, renderCell, banner, }: CrudPageProps) { + const nav = useNavigate(); const [rows, setRows] = useState([]); const [editing, setEditing] = useState(null); const [filter, setFilter] = useState(''); @@ -83,19 +85,29 @@ export default function CrudPage({ return (
-
-

{title}

- /api/ssw/{apiBase || 'sswflow'}/{entity} - - - {sync && ( - - )} - {!readonly && ( - - )} +
+ +

{title}

+ + /api/ssw/{apiBase || 'sswflow'}/{entity} + +
+ + {sync && ( + + )} + {!readonly && ( + + )} +
{banner &&
{banner}
} @@ -143,34 +155,38 @@ export default function CrudPage({
)} - - - - {columns.map((c) => )} - {!readonly && } - - - - {shown.map((r) => ( - +
+
{c.label}操作
+ + {columns.map((c) => ( - + ))} - {!readonly && ( - - )} + {!readonly && } - ))} - {shown.length === 0 && ( - - )} - -
- {renderCell ? renderCell(r, c.key) : format(r[c.key])} - {c.label} - - - 操作
暂无数据
+ + + {shown.map((r) => ( + + {columns.map((c) => ( + + {renderCell ? renderCell(r, c.key) : format(r[c.key])} + + ))} + {!readonly && ( + + + + + )} + + ))} + {shown.length === 0 && ( + 暂无数据 + )} + + +
); diff --git a/src/frontend/src/views/Dashboard.tsx b/src/frontend/src/views/Dashboard.tsx index 1a4974b..1791d3d 100644 --- a/src/frontend/src/views/Dashboard.tsx +++ b/src/frontend/src/views/Dashboard.tsx @@ -1,8 +1,32 @@ -import { useEffect, useState } from 'react'; +import { useEffect, useMemo, useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { currentUser } from '../api/auth'; import { clearToken } from '../api/request'; -import { wrap, card, btnGhost, btn } from './ui'; +import { listFlows, engineInfo } from '../api/flow'; +import { listFlowRuns } from '../api/flowrun'; +import { listDevices } from '../api/device'; +import { listChainBlocks } from '../api/chainblock'; +import { + portal, topbar, brandMark, portalBody, sidebar, mainArea, + navGroupTitle, navItem, navItemActive, navIcon, navBadge, + pageTitle, pageSub, statGrid, statCard, statValue, statLabel, + panel, panelTitle, panelSub, chip, dot, kvRow, kvKey, kvVal, + tableStyle, th, td, +} from './ui'; +import './portal.css'; + +/** + * 门户(工作台)—— + * + * ★ 菜单**仍然全动态**:分组与条目全部来自 `currentUser().menuList`, + * 不在前端硬编码任何菜单项(加菜单只需改 seed + Route + controller 三处)。 + * 这里只负责「怎么摆得好看、并且把运行态信息摆出来」。 + * + * ★ 概览面板的数据全部来自真实接口,不造假数: + * 引擎/算子能力 ← Engine/Info;流程/运行 ← Flow/List、FlowRun/List; + * TEE 节点 ← sswdevice/Device/List;链上存证 ← sswchain/ChainBlock/List。 + * 任一接口失败只显示「—」,不伪造计数。 + */ interface MenuNode { id: string; @@ -13,10 +37,45 @@ interface MenuNode { children: MenuNode[]; } +interface EngineInfo { + driver?: string; + engines?: string[]; + mpc?: { + bin?: string; + binSource?: string; + binSourceLabel?: string; + releaseTag?: string; + sites?: string[]; + available?: boolean; + detail?: string; + }; + capabilities?: { key: string; crate: string; status: string; note?: string }[]; +} + +/** 最近运行实例(门户只取最近若干条做速览,完整列表在「运行监控」页)。 */ +interface RunRow { + id: string; + flowName?: string; + status?: string; + operator?: string; + startTime?: string; + costMs?: number; +} + export default function Dashboard() { const nav = useNavigate(); const [menu, setMenu] = useState([]); const [user, setUser] = useState(null); + const [engine, setEngine] = useState(null); + const [stats, setStats] = useState<{ + flows?: number; runs?: number; running?: number; success?: number; failed?: number; + devices?: number; online?: number; receipts?: number; + }>({}); + const [recentRuns, setRecentRuns] = useState([]); + const [nodes, setNodes] = useState([]); + const [receipts, setReceipts] = useState([]); + const [active, setActive] = useState(''); + const [loadErr, setLoadErr] = useState(''); useEffect(() => { currentUser() @@ -27,6 +86,79 @@ export default function Dashboard() { .catch(() => {}); }, []); + // 概览数据:各自独立失败,互不拖累(一个挂了不影响其它面板) + useEffect(() => { + let alive = true; + const put = (fn: () => Promise) => + fn().then((v) => { + if (alive) return v; + }).catch(() => null); + + put(() => engineInfo()).then((d) => d && alive && setEngine(d)); + put(() => listFlows()).then((d) => d && alive && setStats((s) => ({ ...s, flows: (d || []).length }))); + put(() => listFlowRuns()).then((d) => { + if (!d || !alive) return; + const rows: any[] = d || []; + setStats((s) => ({ + ...s, + runs: rows.length, + running: rows.filter((r) => r.status === 'RUNNING').length, + success: rows.filter((r) => r.status === 'SUCCESS').length, + failed: rows.filter((r) => r.status === 'FAILED').length, + })); + // 速览最近 6 条(按开始时间倒序;后端默认按创建序返回,这里再排一次保险) + setRecentRuns( + [...rows] + .sort((a, b) => String(b.startTime || '').localeCompare(String(a.startTime || ''))) + .slice(0, 6), + ); + }); + put(() => listDevices()).then((d) => { + if (!d || !alive) return; + const rows: any[] = d || []; + setStats((s) => ({ + ...s, + devices: rows.length, + online: rows.filter((r) => r.online === 1).length, + })); + setNodes(rows); + }); + put(() => listChainBlocks()).then((d) => { + if (!d || !alive) return; + const rows: any[] = d || []; + setStats((s) => ({ ...s, receipts: rows.length })); + setReceipts(rows); + }); + + return () => { + alive = false; + }; + }, []); + + /** 侧栏分组:顶级节点为目录(type 1);顶级就是页面的(type 2)归入「直接访问」。 */ + const groups = useMemo(() => { + const dirs = menu.filter((m) => m.children && m.children.length > 0); + const loose = menu.filter((m) => !m.children || m.children.length === 0); + return { dirs, loose }; + }, [menu]); + + /** 目录条目 → 展示名 + 计数(统计口径与概览面板一致)。 */ + function countOf(url?: string): number | undefined { + if (!url) return undefined; + if (url === 'sswflow/Flow') return stats.flows; + if (url === 'sswflow/FlowRun') return stats.runs; + if (url === 'sswdevice/Device') return stats.devices; + if (url === 'sswchain/ChainBlock') return stats.receipts; + return undefined; + } + + /** 两字缩写做图标占位(菜单里没有真实图标资源,用首字生成稳定的彩色块)。 */ + function initials(name: string): string { + const s = (name || '').trim(); + if (!s) return '·'; + return /[一-龥]/.test(s) ? s.slice(0, 1) : s.slice(0, 2).toUpperCase(); + } + function goto(addr?: string) { if (addr) nav('/' + addr); } @@ -35,30 +167,405 @@ export default function Dashboard() { location.reload(); } + const caps = engine?.capabilities || []; + const capStat = caps.reduce((acc: Record, c) => { + acc[c.status] = (acc[c.status] || 0) + 1; + return acc; + }, {}); + const nativeCount = capStat.native || 0; + const totalCaps = caps.length; + return ( -
-
-

SSW MPC Flow · 隐私计算编排

-
- {user?.userAccount} {user?.isAdministrator ? '(管理员)' : ''} +
+ {/* ---------- 顶栏 ---------- */} +
+
SS
+
+
SSW MPC Flow
+
隐私计算编排平台
-

功能菜单

- {menu.map((node) => ( -
-
{node.fullName}
-
- {node.children.map((c) => ( - +
+
+ + 引擎 {engine?.driver || '—'} +
+
+ {user?.userAccount || '—'}{user?.isAdministrator ? ' · 管理员' : ''} +
+ +
+
+ +
+ {/* ---------- 左侧导航 ---------- */} + + + {/* ---------- 右侧概览 ---------- */} +
+

工作台

+

+ 隐私计算编排、设备注册与链上存证的统一入口。左侧菜单按账号权限动态生成, + 右侧概览直接取自真实接口。 +

+ + {/* 统计卡片 */} +
+ + + + +
- ))} - + + {/* 引擎与算子能力 */} +
+

+ 执行引擎 + ssw-mpc 运行态与算子能力分布 +

+
+
+ 当前驱动 + + {engine?.driver || '—'} + {engine?.engines?.length ? ( + 可用:{engine.engines.join(' / ')} + ) : null} + +
+
+ mpc 二进制 + + {engine?.mpc?.available ? ( + + ) : ( + + )} + {engine?.mpc?.bin || '—'} + {engine?.mpc?.releaseTag ? ( + {engine.mpc.releaseTag} + ) : null} + +
+
+ 来源 / 参与方 + + {engine?.mpc?.binSourceLabel || engine?.mpc?.binSource || '—'} + {engine?.mpc?.sites?.length ? ( + 站点 {engine.mpc.sites.join(' / ')} + ) : null} + +
+
+ 探测结果 + {engine?.mpc?.detail || '—'} +
+
+ + {totalCaps > 0 && ( +
+
+ 算子能力 + + + 原生 {nativeCount} / {totalCaps} + +
+
+ {Object.entries(capStat).map(([k, v]) => ( + + + {statusLabel(k)} {v} + + ))} +
+
+ )} +
+ + {/* 运行态 */} +
+

+ 运行状态 + 最近运行实例的成功与失败分布 +

+
+ + + +
+
+ + {/* 最近运行实例 */} +
+

+ 最近运行实例 + 点「运行监控」看全部 +

+ {recentRuns.length === 0 ? ( + + ) : ( + + + + + + + + + + + + {recentRuns.map((r) => ( + + + + + + + + ))} + +
流程状态触发人开始时间耗时
{r.flowName || '—'} + + + {statusLabel(r.status || '')} + + {r.operator || '—'}{fmtTime(r.startTime)}{r.costMs != null ? `${r.costMs} ms` : '—'}
+ )} +
+ + {/* 真源双模块速览 */} +
+
+

+ TEE 节点 + control-plane 真源 +

+ {nodes.length === 0 ? ( + + ) : ( +
+ {nodes.slice(0, 5).map((n) => ( +
+ + + {n.site || '—'} + + + {n.host || '—'} + {n.platform || '—'} + {n.tcb != null ? TCB {n.tcb} : null} + {n.online === 1 ? null : 离线} + +
+ ))} +
+ )} +
+ +
+

+ 链上存证 + outbox + 国密链 +

+ {receipts.length === 0 ? ( + + ) : ( +
+ {receipts.slice(0, 5).map((r) => ( +
+ {r.orderId || '—'} + + {r.decisionId || '—'} + + {r.status === 0 ? '已出块' : r.status == null ? '待确认' : `失败(${r.status})`} + + {r.blockNumber != null ? ( + 块高 {r.blockNumber} + ) : null} + +
+ ))} +
+ )} +
+
+ + {loadErr && ( +
{loadErr}
+ )} +
); } + +/* ---------------------------------------------------------------- 小组件 */ + +function NavButton({ + name, initials, active, count, onClick, +}: { + name: string; initials: string; active: boolean; count?: number; onClick: () => void; +}) { + return ( + + ); +} + +function Stat({ + label, value, unit, accent, +}: { + label: string; value?: number; unit?: string; accent: string; +}) { + return ( +
+
{value ?? '—'}
+
+ {label} + {unit ? {unit} : null} +
+
+ ); +} + +function RunStat({ label, value, color }: { label: string; value?: number; color: string }) { + return ( +
+ + {label} + {value ?? '—'} +
+ ); +} + +/** 能力分布条:按状态分段,一眼看出原生占比。 */ +function CapabilityBar({ stat, total }: { stat: Record; total: number }) { + const order = ['native', 'local', 'partial', 'unsupported', 'sim']; + const known = order.filter((k) => stat[k]); + const rest = Object.keys(stat).filter((k) => !order.includes(k)); + const segs = [...known, ...rest]; + return ( +
`${statusLabel(k)} ${stat[k]}`).join(' · ')} + > + {segs.map((k) => ( +
+ ))} +
+ ); +} + +function statusColor(k: string): string { + switch (k) { + case 'native': return '#3fb950'; + case 'local': return '#58a6ff'; + case 'partial': return '#d29922'; + case 'sim': return '#a371f7'; + // 运行状态 + case 'SUCCESS': return '#3fb950'; + case 'RUNNING': return '#d29922'; + case 'FAILED': return '#f85149'; + case 'CANCELLED': return '#6e7681'; + default: return '#6e7681'; + } +} + +function statusLabel(k: string): string { + switch (k) { + case 'native': return '原生'; + case 'local': return '本地'; + case 'partial': return '降级'; + case 'sim': return '模拟'; + case 'unsupported': return '不支持'; + // 运行状态 + case 'SUCCESS': return '成功'; + case 'RUNNING': return '运行中'; + case 'FAILED': return '失败'; + case 'CANCELLED': return '已取消'; + case 'PENDING': return '等待中'; + default: return k || '—'; + } +} + +/** 徽标底色(按状态色淡化,作为 chip 背景)。 */ +function statusBg(k: string): string { + const c = statusColor(k); + return `${c}1f`; +} + +/** ISO 时间戳 → 本地可读时间。 */ +function fmtTime(v?: string): string { + if (!v) return '—'; + const d = new Date(v); + if (Number.isNaN(d.getTime())) return v; + return d.toLocaleString('zh-CN', { hour12: false }); +} + +/** 空态提示。 */ +function Empty({ text }: { text: string }) { + return ( +
{text}
+ ); +} diff --git a/src/frontend/src/views/Login.tsx b/src/frontend/src/views/Login.tsx index a578d85..d810503 100644 --- a/src/frontend/src/views/Login.tsx +++ b/src/frontend/src/views/Login.tsx @@ -4,16 +4,22 @@ import { login } from '../api/auth'; import { setToken } from '../api/request'; import { encryptPassword } from '../utils/cipher'; +/** + * 登录页 —— 与门户(Dashboard)同一套视觉语言: + * 左侧品牌介绍 + 右侧登录卡。默认值即 admin / 123456,直接点登录即可。 + */ export default function Login() { const [account, setAccount] = useState('admin'); const [password, setPassword] = useState('123456'); const [err, setErr] = useState(''); + const [busy, setBusy] = useState(false); const nav = useNavigate(); const loc = useLocation(); async function onSubmit(e: React.FormEvent) { e.preventDefault(); setErr(''); + setBusy(true); try { const hex = encryptPassword(password); const res = await login(account, hex); @@ -22,60 +28,176 @@ export default function Login() { nav(next); } catch (e: any) { setErr(e.message || '登录失败'); + } finally { + setBusy(false); } } return (
-
-

SSW JNPF Lite · React

- setAccount(e.target.value)} placeholder="账号" style={input} /> - setPassword(e.target.value)} - type="password" - placeholder="密码" - style={input} - /> - {err &&
{err}
} - -
默认 admin / 123456
-
+ {/* 左:品牌介绍 */} +
+
+
SS
+
+
SSW MPC Flow
+
隐私计算编排平台
+
+
+ +

+ 隐私计算编排 +
+ 设备注册与链上存证 +

+

+ 以可视化画布编排多方隐私计算流程,直接对接 ssw-mpc 的真实执行底座 —— + TEE 节点注册表取自 control-plane,存证写入国密链,全部真源可溯。 +

+ +
+ {['可视化流程画布', 'TEE 节点真源', '国密链存证', '两方密态计算'].map((t) => ( + {t} + ))} +
+
+ + {/* 右:登录卡 */} +
+
+

账号登录

+
+ 请使用平台分配的账号进入工作台 +
+ + + + + {err && ( +
+ {err} +
+ )} + + + +
+ 默认 admin / 123456 +
+
+
); } +/* ---------------------------------------------------------------- 样式 */ + const wrap: React.CSSProperties = { minHeight: '100vh', display: 'flex', - alignItems: 'center', - justifyContent: 'center', background: '#0f1419', color: '#eee', + fontFamily: 'system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif', }; -const card: React.CSSProperties = { + +const hero: React.CSSProperties = { + flex: 1, + padding: '56px 60px', display: 'flex', flexDirection: 'column', - gap: 12, - padding: 24, - background: '#1a1f26', - borderRadius: 12, - width: 300, + justifyContent: 'center', + background: + 'radial-gradient(900px 480px at 12% 18%, rgba(24,95,165,0.22), transparent 62%), #0f1419', + minWidth: 0, }; + +const rightSide: React.CSSProperties = { + flex: '0 0 46%', + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + padding: 32, + background: '#141a21', + borderLeft: '1px solid #232c36', +}; + +const card: React.CSSProperties = { + width: '100%', + maxWidth: 340, + display: 'flex', + flexDirection: 'column', + gap: 14, + padding: 28, + background: '#1a1f26', + border: '1px solid #232c36', + borderRadius: 14, +}; + +const brandMark: React.CSSProperties = { + width: 34, + height: 34, + borderRadius: 9, + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + background: 'linear-gradient(135deg, #185fa5, #2b7fd4)', + color: '#fff', + fontWeight: 700, + fontSize: 15, +}; + +const label: React.CSSProperties = { + display: 'flex', + flexDirection: 'column', + gap: 5, + fontSize: 12, + color: '#8b9aab', +}; + const input: React.CSSProperties = { - padding: 8, - borderRadius: 6, - border: '1px solid #333', + padding: '9px 11px', + borderRadius: 7, + border: '1px solid #2a3340', background: '#0f1419', color: '#eee', + fontSize: 13, + outline: 'none', }; + const btn: React.CSSProperties = { - padding: 10, - borderRadius: 6, + borderRadius: 7, border: 0, background: '#185fa5', color: '#fff', cursor: 'pointer', + fontSize: 13, + fontWeight: 600, +}; + +const chip: React.CSSProperties = { + fontSize: 11, + padding: '4px 10px', + borderRadius: 12, + background: '#1c2a38', + color: '#8fb6dd', + border: '1px solid #24425e', }; diff --git a/src/frontend/src/views/portal.css b/src/frontend/src/views/portal.css new file mode 100644 index 0000000..f7357b0 --- /dev/null +++ b/src/frontend/src/views/portal.css @@ -0,0 +1,22 @@ +/* 门户(Dashboard)专用样式 —— 只放伪类/动画这类内联 style 表达不了的部分。 + 主题令牌在 views/ui.ts,与既有页面共用。 */ + +.ssw-nav-item { + transition: background 0.14s ease, color 0.14s ease; +} +.ssw-nav-item:hover { + background: #1c242d; + color: #fff; +} +.ssw-nav-item.ssw-nav-active:hover { + background: #1b2b3d; + color: #cfe3ff; +} + +.ssw-portal-stat { + transition: border-color 0.14s ease, transform 0.14s ease; +} +.ssw-portal-stat:hover { + border-color: #33404e; + transform: translateY(-1px); +} diff --git a/src/frontend/src/views/ui.ts b/src/frontend/src/views/ui.ts index d6ff532..f38513d 100644 --- a/src/frontend/src/views/ui.ts +++ b/src/frontend/src/views/ui.ts @@ -43,4 +43,258 @@ export const th: CSSProperties = { export const td: CSSProperties = { padding: '8px', borderBottom: '1px solid #1f2630', + maxWidth: 320, + overflow: 'hidden', + textOverflow: 'ellipsis', +}; + +/* --------------------------------------------------------------------------- + * 门户(Dashboard)专用令牌 + * 主题与既有页面一致:底 #0f1419 / 卡 #1a1f26 / 主色 #185fa5 / 次要字 #9aa7b5 + * ------------------------------------------------------------------------- */ + +/** 门户整页骨架:左侧导航 + 右侧内容 */ +export const portal: CSSProperties = { + minHeight: '100vh', + background: '#0f1419', + color: '#eee', + fontFamily: 'system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif', + display: 'flex', + flexDirection: 'column', +}; + +/** 顶部品牌栏 */ +export const topbar: CSSProperties = { + height: 58, + flex: '0 0 58px', + padding: '0 20px', + display: 'flex', + alignItems: 'center', + gap: 14, + background: '#141a21', + borderBottom: '1px solid #232c36', +}; + +/** 品牌方块(左侧色块 logo) */ +export const brandMark: CSSProperties = { + width: 30, + height: 30, + borderRadius: 8, + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + background: 'linear-gradient(135deg, #185fa5, #2b7fd4)', + color: '#fff', + fontWeight: 700, + fontSize: 14, + flexShrink: 0, +}; + +/** 主体两栏 */ +export const portalBody: CSSProperties = { + flex: 1, + display: 'flex', + minHeight: 0, +}; + +/** 左侧导航栏 */ +export const sidebar: CSSProperties = { + width: 244, + flex: '0 0 244px', + background: '#141a21', + borderRight: '1px solid #232c36', + padding: '16px 10px', + overflowY: 'auto', +}; + +/** 右侧内容区 */ +export const mainArea: CSSProperties = { + flex: 1, + padding: 24, + overflowY: 'auto', + minWidth: 0, +}; + +/** 侧栏分组标题 */ +export const navGroupTitle: CSSProperties = { + padding: '12px 10px 6px', + fontSize: 11, + letterSpacing: 1, + textTransform: 'uppercase', + color: '#6b7a8c', + fontWeight: 600, +}; + +/** 侧栏导航项 */ +export const navItem: CSSProperties = { + display: 'flex', + alignItems: 'center', + gap: 9, + padding: '8px 10px', + borderRadius: 7, + color: '#c7d3e0', + fontSize: 13, + cursor: 'pointer', + border: 'none', + background: 'transparent', + width: '100%', + textAlign: 'left', +}; + +/** 侧栏导航项 hover */ +export const navItemHover: CSSProperties = { + background: '#1c242d', + color: '#fff', +}; + +/** 侧栏导航项选中态 */ +export const navItemActive: CSSProperties = { + background: '#1b2b3d', + color: '#cfe3ff', + boxShadow: 'inset 2px 0 0 #2b7fd4', +}; + +/** 导航项内的图标底座 */ +export const navIcon: CSSProperties = { + width: 22, + height: 22, + borderRadius: 6, + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + background: '#222c37', + color: '#8fb6dd', + fontSize: 11, + fontWeight: 700, + flexShrink: 0, +}; + +/** 导航项右侧计数徽标 */ +export const navBadge: CSSProperties = { + marginLeft: 'auto', + fontSize: 11, + color: '#7d8ea1', + background: '#202a35', + borderRadius: 9, + padding: '1px 7px', + fontVariantNumeric: 'tabular-nums', +}; + +/** 页面标题 */ +export const pageTitle: CSSProperties = { + margin: 0, + fontSize: 19, + fontWeight: 650, + letterSpacing: 0.2, +}; + +/** 页面副标题 */ +export const pageSub: CSSProperties = { + margin: '6px 0 0', + fontSize: 13, + color: '#8b9aab', + lineHeight: 1.6, +}; + +/** 统计卡片容器 */ +export const statGrid: CSSProperties = { + display: 'grid', + gridTemplateColumns: 'repeat(auto-fit, minmax(150px, 1fr))', + gap: 12, + marginTop: 18, +}; + +/** 单个统计卡片 */ +export const statCard: CSSProperties = { + background: '#1a1f26', + border: '1px solid #232c36', + borderRadius: 10, + padding: '14px 16px', +}; + +/** 统计卡片的数值 */ +export const statValue: CSSProperties = { + fontSize: 24, + fontWeight: 680, + lineHeight: 1.15, + fontVariantNumeric: 'tabular-nums', +}; + +/** 统计卡片的标签 */ +export const statLabel: CSSProperties = { + fontSize: 12, + color: '#8b9aab', + marginTop: 5, +}; + +/** 内容分区块(带标题的面板) */ +export const panel: CSSProperties = { + background: '#1a1f26', + border: '1px solid #232c36', + borderRadius: 10, + padding: '16px 18px', + marginTop: 16, +}; + +/** 面板标题 */ +export const panelTitle: CSSProperties = { + margin: 0, + fontSize: 14, + fontWeight: 620, + display: 'flex', + alignItems: 'center', + gap: 8, +}; + +/** 面板副标题 */ +export const panelSub: CSSProperties = { + fontSize: 12, + color: '#7d8ea1', + marginTop: 4, + fontWeight: 400, +}; + +/** 小徽标(能力状态等) */ +export const chip: CSSProperties = { + display: 'inline-flex', + alignItems: 'center', + gap: 5, + fontSize: 11, + padding: '2px 8px', + borderRadius: 10, + background: '#222c37', + color: '#a9bacb', + whiteSpace: 'nowrap', +}; + +/** 状态圆点 */ +export const dot: CSSProperties = { + width: 7, + height: 7, + borderRadius: '50%', + flexShrink: 0, +}; + +/** 定义列表行(键值对) */ +export const kvRow: CSSProperties = { + display: 'flex', + gap: 12, + fontSize: 13, + padding: '7px 0', + borderBottom: '1px solid #1f2630', + alignItems: 'baseline', +}; + +/** 键名 */ +export const kvKey: CSSProperties = { + color: '#8b9aab', + width: 116, + flexShrink: 0, +}; + +/** 键值 */ +export const kvVal: CSSProperties = { + color: '#dce6f0', + wordBreak: 'break-all', + fontVariantNumeric: 'tabular-nums', };