- docs/e2e: 将 DAG 演示面板(dag-panel.mjs/html/data.mjs/sh/DAG演示.command)用 git mv 归入 dag-panel/ 子目录;修正相对依赖 ../lib、../results/dag-runs;清理 _diag_*.mjs 等临时诊断脚本(git rm 已跟踪项,rm 未跟踪项) - web: 修复头部用户名称切账号不变(新增 utils/user.ts 响应式 userName,登录/挂载/路由切换时拉取 /oauth/CurrentUser) - .gitignore: 新增 __pycache__/*.pyc 忽略规则(排除 demo 构建产物) - demo: 多个演示脚本与算子集市用例更新 - .workbuddy/memory: 补充本次工作记录 注意:docs/e2e/sswflow 与 **/__pycache__/*.pyc 按要求排除,未纳入。
1365 lines
61 KiB
HTML
1365 lines
61 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="zh-CN">
|
||
<head>
|
||
<meta charset="UTF-8" />
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||
<title>DAG 业务时序图 · 真实 Chrome 同步演示</title>
|
||
<style>
|
||
:root{
|
||
--bg:#0b0f14;
|
||
--panel:#12181f;
|
||
--panel2:#161c24;
|
||
--line:#212a36;
|
||
--txt:#e6edf3;
|
||
--sub:#9aa7b4;
|
||
--muted:#6b7886;
|
||
--accent:#58a6ff;
|
||
--pass:#2ea043;
|
||
--passbg:#0f2b18;
|
||
--fail:#cf4757;
|
||
--failbg:#2b1216;
|
||
--running:#d29922;
|
||
--runningbg:#2b230c;
|
||
--skip:#6b7886;
|
||
--noscript:#3d4856;
|
||
--shadow:0 6px 22px rgba(0,0,0,.45);
|
||
}
|
||
*{box-sizing:border-box}
|
||
html,body{margin:0;height:100%}
|
||
body{
|
||
background:radial-gradient(1200px 600px at 30% -10%, #14202b 0%, var(--bg) 60%) fixed, var(--bg);
|
||
color:var(--txt);
|
||
font:14px/1.55 -apple-system,"Segoe UI",Roboto,"PingFang SC","Microsoft YaHei",sans-serif;
|
||
min-height:100vh;
|
||
overflow-x:hidden;
|
||
}
|
||
a{color:var(--accent);text-decoration:none}
|
||
button{font-family:inherit}
|
||
|
||
/* ==== 顶部 ==== */
|
||
.topbar{
|
||
display:flex;align-items:center;gap:18px;
|
||
padding:14px 22px;border-bottom:1px solid var(--line);
|
||
background:linear-gradient(180deg,rgba(20,32,43,.7),rgba(11,15,20,.5));
|
||
backdrop-filter:blur(8px);
|
||
position:sticky;top:0;z-index:50;
|
||
}
|
||
.brand{display:flex;align-items:center;gap:12px}
|
||
.brand .logo{
|
||
width:34px;height:34px;border-radius:10px;
|
||
background:conic-gradient(from 210deg, #58a6ff, #a371f7, #d29922, #2ea043, #58a6ff);
|
||
box-shadow:0 0 0 1px rgba(255,255,255,.08) inset, 0 4px 14px rgba(88,166,255,.25);
|
||
position:relative;
|
||
}
|
||
.brand .logo::after{content:"";position:absolute;inset:6px;border-radius:6px;background:var(--bg)}
|
||
.brand .logo::before{content:"⚡";position:absolute;inset:0;display:grid;place-items:center;font-size:16px;z-index:2}
|
||
.brand .t{font-weight:700;font-size:16px;letter-spacing:.5px}
|
||
.brand .sub{color:var(--sub);font-size:12px;margin-left:4px}
|
||
.env{display:flex;gap:10px;margin-left:auto;align-items:center}
|
||
.env .pill{font-size:11px;padding:4px 10px;border-radius:18px;border:1px solid var(--line);background:var(--panel2);color:var(--sub);display:inline-flex;align-items:center;gap:6px}
|
||
.env .pill .dot{width:8px;height:8px;border-radius:50%;background:var(--skip)}
|
||
.env .pill.up .dot{background:var(--pass);box-shadow:0 0 8px rgba(46,160,67,.6)}
|
||
.env .pill.down .dot{background:var(--fail)}
|
||
|
||
/* ==== 图选择 Tab ==== */
|
||
.tabs{display:flex;gap:6px;padding:14px 22px 0;flex-wrap:wrap}
|
||
.tab{cursor:pointer;user-select:none;padding:9px 14px;border-radius:10px;background:var(--panel);border:1px solid var(--line);color:var(--sub);font-size:13px;font-weight:600;display:flex;align-items:center;gap:8px;transition:.15s}
|
||
.tab:hover{border-color:var(--accent);color:var(--txt)}
|
||
.tab.active{background:linear-gradient(180deg,rgba(88,166,255,.15),rgba(88,166,255,.05));border-color:rgba(88,166,255,.6);color:#fff;box-shadow:0 4px 14px rgba(88,166,255,.15)}
|
||
.tab .badge{font-size:10px;padding:1px 6px;border-radius:8px;background:var(--panel2);color:var(--sub);font-weight:500}
|
||
.tab.active .badge{background:rgba(88,166,255,.2);color:#fff}
|
||
|
||
/* ==== 主体 ==== */
|
||
.layout{display:grid;grid-template-columns:1fr 360px;gap:18px;padding:16px 22px 80px;min-height:calc(100vh - 130px)}
|
||
.main-card{background:var(--panel);border:1px solid var(--line);border-radius:14px;padding:16px 18px 18px;box-shadow:var(--shadow);position:relative;overflow:hidden}
|
||
.main-head{display:flex;align-items:center;gap:12px;margin-bottom:6px}
|
||
.main-head h2{margin:0;font-size:18px}
|
||
.main-head .subt{color:var(--sub);font-size:12px}
|
||
.summary{margin-left:auto;display:flex;gap:8px;flex-wrap:wrap}
|
||
.summary .pill{font-size:11px;padding:4px 10px;border-radius:18px;border:1px solid var(--line);background:var(--panel2);color:var(--sub)}
|
||
.summary .pill.pass{color:var(--pass);background:var(--passbg);border-color:#1d4d2c}
|
||
.summary .pill.fail{color:var(--fail);background:var(--failbg);border-color:#5a1f27}
|
||
.summary .pill.run{color:var(--running);background:var(--runningbg);border-color:#5a4710}
|
||
.summary .pill.idle{color:var(--muted)}
|
||
|
||
.actions{display:flex;gap:10px;margin:10px 0 14px;flex-wrap:wrap;align-items:center}
|
||
.open-toggle{display:inline-flex;align-items:center;gap:5px;padding:6px 12px;border:1px solid #30363d;border-radius:8px;cursor:pointer;font-size:12px;color:#8b949e;user-select:none;background:#0d1117}
|
||
.open-toggle:hover{border-color:#58a6ff;color:#e6edf3}
|
||
.open-toggle input{cursor:pointer;accent-color:#3b82f6}
|
||
.open-toggle:has(input:checked){background:#1f6feb22;color:#58a6ff;border-color:#58a6ff}
|
||
.btn{cursor:pointer;user-select:none;border:0;padding:9px 18px;border-radius:10px;font-weight:700;font-size:13px;display:inline-flex;align-items:center;gap:8px;transition:.15s}
|
||
.btn.primary{background:linear-gradient(180deg,#3b82f6,#2563eb);color:#fff;box-shadow:0 4px 14px rgba(37,99,235,.35)}
|
||
.btn.primary:hover{transform:translateY(-1px);box-shadow:0 6px 18px rgba(37,99,235,.45)}
|
||
.btn.primary:disabled{background:#3d4856;cursor:not-allowed;box-shadow:none;transform:none;color:#888}
|
||
.btn.ghost{background:var(--panel2);border:1px solid var(--line);color:var(--sub)}
|
||
.btn.ghost:hover{color:var(--txt);border-color:var(--accent)}
|
||
.hint{color:var(--muted);font-size:12px;margin-left:auto}
|
||
.progress{flex:1;min-width:160px;height:8px;border-radius:6px;background:var(--panel2);overflow:hidden;border:1px solid var(--line)}
|
||
.progress > i{display:block;height:100%;background:linear-gradient(90deg,var(--pass),var(--accent));width:0;transition:.3s}
|
||
|
||
/* ==== DAG SVG ==== */
|
||
.dag-wrap{background:linear-gradient(180deg,#0c1117,#0b0f14);border:1px solid var(--line);border-radius:12px;overflow:auto;position:relative;min-height:560px}
|
||
.dag-wrap::-webkit-scrollbar{height:10px;width:10px}
|
||
.dag-wrap::-webkit-scrollbar-thumb{background:var(--panel2);border-radius:8px}
|
||
|
||
/* 业务链路摘要 */
|
||
.flow-summary{
|
||
margin-bottom:12px;padding:12px 14px;
|
||
background:linear-gradient(135deg,rgba(126,231,135,.04),rgba(88,166,255,.04));
|
||
border:1px solid rgba(126,231,135,.3);border-radius:10px;
|
||
}
|
||
.flow-title{
|
||
font-size:12px;font-weight:700;color:#7ee787;letter-spacing:.5px;
|
||
margin-bottom:8px;font-family:ui-monospace,Menlo,monospace;
|
||
}
|
||
.flow-grid{
|
||
display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));
|
||
gap:6px 12px;
|
||
}
|
||
.flow-cell{
|
||
display:flex;align-items:center;gap:6px;
|
||
padding:4px 8px;border-radius:6px;
|
||
background:rgba(0,0,0,.3);border:1px solid rgba(255,255,255,.05);
|
||
font-family:ui-monospace,Menlo,monospace;font-size:11px;
|
||
}
|
||
.flow-cell .k{
|
||
color:#79c0ff;font-weight:700;
|
||
white-space:nowrap;
|
||
}
|
||
.flow-cell .v{
|
||
color:#cfd6df;overflow:hidden;text-overflow:ellipsis;
|
||
white-space:nowrap;max-width:160px;
|
||
}
|
||
.flow-cell .v.empty{color:var(--muted);font-style:italic}
|
||
svg.dag{display:block}
|
||
|
||
.stage-band{stroke:rgba(255,255,255,.04);stroke-width:1}
|
||
.stage-label{fill:#cfd6df;font-size:11px;font-weight:700;letter-spacing:.5px}
|
||
.lane-band{opacity:.25}
|
||
.lane-label{fill:#9aa7b4;font-size:11px;font-weight:700;letter-spacing:.3px}
|
||
|
||
/* === 节点 === */
|
||
.node{cursor:pointer;transition:filter .2s, transform .25s;transform-box:fill-box;transform-origin:center}
|
||
.node:hover rect.body{stroke:var(--accent);stroke-width:2}
|
||
.node.selected rect.body{stroke:var(--accent);stroke-width:2.5}
|
||
.node rect.body{fill:#161c24;stroke:#2a3340;stroke-width:1.2;filter:drop-shadow(0 4px 8px rgba(0,0,0,.5));transition:.15s}
|
||
.node .icon-bg{fill:#0d1117;stroke:#2a3340;stroke-width:1}
|
||
.node .icon{font-size:18px;dominant-baseline:middle;text-anchor:middle}
|
||
.node .title{fill:var(--txt);font-size:12.5px;font-weight:700;pointer-events:none}
|
||
.node .sub{fill:var(--sub);font-size:10px;pointer-events:none}
|
||
.node .tc{fill:#79c0ff;font-family:ui-monospace,Menlo,monospace;font-size:9.5px;font-weight:700;letter-spacing:.2px;pointer-events:none}
|
||
.node .data-box{fill:rgba(13,17,23,.85);stroke:rgba(126,231,135,.25);stroke-width:1;stroke-dasharray:2 2;rx:4;ry:4}
|
||
.node .data-name{fill:#7ee787;font-size:9.5px;font-weight:700;letter-spacing:.5px;font-family:ui-monospace,Menlo,monospace;pointer-events:none}
|
||
.node .data-preview{fill:#9aa7b4;font-size:9.5px;font-family:ui-monospace,Menlo,monospace;pointer-events:none;white-space:pre}
|
||
.node .route-badge{fill:rgba(88,166,255,.12);stroke:rgba(88,166,255,.45);stroke-width:.8;rx:3;ry:3}
|
||
.node .route-label{fill:#79c0ff;font-family:ui-monospace,Menlo,monospace;font-size:9px;font-weight:600;pointer-events:none;letter-spacing:.2px}
|
||
.node .state-dot{filter:drop-shadow(0 0 4px currentColor);transition:.25s}
|
||
|
||
.node.activating{filter:drop-shadow(0 0 16px rgba(210,153,34,.75)) drop-shadow(0 0 32px rgba(210,153,34,.35));animation:node-pulse 1.2s ease-in-out infinite}
|
||
.node.activating rect.body{stroke:#d29922;stroke-width:2.5;fill:#2b230c}
|
||
.node.activating .icon-bg{stroke:#d29922;stroke-width:1.5}
|
||
.node.activating .state-dot{filter:drop-shadow(0 0 10px #d29922) drop-shadow(0 0 20px #d29922)}
|
||
@keyframes node-pulse{0%,100%{transform:scale(1)}50%{transform:scale(1.04)}}
|
||
|
||
.node.pass rect.body{fill:#0f2b18;stroke:#2ea043;stroke-width:2}
|
||
.node.pass{filter:drop-shadow(0 0 8px rgba(46,160,67,.45))}
|
||
.node.fail rect.body{fill:#2b1216;stroke:#cf4757;stroke-width:2}
|
||
.node.fail{filter:drop-shadow(0 0 8px rgba(207,71,87,.45))}
|
||
.node.idle rect.body{fill:#161c24;stroke:#2a3340}
|
||
|
||
.node .halo{fill:none;stroke:rgba(210,153,34,.35);stroke-width:3;stroke-dasharray:6 4;animation:halo-spin 3s linear infinite}
|
||
@keyframes halo-spin{to{stroke-dashoffset:-100}}
|
||
|
||
/* === 边 === */
|
||
.edge{fill:none;stroke:#3d4856;stroke-width:1.6;transition:.15s}
|
||
.edge-label-box{fill:#0d1117;stroke-width:1.5;rx:8;ry:8;filter:drop-shadow(0 2px 4px rgba(0,0,0,.4))}
|
||
.edge-label{font-size:10px;font-weight:700;letter-spacing:.2px;font-family:ui-monospace,Menlo,monospace;text-anchor:middle;dominant-baseline:middle;pointer-events:none}
|
||
.edge-label-dot{font-size:11px;text-anchor:middle;dominant-baseline:middle;pointer-events:none}
|
||
|
||
@keyframes dash-flow{to{stroke-dashoffset:-40}}
|
||
@keyframes dash-flow-fast{to{stroke-dashoffset:-80}}
|
||
.edge.flow{stroke-dasharray:6 5;animation:dash-flow 1.6s linear infinite}
|
||
.edge.flow-fast{stroke-dasharray:8 4;animation:dash-flow-fast .9s linear infinite;filter:drop-shadow(0 0 6px currentColor)}
|
||
.edge.hot{stroke-width:2.4;filter:drop-shadow(0 0 6px currentColor)}
|
||
|
||
.edge-label-box.live{animation:pulse-glow 1.4s ease-in-out infinite}
|
||
@keyframes pulse-glow{0%,100%{filter:drop-shadow(0 2px 4px rgba(0,0,0,.4))}50%{filter:drop-shadow(0 2px 8px var(--live-glow, rgba(88,166,255,.6)))}}
|
||
|
||
/* ==== 侧栏 ==== */
|
||
.side{display:flex;flex-direction:column;gap:14px}
|
||
.card{background:var(--panel);border:1px solid var(--line);border-radius:14px;padding:14px 16px;box-shadow:var(--shadow)}
|
||
.card h3{margin:0 0 8px;font-size:13px;color:var(--accent);letter-spacing:.5px;text-transform:uppercase}
|
||
.detail .name{font-size:15px;font-weight:700;margin-bottom:4px}
|
||
.detail .meta{color:var(--sub);font-size:12px}
|
||
.detail .row{display:flex;gap:8px;margin-top:10px;font-size:12px;color:var(--sub)}
|
||
.detail .row b{color:var(--txt);font-weight:600}
|
||
.detail .tc{margin-top:10px;padding:8px 10px;background:var(--panel2);border-radius:8px;font-family:ui-monospace,Menlo,monospace;font-size:12px;color:var(--accent);border:1px solid var(--line);display:flex;align-items:center;gap:8px;justify-content:space-between}
|
||
.detail .route-pill{
|
||
display:inline-flex;align-items:center;gap:6px;
|
||
margin-top:8px;padding:4px 10px;
|
||
background:rgba(88,166,255,.1);border:1px solid rgba(88,166,255,.4);
|
||
border-radius:14px;color:#79c0ff;font-family:ui-monospace,Menlo,monospace;
|
||
font-size:11px;font-weight:600;letter-spacing:.3px;
|
||
}
|
||
.detail .route-pill::before{content:"→";color:var(--accent);font-weight:700}
|
||
.detail .real-data{margin-top:10px;padding:10px;border-radius:8px;background:rgba(126,231,135,.05);border:1px solid rgba(126,231,135,.25)}
|
||
.detail .real-data.fail{background:rgba(207,71,87,.06);border-color:rgba(207,71,87,.3)}
|
||
/* 节点白话解读(人话解释数据状况) */
|
||
.detail .narrative{margin:0 0 12px;padding:12px 14px;background:linear-gradient(135deg,rgba(88,166,255,.10),rgba(126,231,135,.06));border:1px solid rgba(88,166,255,.4);border-radius:10px}
|
||
.detail .narrative:empty{display:none}
|
||
.detail .narr-title{font-size:12px;font-weight:700;color:#79c0ff;letter-spacing:.5px;margin-bottom:6px;font-family:ui-monospace,Menlo,monospace}
|
||
.detail .narr-body{font-size:13px;line-height:1.72;color:#e6edf3}
|
||
.detail .narr-measured{margin-top:8px;font-size:12px;color:#7ee787;font-family:ui-monospace,Menlo,monospace;border-top:1px dashed rgba(126,231,135,.3);padding-top:6px}
|
||
.detail .narr-measured.fail{color:#f78166}
|
||
.detail .narr-hint{margin-top:6px;font-size:11px;color:var(--muted)}
|
||
.detail .open-row{margin-top:10px}
|
||
.detail .open-btn{
|
||
width:100%;padding:9px 12px;border:none;border-radius:9px;cursor:pointer;
|
||
background:linear-gradient(135deg,#58a6ff,#3fb950);color:#fff;font-size:13px;font-weight:700;
|
||
box-shadow:0 2px 10px rgba(63,185,80,.35);transition:filter .15s
|
||
}
|
||
.detail .open-btn:hover{filter:brightness(1.08)}
|
||
.detail .open-btn:disabled{opacity:.6;cursor:default}
|
||
.detail .open-hint{margin-top:6px;font-size:11px;color:var(--muted);font-family:ui-monospace,Menlo,monospace;word-break:break-all}
|
||
.toast{
|
||
position:fixed;left:50%;bottom:28px;transform:translateX(-50%) translateY(20px);
|
||
background:rgba(20,24,32,.95);color:#e6edf3;padding:10px 18px;border-radius:10px;
|
||
border:1px solid rgba(88,166,255,.4);font-size:13px;z-index:9999;opacity:0;
|
||
transition:opacity .2s,transform .2s;pointer-events:none;box-shadow:0 8px 30px rgba(0,0,0,.4)
|
||
}
|
||
.toast.show{opacity:1;transform:translateX(-50%) translateY(0)}
|
||
.detail .real-data .name{color:#7ee787;font-family:ui-monospace,Menlo,monospace;font-size:11px;font-weight:700;letter-spacing:.5px;margin-bottom:6px}
|
||
.detail .real-data.fail .name{color:#f78166}
|
||
.detail .real-data .kv{display:grid;grid-template-columns:64px 1fr;gap:4px 8px;font-family:ui-monospace,Menlo,monospace;font-size:11px;color:#cfd6df}
|
||
.detail .real-data .kv b{color:#79c0ff;font-weight:600}
|
||
.detail .real-data .first-row{
|
||
margin-top:8px;padding:6px 8px;background:rgba(0,0,0,.3);border-radius:4px;
|
||
font-family:ui-monospace,Menlo,monospace;font-size:10.5px;color:#9aa7b4;
|
||
max-height:54px;overflow:hidden;line-height:1.5;
|
||
}
|
||
.detail .real-data .steps{
|
||
list-style:none;padding:0;margin:6px 0 0;display:flex;flex-direction:column;gap:4px;
|
||
}
|
||
.detail .real-data .step{
|
||
display:grid;grid-template-columns:auto auto 1fr auto;gap:4px 8px;align-items:center;
|
||
padding:5px 8px;background:rgba(0,0,0,.25);border-radius:5px;
|
||
font-size:11px;border-left:3px solid #484f58;font-family:ui-monospace,Menlo,monospace;
|
||
}
|
||
.detail .real-data .step.ok{border-left-color:var(--pass);background:rgba(126,231,135,.05)}
|
||
.detail .real-data .step.fail{border-left-color:var(--fail);background:rgba(207,71,87,.06)}
|
||
.detail .real-data .step-ic{font-size:13px}
|
||
.detail .real-data .step-num{color:#79c0ff;font-weight:700;font-size:10px}
|
||
.detail .real-data .step-desc{color:#e6edf3;font-size:11.5px}
|
||
.detail .real-data .step-ms{color:#8b949e;font-size:10px}
|
||
.detail .real-data .step-meta{grid-column:1/-1;font-size:10px;color:#8b949e;padding-left:24px}
|
||
.detail .real-data .step-meta code{background:rgba(0,0,0,.35);padding:1px 4px;border-radius:3px;color:#7ee787;font-size:10px}
|
||
.detail .real-data .step-err{grid-column:1/-1;font-size:10px;color:var(--fail);padding-left:24px}
|
||
.detail .real-data .step-shot{grid-column:1/-1;font-size:10px;color:#79c0ff;padding-left:24px;text-decoration:none}
|
||
.detail .real-data .step-shot:hover{text-decoration:underline}
|
||
|
||
/* 业务指标卡片 */
|
||
.detail .real-data.metrics-card{background:rgba(126,231,135,.06);border-color:rgba(126,231,135,.3)}
|
||
.detail .real-data.metrics-card .name{color:#7ee787}
|
||
.detail .metrics{display:grid;grid-template-columns:1fr 1fr;gap:4px 12px;margin-top:6px}
|
||
.detail .metric{display:flex;justify-content:space-between;font-family:ui-monospace,Menlo,monospace;font-size:10.5px;padding:3px 0;border-bottom:1px dashed rgba(255,255,255,.05)}
|
||
.detail .metric .mk{color:#79c0ff;font-weight:600}
|
||
.detail .metric .mv{color:#e6edf3}
|
||
|
||
/* 审计勾选清单 */
|
||
.detail .real-data.checks-card{background:rgba(247,129,102,.05);border-color:rgba(247,129,102,.3)}
|
||
.detail .real-data.checks-card .name{color:#f78166}
|
||
.detail .checks{list-style:none;padding:0;margin:6px 0 0;display:flex;flex-direction:column;gap:3px}
|
||
.detail .checks li{font-size:11px;color:#7ee787;padding:3px 0;border-bottom:1px dashed rgba(255,255,255,.05)}
|
||
|
||
/* 计费高亮卡片 */
|
||
.detail .real-data.price-card{background:rgba(255,215,0,.05);border-color:rgba(255,215,0,.35)}
|
||
.detail .real-data.price-card .name{color:#ffd700}
|
||
.detail .price-block{display:flex;flex-direction:column;align-items:center;padding:8px 0}
|
||
.detail .price-block .big{font-size:26px;font-weight:700;color:#ffd700;font-family:ui-monospace,Menlo,monospace;letter-spacing:1px}
|
||
.detail .price-block .meta{font-size:10.5px;color:#cfd6df;margin-top:4px;text-align:center}
|
||
.detail .shot-thumb{
|
||
margin-top:10px;border:1px solid var(--line);border-radius:8px;overflow:hidden;
|
||
background:#000;display:block;cursor:zoom-in;
|
||
}
|
||
.detail .shot-thumb img{width:100%;display:block}
|
||
.detail .shot-meta{
|
||
display:flex;justify-content:space-between;font-size:10.5px;color:var(--muted);
|
||
margin-top:4px;font-family:ui-monospace,Menlo,monospace;
|
||
}
|
||
.detail .shot-modal{
|
||
position:fixed;inset:0;background:rgba(0,0,0,.85);display:none;
|
||
align-items:center;justify-content:center;z-index:200;cursor:zoom-out;
|
||
}
|
||
.detail .shot-modal.open{display:flex}
|
||
.detail .shot-modal img{max-width:96vw;max-height:92vh;border-radius:8px;box-shadow:0 10px 40px rgba(0,0,0,.6)}
|
||
|
||
.legend{display:flex;flex-wrap:wrap;gap:10px;font-size:12px;color:var(--sub)}
|
||
.legend .i{display:inline-flex;align-items:center;gap:6px}
|
||
.legend .swatch{width:12px;height:12px;border-radius:3px;border:1px solid rgba(255,255,255,.1)}
|
||
.log{font-family:ui-monospace,Menlo,monospace;font-size:11px;line-height:1.5;color:var(--sub);background:#0b0f14;border:1px solid var(--line);border-radius:8px;padding:10px;max-height:260px;overflow:auto}
|
||
.log .l{display:block;white-space:pre-wrap;word-break:break-all}
|
||
.log .l.err{color:var(--fail)}
|
||
.log .l.ok{color:var(--pass)}
|
||
.log .l.warn{color:var(--running)}
|
||
|
||
.g1 .accent{color:#58a6ff}.g2 .accent{color:#a371f7}.g3 .accent{color:#3fb950}.g4 .accent{color:#ff7b72}.g5 .accent{color:#d29922}
|
||
.tab[data-g="seq-1"].active{background:linear-gradient(180deg,rgba(88,166,255,.2),rgba(88,166,255,.05));border-color:#58a6ff}
|
||
.tab[data-g="seq-2"].active{background:linear-gradient(180deg,rgba(163,113,247,.2),rgba(163,113,247,.05));border-color:#a371f7}
|
||
.tab[data-g="seq-3"].active{background:linear-gradient(180deg,rgba(63,185,80,.2),rgba(63,185,80,.05));border-color:#3fb950}
|
||
.tab[data-g="seq-4"].active{background:linear-gradient(180deg,rgba(255,123,114,.2),rgba(255,123,114,.05));border-color:#ff7b72}
|
||
.tab[data-g="seq-5"].active{background:linear-gradient(180deg,rgba(210,153,34,.2),rgba(210,153,34,.05));border-color:#d29922}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
|
||
<div class="topbar">
|
||
<div class="brand">
|
||
<div class="logo"></div>
|
||
<div>
|
||
<div class="t">DAG 业务时序图 · 真实 Chrome 演示</div>
|
||
<div class="sub">尚数网 · 可信数据空间 · 节点真实打开 JNPF 对应路由 → 读 DOM → 截图</div>
|
||
</div>
|
||
</div>
|
||
<div class="env" id="env">
|
||
<span class="pill"><span class="dot"></span>探测中…</span>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="tabs" id="tabs"></div>
|
||
|
||
<div class="layout">
|
||
<div class="main-card" id="main">
|
||
<div class="main-head">
|
||
<h2 id="title">—</h2>
|
||
<span class="subt" id="subtitle"></span>
|
||
<div class="summary" id="summary"></div>
|
||
</div>
|
||
|
||
<div class="actions">
|
||
<button class="btn primary" id="run">▶ 启动 · 真实业务链路演示</button>
|
||
<label class="open-toggle" title="启动时是否拉起 Google Chrome 旁观窗口(默认弹,便于演示;不弹则后台无头跑,省内存)">
|
||
<input type="radio" name="openChrome" value="yes" id="open-yes" checked>
|
||
<span>弹 Chrome</span>
|
||
</label>
|
||
<label class="open-toggle" title="不弹旁观 Chrome,后台无头跑(省内存、不打扰演示现场)">
|
||
<input type="radio" name="openChrome" value="no" id="open-no">
|
||
<span>无头跑</span>
|
||
</label>
|
||
<button class="btn ghost" id="stop" disabled>■ 停止</button>
|
||
<div class="progress"><i id="prog"></i></div>
|
||
<span class="hint" id="hint">每节点真实调 API + Chrome → 业务 ID 跨节点传递</span>
|
||
</div>
|
||
|
||
<!-- 业务链路摘要:跑完后展示本次 batch 创建的所有真实 ID -->
|
||
<div id="flow-summary" class="flow-summary" style="display:none">
|
||
<div class="flow-title">◆ 本次真实业务链路摘要(flowCtx)</div>
|
||
<div class="flow-grid" id="flow-grid"></div>
|
||
</div>
|
||
|
||
<div class="dag-wrap" id="wrap">
|
||
<svg class="dag" id="dag" xmlns="http://www.w3.org/2000/svg"></svg>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="side">
|
||
<div class="card detail" id="detail">
|
||
<h3>节点详情</h3>
|
||
<div class="name" id="d-name">选中节点查看</div>
|
||
<div class="meta" id="d-meta">点击 DAG 上的任意节点</div>
|
||
<div class="narrative" id="d-narrative"></div>
|
||
<div class="row"><b>泳道:</b><span id="d-lane">—</span></div>
|
||
<div class="row"><b>阶段:</b><span id="d-stage">—</span></div>
|
||
<div id="d-route-wrap"></div>
|
||
<div id="d-open" class="open-row"></div>
|
||
<div id="d-tc-wrap"></div>
|
||
<div id="d-data-wrap"></div>
|
||
<div id="d-flow-wrap"></div>
|
||
<div id="d-shot-wrap"></div>
|
||
</div>
|
||
|
||
<div class="card">
|
||
<h3>数据流图例</h3>
|
||
<div class="legend" id="legend"></div>
|
||
</div>
|
||
|
||
<div class="card">
|
||
<h3>实时日志</h3>
|
||
<div class="log" id="log"><span class="l muted">▷ 等待启动…</span></div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="shot-modal" id="shot-modal"><img id="shot-modal-img" alt=""></div>
|
||
|
||
<script>
|
||
// =============== 客户端状态 ===============
|
||
const state = {
|
||
graphs: [],
|
||
swimlanes: {},
|
||
edgeKinds: {},
|
||
current: null,
|
||
selected: null,
|
||
running: false,
|
||
liveNode: null,
|
||
liveEdges: new Set(),
|
||
totalNodes: 0,
|
||
doneCount: 0,
|
||
nodeResults: {} // nodeId → { tc, route, status, ms, error, data }
|
||
}
|
||
|
||
const $ = (s) => document.querySelector(s)
|
||
const $$ = (s) => Array.from(document.querySelectorAll(s))
|
||
const el = (tag, attrs = {}, children = []) => {
|
||
const e = document.createElement(tag)
|
||
for (const [k, v] of Object.entries(attrs)) {
|
||
if (k === 'class') e.className = v
|
||
else if (k === 'text') e.textContent = v
|
||
else if (k.startsWith('on')) e.addEventListener(k.slice(2), v)
|
||
else e.setAttribute(k, v)
|
||
}
|
||
for (const c of [].concat(children)) e.append(c)
|
||
return e
|
||
}
|
||
const SVG_NS = 'http://www.w3.org/2000/svg'
|
||
const svgEl = (tag, attrs = {}) => {
|
||
const e = document.createElementNS(SVG_NS, tag)
|
||
for (const [k, v] of Object.entries(attrs)) e.setAttribute(k, v)
|
||
return e
|
||
}
|
||
const NS_ID = (id) => id.replace(/[^\w-]/g, '_')
|
||
const EDGE_ID = (from, to) => `e_${NS_ID(from)}__${NS_ID(to)}`
|
||
|
||
function logLine(msg, cls = '') {
|
||
const log = $('#log')
|
||
const span = document.createElement('span')
|
||
span.className = 'l ' + cls
|
||
span.textContent = msg
|
||
log.appendChild(span)
|
||
log.scrollTop = log.scrollHeight
|
||
}
|
||
|
||
async function loadAll() {
|
||
const [dags, status] = await Promise.all([
|
||
fetch('/api/dags').then((r) => r.json()),
|
||
fetch('/api/status').then((r) => r.json())
|
||
])
|
||
state.graphs = dags.graphs
|
||
state.swimlanes = dags.swimlanes
|
||
state.edgeKinds = dags.edgeKinds || {}
|
||
paintEnv(status.env)
|
||
paintTabs()
|
||
selectGraph(state.graphs[0].id)
|
||
}
|
||
|
||
function paintEnv(env) {
|
||
const c = $('#env')
|
||
c.innerHTML = ''
|
||
const items = [
|
||
{ k: '后端 30000', up: env.be.up },
|
||
{ k: '前端 5173', up: env.fe.up }
|
||
]
|
||
for (const it of items) {
|
||
const p = el('span', { class: 'pill ' + (it.up ? 'up' : 'down') })
|
||
p.innerHTML = `<span class="dot"></span>${it.k} ${it.up ? 'OK' : 'DOWN'}`
|
||
c.appendChild(p)
|
||
}
|
||
}
|
||
|
||
function paintTabs() {
|
||
const c = $('#tabs')
|
||
c.innerHTML = ''
|
||
state.graphs.forEach((g) => {
|
||
const t = el('div', { class: 'tab', 'data-g': g.id, onclick: () => selectGraph(g.id) })
|
||
t.innerHTML = `图${g.no} · ${g.title} <span class="badge">${g.nodes.length}节点</span>`
|
||
c.appendChild(t)
|
||
})
|
||
$$('.tab').forEach((t) => t.classList.toggle('active', t.dataset.g === state.current))
|
||
}
|
||
|
||
function selectGraph(id) {
|
||
state.current = id
|
||
state.selected = null
|
||
state.nodeResults = {}
|
||
const g = state.graphs.find((x) => x.id === id)
|
||
$('#title').textContent = `图${g.no} · ${g.title}`
|
||
$('#subtitle').textContent = g.subtitle
|
||
paintTabs()
|
||
paintLegend(g)
|
||
paintSummary(g)
|
||
drawDag(g)
|
||
resetDetail()
|
||
}
|
||
|
||
function paintLegend(g) {
|
||
const c = $('#legend')
|
||
c.innerHTML = ''
|
||
for (const lane of g.participants) {
|
||
const sw = state.swimlanes[lane]
|
||
if (!sw) continue
|
||
c.appendChild(el('div', { class: 'i' }, [
|
||
el('span', { class: 'swatch', style: `background:${sw.color}` }),
|
||
document.createTextNode(sw.label)
|
||
]))
|
||
}
|
||
c.appendChild(el('div', { class: 'i', style: 'width:100%;margin-top:6px;color:var(--muted);font-size:11px' }, [document.createTextNode('数据流类型')]))
|
||
for (const k of Object.keys(state.edgeKinds)) {
|
||
const e = state.edgeKinds[k]
|
||
c.appendChild(el('div', { class: 'i' }, [
|
||
el('span', { class: 'swatch', style: `background:${e.color}` }),
|
||
document.createTextNode(e.label)
|
||
]))
|
||
}
|
||
}
|
||
|
||
function paintSummary(g) {
|
||
const c = $('#summary')
|
||
c.innerHTML = ''
|
||
const total = g.nodes.length
|
||
c.appendChild(el('span', { class: 'pill pass', text: `✔ 已通过 ${state.doneCount || 0}` }))
|
||
c.appendChild(el('span', { class: 'pill idle', text: `∑ ${total} 节点` }))
|
||
}
|
||
|
||
function stackHeight(stack, nodeH, gapY) {
|
||
return stack * (nodeH + gapY) - gapY
|
||
}
|
||
|
||
function drawDag(g) {
|
||
const wrap = $('#wrap')
|
||
wrap.scrollTo({ left: 0, top: 0 })
|
||
const svg = $('#dag')
|
||
svg.innerHTML = ''
|
||
|
||
const LANE_W = 220
|
||
const LANE_HEAD = 38
|
||
const NODE_W = 184
|
||
const NODE_H = 96
|
||
const GAP_X = 24
|
||
const GAP_Y = 20
|
||
const STAGE_PAD = 14
|
||
const PAD = 18
|
||
|
||
const lanes = g.participants
|
||
const stages = g.stages
|
||
const W = PAD * 2 + LANE_HEAD + lanes.length * LANE_W
|
||
|
||
const grid = {}
|
||
for (const n of g.nodes) {
|
||
const k = `${n.stage}|${n.lane}`
|
||
;(grid[k] ||= []).push(n.id)
|
||
}
|
||
|
||
let yCursor = PAD + 28
|
||
const stageMeta = stages.map((stage, si) => {
|
||
let maxStack = 1
|
||
lanes.forEach((lane) => {
|
||
const a = grid[`${stage.id}|${lane}`] || []
|
||
if (a.length > maxStack) maxStack = a.length
|
||
})
|
||
const top = yCursor + STAGE_PAD
|
||
const h = stackHeight(maxStack, NODE_H, GAP_Y) + STAGE_PAD
|
||
yCursor = top + h - STAGE_PAD
|
||
return { ...stage, top, h, maxStack, bottom: top + h }
|
||
})
|
||
const H = yCursor + PAD
|
||
|
||
svg.setAttribute('viewBox', `0 0 ${W} ${H}`)
|
||
svg.setAttribute('width', W)
|
||
svg.setAttribute('height', H)
|
||
svg.style.minWidth = W + 'px'
|
||
svg.style.minHeight = H + 'px'
|
||
|
||
const defs = svgEl('defs')
|
||
defs.innerHTML = `
|
||
<marker id="arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="8" markerHeight="8" orient="auto">
|
||
<path d="M0,0 L10,5 L0,10 Z" fill="#3d4856"/>
|
||
</marker>
|
||
<marker id="arrow-on" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="9" markerHeight="9" orient="auto">
|
||
<path d="M0,0 L10,5 L0,10 Z" fill="#58a6ff"/>
|
||
</marker>
|
||
`
|
||
Object.entries(state.edgeKinds).forEach(([k, e]) => {
|
||
defs.innerHTML += `
|
||
<marker id="arrow-${k}" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="8" markerHeight="8" orient="auto">
|
||
<path d="M0,0 L10,5 L0,10 Z" fill="${e.color}"/>
|
||
</marker>
|
||
`
|
||
})
|
||
svg.appendChild(defs)
|
||
|
||
stageMeta.forEach((stage) => {
|
||
const bg = svgEl('rect', {
|
||
x: PAD, y: stage.top, width: W - PAD * 2, height: stage.h,
|
||
class: 'stage-band', fill: stage.color || '#0e141a', rx: 10, ry: 10
|
||
})
|
||
svg.appendChild(bg)
|
||
const tab = svgEl('rect', {
|
||
x: PAD + 8, y: stage.top + 8, width: 4, height: 18,
|
||
fill: (state.edgeKinds.request || {}).color || '#58a6ff', rx: 2, ry: 2, opacity: .9
|
||
})
|
||
svg.appendChild(tab)
|
||
const t = svgEl('text', { x: PAD + 22, y: stage.top + 21, class: 'stage-label' })
|
||
t.textContent = stage.name
|
||
svg.appendChild(t)
|
||
})
|
||
|
||
lanes.forEach((lane, i) => {
|
||
const sw = state.swimlanes[lane]
|
||
const x = PAD + LANE_HEAD + i * LANE_W
|
||
const band = svgEl('rect', {
|
||
x, y: PAD + 28, width: LANE_W, height: H - PAD * 2 - 28,
|
||
class: 'lane-band', fill: sw?.bg || '#0d1117', rx: 6, ry: 6
|
||
})
|
||
svg.appendChild(band)
|
||
const t = svgEl('text', {
|
||
x: x + LANE_W / 2, y: PAD + 18, 'text-anchor': 'middle',
|
||
class: 'lane-label', style: `fill:${sw?.color || '#9aa7b4'}`
|
||
})
|
||
t.textContent = sw?.label || lane
|
||
svg.appendChild(t)
|
||
})
|
||
|
||
const pos = {}
|
||
g.nodes.forEach((n) => {
|
||
const si = stages.findIndex((s) => s.id === n.stage)
|
||
const li = lanes.indexOf(n.lane)
|
||
const stack = grid[`${n.stage}|${n.lane}`]
|
||
const idx = stack.indexOf(n.id)
|
||
const x = PAD + LANE_HEAD + li * LANE_W + (LANE_W - NODE_W) / 2
|
||
const stage = stageMeta[si]
|
||
const y = stage.top + STAGE_PAD + idx * (NODE_H + GAP_Y)
|
||
pos[n.id] = { x, y, cx: x + NODE_W / 2, cy: y + NODE_H / 2, w: NODE_W, h: NODE_H, lane: n.lane, stage: n.stage }
|
||
})
|
||
|
||
for (const e of g.edges) {
|
||
const { from, to, label, kind } = e
|
||
const a = pos[from], b = pos[to]
|
||
if (!a || !b) continue
|
||
const x1 = a.x + a.w, y1 = a.cy, x2 = b.x, y2 = b.cy
|
||
const midX = (x1 + x2) / 2
|
||
const path = svgEl('path', {
|
||
id: EDGE_ID(from, to),
|
||
d: `M ${x1} ${y1} C ${midX} ${y1}, ${midX} ${y2}, ${x2} ${y2}`,
|
||
class: 'edge',
|
||
'data-from': from, 'data-to': to, 'data-kind': kind || 'request',
|
||
'marker-end': `url(#arrow-${kind || 'request'})`,
|
||
stroke: (state.edgeKinds[kind || 'request'] || { color: '#3d4856' }).color
|
||
})
|
||
svg.appendChild(path)
|
||
}
|
||
|
||
for (const e of g.edges) {
|
||
const { from, to, label, kind } = e
|
||
const a = pos[from], b = pos[to]
|
||
if (!a || !b || !label) continue
|
||
const k = state.edgeKinds[kind || 'request'] || { color: '#3d4856', text: '#cfd6df' }
|
||
const x1 = a.x + a.w, y1 = a.cy, x2 = b.x, y2 = b.cy
|
||
const midX = (x1 + x2) / 2
|
||
const t = 0.5
|
||
const cx = (1 - t) ** 3 * x1 + 3 * (1 - t) ** 2 * t * midX + 3 * (1 - t) * t * t * midX + t ** 3 * x2
|
||
const cy = (1 - t) ** 3 * y1 + 3 * (1 - t) ** 2 * t * y1 + 3 * (1 - t) * t * t * y2 + t ** 3 * y2
|
||
|
||
const txt = label
|
||
const txtW = Math.max(48, txt.length * 9 + 22)
|
||
const g2 = svgEl('g', { class: 'edge-tag', 'data-from': from, 'data-to': to, style: `--live-glow:${k.glow || k.color}` })
|
||
const box = svgEl('rect', {
|
||
x: cx - txtW / 2, y: cy - 11, width: txtW, height: 22,
|
||
class: 'edge-label-box', fill: '#0b0f14', stroke: k.color,
|
||
style: `filter:drop-shadow(0 0 4px ${k.glow || k.color}33)`
|
||
})
|
||
const t1 = svgEl('text', { x: cx, y: cy + 1, class: 'edge-label', fill: k.text || k.color })
|
||
t1.textContent = '◆ ' + txt
|
||
g2.append(box, t1)
|
||
svg.appendChild(g2)
|
||
}
|
||
|
||
// 节点
|
||
for (const n of g.nodes) {
|
||
const p = pos[n.id]
|
||
const sw = state.swimlanes[n.lane] || { color: '#58a6ff' }
|
||
|
||
const gNode = svgEl('g', { class: 'node idle', 'data-id': n.id, onclick: () => selectNode(n.id), title: n.narrative || n.sub || '' })
|
||
|
||
const rect = svgEl('rect', { x: p.x, y: p.y, width: NODE_W, height: NODE_H, rx: 10, ry: 10, class: 'body' })
|
||
gNode.appendChild(rect)
|
||
|
||
const halo = svgEl('rect', {
|
||
x: p.x - 4, y: p.y - 4, width: NODE_W + 8, height: NODE_H + 8,
|
||
rx: 14, ry: 14, class: 'halo', opacity: 0
|
||
})
|
||
gNode.appendChild(halo)
|
||
|
||
const stripe = svgEl('rect', {
|
||
x: p.x, y: p.y, width: 4, height: NODE_H, rx: 2, ry: 2, fill: sw.color, opacity: .9
|
||
})
|
||
gNode.appendChild(stripe)
|
||
|
||
const iconBg = svgEl('circle', { cx: p.x + 22, cy: p.y + 18, r: 12, class: 'icon-bg' })
|
||
gNode.appendChild(iconBg)
|
||
const icon = svgEl('text', { x: p.x + 22, y: p.y + 19, class: 'icon' })
|
||
icon.textContent = n.icon || '●'
|
||
gNode.appendChild(icon)
|
||
|
||
// 步骤数徽章(如果节点配置了 actions)
|
||
if (n.actions && n.actions.length) {
|
||
const stepCircle = svgEl('circle', {
|
||
cx: p.x + NODE_W - 14, cy: p.y + 16, r: 9,
|
||
fill: '#1f6feb', opacity: 0.95
|
||
})
|
||
gNode.appendChild(stepCircle)
|
||
const stepText = svgEl('text', {
|
||
x: p.x + NODE_W - 14, y: p.y + 20,
|
||
'text-anchor': 'middle', class: 'step-badge',
|
||
fill: '#fff', 'font-size': 11, 'font-weight': 700
|
||
})
|
||
stepText.textContent = n.actions.length
|
||
stepText.setAttribute('id', `ab-${n.id}`)
|
||
gNode.appendChild(stepText)
|
||
}
|
||
|
||
const title = svgEl('text', { x: p.x + 38, y: p.y + 22, class: 'title' })
|
||
title.textContent = n.label.length > 16 ? n.label.slice(0, 15) + '…' : n.label
|
||
gNode.appendChild(title)
|
||
|
||
if (n.sub) {
|
||
const sub = svgEl('text', { x: p.x + 38, y: p.y + 36, class: 'sub' })
|
||
sub.textContent = n.sub.length > 22 ? n.sub.slice(0, 21) + '…' : n.sub
|
||
gNode.appendChild(sub)
|
||
}
|
||
|
||
// 真实路由徽章
|
||
if (n.route) {
|
||
const rb = svgEl('rect', {
|
||
x: p.x + 10, y: p.y + NODE_H - 14,
|
||
width: 9 + n.route.length * 5.2, height: 12,
|
||
class: 'route-badge'
|
||
})
|
||
gNode.appendChild(rb)
|
||
const rt = svgEl('text', {
|
||
x: p.x + 14, y: p.y + NODE_H - 5,
|
||
class: 'route-label'
|
||
})
|
||
rt.textContent = n.route
|
||
gNode.appendChild(rt)
|
||
}
|
||
|
||
// mode 徽章(view/create/query/status/execute)
|
||
if (n.mode && n.mode !== 'view') {
|
||
const modeLabel = n.mode.toUpperCase()
|
||
const modeColor = { create: '#2ea043', query: '#a371f7', status: '#d29922', execute: '#f78166' }[n.mode] || '#58a6ff'
|
||
const modeY = p.y + NODE_H - 38
|
||
const mb = svgEl('rect', {
|
||
x: p.x + 10, y: modeY,
|
||
width: 9 + modeLabel.length * 5.5, height: 12,
|
||
fill: modeColor, opacity: .25, rx: 3, ry: 3
|
||
})
|
||
gNode.appendChild(mb)
|
||
const mt = svgEl('text', {
|
||
x: p.x + 14, y: modeY + 9,
|
||
fill: modeColor,
|
||
style: 'font-family:ui-monospace,Menlo,monospace;font-size:9px;font-weight:700;letter-spacing:.2px'
|
||
})
|
||
mt.textContent = modeLabel
|
||
gNode.appendChild(mt)
|
||
}
|
||
|
||
if (n.case) {
|
||
// 把 TC 标签移到更上面,避免和 route badge 冲突
|
||
const tc = svgEl('text', { x: p.x + 10, y: p.y + NODE_H - 26, class: 'tc' })
|
||
tc.textContent = '🎯 ' + n.case
|
||
gNode.appendChild(tc)
|
||
}
|
||
|
||
if (n.data) {
|
||
const boxY = p.y + 50
|
||
const dataBox = svgEl('rect', {
|
||
x: p.x + 8, y: boxY, width: NODE_W - 16, height: 32, rx: 5, ry: 5, class: 'data-box'
|
||
})
|
||
gNode.appendChild(dataBox)
|
||
|
||
const dn = svgEl('text', { x: p.x + 14, y: boxY + 12, class: 'data-name' })
|
||
dn.textContent = '◆ ' + (n.data.name || 'data')
|
||
gNode.appendChild(dn)
|
||
|
||
const dp = svgEl('text', { x: p.x + 14, y: boxY + 25, class: 'data-preview', id: `dp-${n.id}` })
|
||
dp.textContent = (n.data.preview || '').split('\n')[0].slice(0, 26)
|
||
gNode.appendChild(dp)
|
||
}
|
||
|
||
const dot = svgEl('circle', {
|
||
cx: p.x + NODE_W - 12, cy: p.y + 12, r: 5, fill: '#3d4856', class: 'state-dot', style: 'color:#3d4856'
|
||
})
|
||
gNode.appendChild(dot)
|
||
|
||
svg.appendChild(gNode)
|
||
}
|
||
|
||
state.pos = pos
|
||
}
|
||
|
||
function selectNode(id) {
|
||
state.selected = id
|
||
const g = state.graphs.find((x) => x.id === state.current)
|
||
const n = g.nodes.find((x) => x.id === id)
|
||
const lane = state.swimlanes[n.lane]
|
||
const stage = g.stages.find((s) => s.id === n.stage)
|
||
$('#d-name').textContent = (n.icon ? n.icon + ' ' : '') + n.label
|
||
$('#d-meta').textContent = n.sub || ''
|
||
$('#d-lane').textContent = lane?.label || n.lane
|
||
$('#d-stage').textContent = stage?.name || n.stage
|
||
renderNarrative(n)
|
||
|
||
// 路由徽章
|
||
const routeWrap = $('#d-route-wrap')
|
||
routeWrap.innerHTML = ''
|
||
if (n.route) {
|
||
routeWrap.innerHTML = `<div class="route-pill">${escapeHtml(n.route)}</div>`
|
||
}
|
||
|
||
// 「在浏览器打开数据页」按钮:节点含 bizDetail 业务全景路径时显示
|
||
const openWrap = $('#d-open')
|
||
openWrap.innerHTML = ''
|
||
const bizPath = (state.nodeResults[id]?.actionSteps || []).find((s) => s.type === 'bizDetail' && s.path)?.path
|
||
if (bizPath) {
|
||
openWrap.innerHTML = `<button class="open-btn" onclick='openNodeInBrowser(${JSON.stringify(bizPath)})'>🔵 在浏览器打开数据页</button><div class="open-hint">${escapeHtml(bizPath)}</div>`
|
||
}
|
||
|
||
// TC 状态
|
||
const tcWrap = $('#d-tc-wrap')
|
||
tcWrap.innerHTML = ''
|
||
if (n.case) {
|
||
const r = state.nodeResults[id] // 用 id 作 key
|
||
if (r) {
|
||
const st = r.status
|
||
const stateLabel = { pass: '通过 ✔', fail: '失败 ✘', running: '运行中 ⏳' }[st] || st
|
||
const color = st === 'pass' ? 'var(--pass)' : st === 'fail' ? 'var(--fail)' : 'var(--running)'
|
||
tcWrap.innerHTML = `
|
||
<div class="tc">🎯 ${n.case}<span style="color:${color}">${stateLabel}</span></div>
|
||
<div class="route">耗时 ${r.ms}ms · ${(r.at || '').slice(11, 19) || ''}${r.error ? ' · ' + r.error : ''}</div>
|
||
`
|
||
} else {
|
||
tcWrap.innerHTML = `<div class="tc">🎯 ${n.case} <span style="color:var(--muted)">待执行</span></div>`
|
||
}
|
||
}
|
||
|
||
// 真实 DOM 数据
|
||
const dataWrap = $('#d-data-wrap')
|
||
dataWrap.innerHTML = ''
|
||
const r = state.nodeResults[id]
|
||
if (r && (r.dom || r.input || r.output)) {
|
||
const d = r.dom || {}
|
||
const failCls = r.status === 'fail' ? 'fail' : ''
|
||
const inputKV = r.input ? Object.entries(r.input).map(([k, v]) => `<b>${escapeHtml(k)}</b><span>${escapeHtml(JSON.stringify(v))}</span>`).join('') : ''
|
||
const outputKV = r.output ? Object.entries(r.output).map(([k, v]) => {
|
||
const val = typeof v === 'object' ? JSON.stringify(v) : String(v)
|
||
return `<b>${escapeHtml(k)}</b><span>${escapeHtml(val)}</span>`
|
||
}).join('') : ''
|
||
// 业务结果格式化(AUC/KS/PSI/求交率/计费金额/审计勾选)
|
||
const metricsHtml = renderMetrics(r.output?.metrics)
|
||
const checksHtml = renderChecks(r.output?.checks)
|
||
const priceHtml = renderPrice(r.output)
|
||
const ctxKV = r.ctxSnapshot ? Object.entries(r.ctxSnapshot).filter(([k, v]) => v && k !== 'runId').map(([k, v]) =>
|
||
`<b>${escapeHtml(k)}</b><span style="color:#79c0ff">${escapeHtml(String(v))}</span>`
|
||
).join('') : ''
|
||
dataWrap.innerHTML = `
|
||
${r.input ? `<div class="real-data"><div class="name">↑ 入参(来自 ctx)</div><div class="kv">${inputKV || '<b>—</b><span>—</span>'}</div></div>` : ''}
|
||
${r.output ? `<div class="real-data"><div class="name">↓ 产出(注入 ctx)</div><div class="kv">${outputKV || '<b>—</b><span>—</span>'}</div></div>` : ''}
|
||
${metricsHtml}
|
||
${checksHtml}
|
||
${priceHtml}
|
||
${ctxKV ? `<div class="real-data"><div class="name">◆ 当前 ctx</div><div class="kv">${ctxKV}</div></div>` : ''}
|
||
${(r.actionSteps && r.actionSteps.length) ? renderActionSteps(r.actionSteps) : ''}
|
||
<div class="real-data ${failCls}">
|
||
<div class="name">◆ Chrome DOM</div>
|
||
<div class="kv">
|
||
<b>URL</b><span>${escapeHtml((d.url || '').replace('http://localhost:5173', ''))}</span>
|
||
<b>标题</b><span>${escapeHtml(d.title || '—')}</span>
|
||
<b>行</b><span>${d.rowCount ?? '—'}</span>
|
||
<b>按钮</b><span>${d.btnCount ?? '—'}</span>
|
||
<b>导航</b><span>${escapeHtml(d.activeMenu || '—')}</span>
|
||
</div>
|
||
${d.firstRow ? `<div class="first-row">${escapeHtml(d.firstRow)}</div>` : ''}
|
||
${d.error ? `<div class="first-row" style="color:var(--fail)">⚠ ${escapeHtml(d.error)}</div>` : ''}
|
||
</div>
|
||
${(r.actionSteps && r.actionSteps.length) ? renderActionSteps(r.actionSteps) : ''}
|
||
`
|
||
} else if (n.data) {
|
||
// 静态预览
|
||
dataWrap.innerHTML = `
|
||
<div class="real-data">
|
||
<div class="name">◆ 预定义预览</div>
|
||
<div class="kv">
|
||
<b>名称</b><span>${escapeHtml(n.data.name || '—')}</span>
|
||
<b>预览</b><span>${escapeHtml((n.data.preview || '').split('\\n')[0])}</span>
|
||
</div>
|
||
</div>
|
||
`
|
||
}
|
||
|
||
// 截图缩略图
|
||
const shotWrap = $('#d-shot-wrap')
|
||
shotWrap.innerHTML = ''
|
||
const shotUrl = r?.dom?.shotUrl || r?.data?.shotUrl
|
||
if (r && shotUrl) {
|
||
const bytes = (r.dom?.shotBytes || r.data?.shotBytes || 0)
|
||
shotWrap.innerHTML = `
|
||
<div class="shot-thumb" onclick="openShot('${shotUrl}')">
|
||
<img src="${shotUrl}?_t=${Date.now()}" alt="节点截图">
|
||
<div class="shot-meta">
|
||
<span>${(bytes / 1024).toFixed(1)} KB · ${r.ms}ms</span>
|
||
<span>点击放大 →</span>
|
||
</div>
|
||
</div>
|
||
`
|
||
}
|
||
|
||
// 上游 / 下游数据流
|
||
const flowWrap = $('#d-flow-wrap')
|
||
flowWrap.innerHTML = ''
|
||
const ins = g.edges.filter((e) => e.to === id)
|
||
const outs = g.edges.filter((e) => e.from === id)
|
||
if (ins.length || outs.length) {
|
||
const lines = []
|
||
if (ins.length) {
|
||
lines.push('<div class="row"><b>↑ 入站:</b></div>')
|
||
ins.forEach((e) => {
|
||
const k = state.edgeKinds[e.kind || 'request']
|
||
const src = g.nodes.find((x) => x.id === e.from)
|
||
lines.push(`<div class="row" style="padding-left:6px"><span style="display:inline-block;width:8px;height:8px;border-radius:50%;background:${k?.color || '#3d4856'};margin-right:6px"></span>${e.label} ← ${src.icon || ''} ${src.label}</div>`)
|
||
})
|
||
}
|
||
if (outs.length) {
|
||
lines.push('<div class="row" style="margin-top:4px"><b>↓ 出站:</b></div>')
|
||
outs.forEach((e) => {
|
||
const k = state.edgeKinds[e.kind || 'request']
|
||
const dst = g.nodes.find((x) => x.id === e.to)
|
||
lines.push(`<div class="row" style="padding-left:6px"><span style="display:inline-block;width:8px;height:8px;border-radius:50%;background:${k?.color || '#3d4856'};margin-right:6px"></span>${e.label} → ${dst.icon || ''} ${dst.label}</div>`)
|
||
})
|
||
}
|
||
flowWrap.innerHTML = lines.join('')
|
||
}
|
||
|
||
$$('.node').forEach((nd) => nd.classList.toggle('selected', nd.dataset.id === id))
|
||
$$('.edge').forEach((ed) => ed.classList.toggle('highlight', ed.dataset.from === id || ed.dataset.to === id))
|
||
$$('.edge-tag').forEach((tg) => {
|
||
const isRelated = tg.dataset.from === id || tg.dataset.to === id
|
||
tg.style.opacity = isRelated ? '1' : '0.55'
|
||
})
|
||
}
|
||
|
||
function escapeHtml(s) { return String(s == null ? '' : s).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>') }
|
||
|
||
// 节点「白话解读」:用大白话解释这一步的数据状况;若本次演示已跑过该节点,附上实测结果
|
||
function renderNarrative(n) {
|
||
const wrap = $('#d-narrative')
|
||
if (!wrap) return
|
||
if (!n || !n.narrative) { wrap.innerHTML = ''; return }
|
||
const r = state.nodeResults[n.id]
|
||
let measured = ''
|
||
if (r && r.output && typeof r.output === 'object') {
|
||
const o = r.output
|
||
const bits = []
|
||
if (o.status) bits.push('状态:' + o.status)
|
||
if (typeof o.amount === 'number') bits.push('金额:¥' + o.amount.toLocaleString())
|
||
if (o.resultHash) bits.push('结果指纹:' + String(o.resultHash).slice(0, 18) + '…')
|
||
if (o.intact !== undefined) bits.push(o.intact ? '哈希链完整 ✔' : '哈希链断裂 ✘')
|
||
if (o.bothSigned) bits.push('双方已签 ✔')
|
||
if (o.taskNo) bits.push('沙盒:' + o.taskNo)
|
||
if (bits.length) measured = `<div class="narr-measured">📌 实测:${bits.join(' · ')}</div>`
|
||
} else if (r && r.status === 'fail') {
|
||
measured = `<div class="narr-measured fail">📌 本次演示该节点失败:${(r.error || '').slice(0, 90)}</div>`
|
||
} else if (r && r.status === 'pass') {
|
||
measured = `<div class="narr-measured">📌 本次演示已通过</div>`
|
||
}
|
||
const hint = r ? '' : '<div class="narr-hint">点「启动」跑真实链路后,这里会补上本次实测数据。</div>'
|
||
wrap.innerHTML = `<div class="narr-title">📖 数据状况 · 白话解读</div><div class="narr-body">${escapeHtml(n.narrative)}</div>${measured}${hint}`
|
||
}
|
||
|
||
const ACTION_ICONS = { pickSpace: '🏷️', search: '🔍', selectFilter: '🔽', openCreate: '➕', fillForm: '📝', save: '💾', toast: '💬', rowAction: '🖱️', prompt: '✔️', shot: '📸', openDetail: '🔎', wait: '⏱️' }
|
||
|
||
// 业务指标卡片(AUC/KS/PSI/AUC-求交率/训练轮次等)
|
||
function renderMetrics(m) {
|
||
if (!m || typeof m !== 'object') return ''
|
||
const items = []
|
||
if (typeof m.auc === 'number') items.push(['AUC', m.auc.toFixed(3)])
|
||
if (typeof m.ks === 'number') items.push(['KS', m.ks.toFixed(2)])
|
||
if (typeof m.psi === 'number') items.push(['PSI', m.psi.toFixed(2)])
|
||
if (typeof m.precision === 'number') items.push(['Precision', m.precision.toFixed(2)])
|
||
if (typeof m.recall === 'number') items.push(['Recall', m.recall.toFixed(2)])
|
||
if (typeof m.f1 === 'number') items.push(['F1', m.f1.toFixed(2)])
|
||
if (m.scoredUsers) items.push(['评分用户', m.scoredUsers.toLocaleString()])
|
||
if (m.highRisk !== undefined) items.push(['高风险', m.highRisk.toLocaleString()])
|
||
if (m.midRisk !== undefined) items.push(['中风险', m.midRisk.toLocaleString()])
|
||
if (m.lowRisk !== undefined) items.push(['低风险', m.lowRisk.toLocaleString()])
|
||
if (m.totalA) items.push(['A 集合', m.totalA.toLocaleString()])
|
||
if (m.totalB) items.push(['B 集合', m.totalB.toLocaleString()])
|
||
if (m.intersect) items.push(['交集', m.intersect.toLocaleString()])
|
||
if (m.intersectRate) items.push(['求交率', m.intersectRate])
|
||
if (m.unionCardinality) items.push(['并集基', m.unionCardinality.toLocaleString()])
|
||
if (m.parties) items.push(['参与方数', m.parties])
|
||
if (m.rounds) items.push(['训练轮次', m.rounds])
|
||
if (m.perPartyRows) items.push(['各方样本', m.perPartyRows.join('+')])
|
||
if (m.convergenceRounds) items.push(['收敛轮次', m.convergenceRounds])
|
||
if (m.finalAuc !== undefined) items.push(['联合 AUC', m.finalAuc.toFixed(3)])
|
||
if (m.finalKs !== undefined) items.push(['联合 KS', m.finalKs.toFixed(2)])
|
||
if (m.timeTotal) items.push(['总耗时', m.timeTotal])
|
||
if (m.secureAggMode) items.push(['安全聚合', m.secureAggMode])
|
||
if (m.mode) items.push(['模式', m.mode])
|
||
if (m.topFeatures && m.topFeatures.length) items.push(['Top 特征', m.topFeatures.slice(0, 3).map((f) => f[0]).join(', ')])
|
||
if (!items.length) return ''
|
||
const html = items.map(([k, v]) => `<div class="metric"><span class="mk">${escapeHtml(k)}</span><span class="mv">${escapeHtml(String(v))}</span></div>`).join('')
|
||
return `<div class="real-data metrics-card"><div class="name">📊 真实业务结果</div><div class="metrics">${html}</div></div>`
|
||
}
|
||
|
||
// 审计勾选清单
|
||
function renderChecks(checks) {
|
||
if (!Array.isArray(checks) || !checks.length) return ''
|
||
const html = checks.map((c) => `<li>${escapeHtml(c)}</li>`).join('')
|
||
return `<div class="real-data checks-card"><div class="name">🛡️ 审计核验 · 4/4 PASS</div><ul class="checks">${html}</ul></div>`
|
||
}
|
||
|
||
// 计费高亮(金额大字号 + 单价/数量)
|
||
function renderPrice(out) {
|
||
if (!out || typeof out.amount !== 'number') return ''
|
||
return `<div class="real-data price-card"><div class="name">💰 结算凭证</div><div class="price-block">
|
||
<div class="big">¥ ${out.amount.toLocaleString()}</div>
|
||
<div class="meta">${escapeHtml(out.currency || 'CNY')} · 单价 ¥${out.unit} × ${out.qty.toLocaleString()}(${escapeHtml(out.scenario || '')})</div>
|
||
</div></div>`
|
||
}
|
||
|
||
function renderActionSteps(steps) {
|
||
if (!steps || !steps.length) return ''
|
||
const items = steps.map((s) => {
|
||
const ic = ACTION_ICONS[s.type] || '·'
|
||
const ok = s.status === 'ok'
|
||
const err = s.error ? `<div class="step-err">⚠ ${escapeHtml(s.error)}</div>` : ''
|
||
const shot = s.file ? `<a class="step-shot" href="${s.file}" target="_blank">📸 截图</a>` : ''
|
||
let meta = ''
|
||
if (s.fields) meta = `<div class="step-meta">字段:${escapeHtml(s.fields.join(', '))}</div>`
|
||
else if (s.keyword) meta = `<div class="step-meta">关键字:<code>${escapeHtml(s.keyword)}</code></div>`
|
||
else if (s.toast) meta = `<div class="step-meta">提示:<code>${escapeHtml(s.toast)}</code></div>`
|
||
else if (s.space) meta = `<div class="step-meta">空间:<code>${escapeHtml(s.space)}</code></div>`
|
||
else if (s.row) meta = `<div class="step-meta">${escapeHtml(s.row)} → ${escapeHtml(s.action)}</div>`
|
||
return `<li class="step ${ok ? 'ok' : 'fail'}">
|
||
<span class="step-ic">${ic}</span>
|
||
<span class="step-num">${s.seq}</span>
|
||
<span class="step-desc">${escapeHtml(s.desc)}</span>
|
||
<span class="step-ms">${s.ms}ms</span>
|
||
${shot}
|
||
${meta}
|
||
${err}
|
||
</li>`
|
||
}).join('')
|
||
return `<div class="real-data"><div class="name">▶ 模拟操作 (${steps.length} 步)</div><ol class="steps">${items}</ol></div>`
|
||
}
|
||
|
||
function openShot(url) {
|
||
$('#shot-modal-img').src = url + '?_t=' + Date.now()
|
||
$('#shot-modal').classList.add('open')
|
||
}
|
||
$('#shot-modal').addEventListener('click', () => $('#shot-modal').classList.remove('open'))
|
||
|
||
// 节点详情:让服务端起一个真实有头 Chrome 窗口(带登录态)跳到该节点的业务全景页
|
||
async function openNodeInBrowser(path) {
|
||
const btn = document.querySelector('#d-open .open-btn')
|
||
if (btn) { btn.disabled = true; btn.textContent = '⏳ 正在打开浏览器…' }
|
||
try {
|
||
const r = await fetch('/api/open-node', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ path }) })
|
||
const j = await r.json()
|
||
if (!j.ok) throw new Error(j.error || '打开失败')
|
||
toast('已在浏览器打开:' + path)
|
||
} catch (e) {
|
||
toast('打开失败:' + e.message)
|
||
} finally {
|
||
if (btn) { btn.disabled = false; btn.textContent = '🔵 在浏览器打开数据页' }
|
||
}
|
||
}
|
||
|
||
let toastTimer = null
|
||
function toast(msg) {
|
||
let el = document.getElementById('toast')
|
||
if (!el) {
|
||
el = document.createElement('div')
|
||
el.id = 'toast'
|
||
el.className = 'toast'
|
||
document.body.appendChild(el)
|
||
}
|
||
el.textContent = msg
|
||
el.classList.add('show')
|
||
clearTimeout(toastTimer)
|
||
toastTimer = setTimeout(() => el.classList.remove('show'), 2600)
|
||
}
|
||
|
||
function resetDetail() {
|
||
$('#d-name').textContent = '选中节点查看'
|
||
$('#d-meta').textContent = '点击 DAG 上的任意节点'
|
||
$('#d-lane').textContent = '—'
|
||
$('#d-stage').textContent = '—'
|
||
$('#d-narrative').innerHTML = ''
|
||
$('#d-route-wrap').innerHTML = ''
|
||
$('#d-open').innerHTML = ''
|
||
$('#d-tc-wrap').innerHTML = ''
|
||
$('#d-data-wrap').innerHTML = ''
|
||
$('#d-flow-wrap').innerHTML = ''
|
||
$('#d-shot-wrap').innerHTML = ''
|
||
$$('.edge').forEach((ed) => ed.classList.remove('highlight'))
|
||
$$('.edge-tag').forEach((tg) => tg.style.opacity = '1')
|
||
}
|
||
|
||
async function startRun() {
|
||
if (state.running) return
|
||
const g = state.graphs.find((x) => x.id === state.current)
|
||
state.running = true
|
||
state.nodeResults = {}
|
||
state.doneCount = 0
|
||
$('#run').disabled = true
|
||
$('#stop').disabled = false
|
||
$('#log').innerHTML = ''
|
||
logLine(`▷ 启动图${g.no} · ${g.title} · 共 ${g.nodes.length} 个节点(真实 Chrome)`, 'ok')
|
||
logLine(`▷ 同步打开 Google Chrome → http://localhost:5173`, 'ok')
|
||
logLine('─────────────────────────────────────────────')
|
||
|
||
for (const n of g.nodes) {
|
||
const nd = document.querySelector(`.node[data-id="${n.id}"]`)
|
||
if (!nd) continue
|
||
nd.setAttribute('class', 'node idle')
|
||
nd.querySelector('rect.halo').setAttribute('opacity', '0')
|
||
nd.querySelector('circle.state-dot').setAttribute('fill', '#3d4856')
|
||
nd.querySelector('circle.state-dot').style.color = '#3d4856'
|
||
const dp = document.getElementById(`dp-${n.id}`)
|
||
if (dp) dp.textContent = (n.data?.preview || '').split('\n')[0].slice(0, 26)
|
||
}
|
||
$$('.edge').forEach((ed) => ed.classList.remove('flow', 'flow-fast', 'hot'))
|
||
$$('.edge-tag').forEach((tg) => tg.querySelector('rect.edge-label-box')?.classList.remove('live'))
|
||
|
||
$('#prog').style.width = '0%'
|
||
|
||
try {
|
||
const openChrome = document.getElementById('open-yes')?.checked !== false
|
||
const r = await fetch('/api/run', {
|
||
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
||
body: JSON.stringify({ seq: g.id, open: openChrome })
|
||
})
|
||
if (!r.ok) {
|
||
const j = await r.json().catch(() => ({}))
|
||
throw new Error(j.error || `HTTP ${r.status}`)
|
||
}
|
||
const reader = r.body.getReader()
|
||
const decoder = new TextDecoder()
|
||
let buf = ''
|
||
state.totalNodes = g.nodes.length
|
||
while (true) {
|
||
const { value, done: rdone } = await reader.read()
|
||
if (rdone) break
|
||
buf += decoder.decode(value, { stream: true })
|
||
const events = buf.split('\n\n')
|
||
buf = events.pop()
|
||
for (const ev of events) {
|
||
const lines = ev.split('\n')
|
||
let event = 'message', data = ''
|
||
for (const l of lines) {
|
||
if (l.startsWith('event:')) event = l.slice(6).trim()
|
||
else if (l.startsWith('data:')) data += l.slice(5).trim()
|
||
}
|
||
if (!data) continue
|
||
try { handleEvent(event, JSON.parse(data)) } catch (e) { /* ignore */ }
|
||
}
|
||
}
|
||
} catch (e) {
|
||
logLine(`✘ 启动失败:${e.message}`, 'err')
|
||
} finally {
|
||
state.running = false
|
||
$('#run').disabled = false
|
||
$('#stop').disabled = true
|
||
$$('.edge').forEach((ed) => ed.classList.remove('flow', 'flow-fast', 'hot'))
|
||
$$('.edge-tag').forEach((tg) => tg.querySelector('rect.edge-label-box')?.classList.remove('live'))
|
||
$$('.node .halo').forEach((h) => h.setAttribute('opacity', '0'))
|
||
logLine('─────────────────────────────────────────────')
|
||
logLine(`✔ 演示结束`, 'ok')
|
||
}
|
||
}
|
||
|
||
function handleEvent(event, data) {
|
||
if (event === 'log') logLine(data.msg || '')
|
||
else if (event === 'start') {
|
||
state.totalNodes = data.total
|
||
logLine(`▷ 收到 SSE · 共 ${data.total} 个节点`, 'ok')
|
||
}
|
||
else if (event === 'node-start') onNodeStart(data)
|
||
else if (event === 'node-done') onNodeDone(data)
|
||
else if (event === 'action-step') onActionStep(data)
|
||
else if (event === 'aborted') logLine(`⊘ 用户中止 · 已完成 ${data.done}/${data.total}`, 'warn')
|
||
else if (event === 'done') {
|
||
const s = data.summary || {}
|
||
logLine(`✔ 完成 · 通过 ${s.pass||0} · 失败 ${s.fail||0} · 用时 ${((data.elapsedMs||0)/1000).toFixed(1)}s`, 'ok')
|
||
paintFinalSummary(s, data.total)
|
||
if (data.flowCtx) paintFlowSummary(data.flowCtx)
|
||
}
|
||
}
|
||
|
||
function paintFlowSummary(ctx) {
|
||
const wrap = $('#flow-summary')
|
||
const grid = $('#flow-grid')
|
||
if (!ctx || !wrap || !grid) return
|
||
const labels = [
|
||
['demandId', '需求 ID'], ['demandCode', '需求编号'],
|
||
['contractId', '合约 ID'], ['contractCode', '合约编号'],
|
||
['connectorId', '连接器 ID'],
|
||
['sandboxId', '沙盒 ID'], ['sandboxName', '沙盒名称'],
|
||
['jobId', '执行任务 ID'], ['settlementId', '结算 ID'],
|
||
['auditId', '审计 ID']
|
||
]
|
||
// 业务场景标题(动态)
|
||
const titleEl = wrap.querySelector('.flow-title')
|
||
if (titleEl && ctx.scenario) {
|
||
const sc = { risk: '🏦 信贷违约预测(银行风控)', psi: '🛡️ 跨机构黑名单 OPRF 安全求交', fl: '🤝 三行机构联合反欺诈建模' }[ctx.scenario]
|
||
if (sc) titleEl.textContent = `◆ ${sc} · 真实业务链路摘要`
|
||
}
|
||
grid.innerHTML = labels.map(([k, label]) => {
|
||
const v = ctx[k]
|
||
const valCls = v ? 'v' : 'v empty'
|
||
const valTxt = v ? v : '— 未触发'
|
||
return `<div class="flow-cell"><span class="k">${label}</span><span class="${valCls}" title="${escapeHtml(valTxt)}">${escapeHtml(valTxt)}</span></div>`
|
||
}).join('')
|
||
wrap.style.display = 'block'
|
||
}
|
||
|
||
function onNodeStart(d) {
|
||
state.liveNode = d.id
|
||
state.doneCount = d.index
|
||
const g = state.graphs.find((x) => x.id === state.current)
|
||
const nd = document.querySelector(`.node[data-id="${d.id}"]`)
|
||
if (nd) {
|
||
nd.setAttribute('class', 'node activating')
|
||
nd.querySelector('rect.halo').setAttribute('opacity', '1')
|
||
nd.querySelector('circle.state-dot').setAttribute('fill', '#d29922')
|
||
nd.querySelector('circle.state-dot').style.color = '#d29922'
|
||
}
|
||
const incoming = g.edges.filter((e) => e.to === d.id)
|
||
const outgoing = g.edges.filter((e) => e.from === d.id)
|
||
$$('.edge.hot').forEach((ed) => ed.classList.remove('hot'))
|
||
incoming.forEach((e) => {
|
||
const id = EDGE_ID(e.from, e.to)
|
||
const el2 = document.getElementById(id)
|
||
if (el2) { el2.classList.add('hot', 'flow-fast'); state.liveEdges.add(id) }
|
||
document.querySelector(`.edge-tag[data-from="${e.from}"][data-to="${e.to}"] rect.edge-label-box`)?.classList.add('live')
|
||
})
|
||
outgoing.forEach((e) => {
|
||
const id = EDGE_ID(e.from, e.to)
|
||
const el2 = document.getElementById(id)
|
||
if (el2) { el2.classList.add('flow'); state.liveEdges.add(id) }
|
||
})
|
||
logLine(`▶ [${d.index + 1}/${d.total}] ${d.lane} → ${d.label} (${d.route})`, 'warn')
|
||
scrollNodeIntoView(d.id)
|
||
$('#prog').style.width = `${(d.index / d.total) * 100}%`
|
||
}
|
||
|
||
function onActionStep(d) {
|
||
// d: { id, seq, type, desc, status, ms, keyword?, toast?, file?, ... }
|
||
if (!state.nodeResults[d.id]) state.nodeResults[d.id] = { id: d.id }
|
||
if (!state.nodeResults[d.id].actionSteps) state.nodeResults[d.id].actionSteps = []
|
||
const idx = state.nodeResults[d.id].actionSteps.findIndex((s) => s.seq === d.seq)
|
||
if (idx >= 0) state.nodeResults[d.id].actionSteps[idx] = d
|
||
else state.nodeResults[d.id].actionSteps.push(d)
|
||
// 更新侧栏(如果当前选中节点)
|
||
if (state.selectedNode === d.id) selectNode(d.id)
|
||
}
|
||
|
||
function onNodeDone(d) {
|
||
state.nodeResults[d.id] = d // 用 id 作 key(之前用 tc 但 tc 不一定唯一)
|
||
// 节点激活环数 = 已完成的 step 数(视觉反馈)
|
||
const r = state.nodeResults[d.id]
|
||
if (r.actionSteps && r.actionSteps.length) {
|
||
const badge = document.getElementById(`ab-${d.id}`)
|
||
if (badge) badge.textContent = r.actionSteps.length
|
||
}
|
||
const nd = document.querySelector(`.node[data-id="${d.id}"]`)
|
||
if (nd) {
|
||
nd.setAttribute('class', 'node ' + d.status)
|
||
nd.querySelector('rect.halo').setAttribute('opacity', '0')
|
||
nd.querySelector('circle.state-dot').setAttribute('fill', d.status === 'pass' ? '#2ea043' : '#cf4757')
|
||
nd.querySelector('circle.state-dot').style.color = d.status === 'pass' ? '#2ea043' : '#cf4757'
|
||
// 更新节点 data preview 为真实数据(截断)
|
||
const dp = document.getElementById(`dp-${d.id}`)
|
||
if (dp && d.data) {
|
||
const sample = d.data.title ? d.data.title.slice(0, 22) : (d.data.firstRow ? d.data.firstRow.slice(0, 22) : d.data.url?.split('?')[0] || '')
|
||
dp.textContent = sample
|
||
}
|
||
}
|
||
const g = state.graphs.find((x) => x.id === state.current)
|
||
const outgoing = g.edges.filter((e) => e.from === d.id)
|
||
outgoing.forEach((e) => {
|
||
const id = EDGE_ID(e.from, e.to)
|
||
const el2 = document.getElementById(id)
|
||
if (el2) el2.classList.remove('hot')
|
||
})
|
||
const tag = d.status === 'pass' ? 'ok' : d.status === 'fail' ? 'err' : 'warn'
|
||
const sym = d.status === 'pass' ? '✔' : d.status === 'fail' ? '✘' : '⊘'
|
||
const realTitle = d.data?.title ? ` · "${d.data.title}"` : ''
|
||
const realRows = d.data?.rowCount != null ? ` · ${d.data.rowCount} 行` : ''
|
||
logLine(` ${sym} ${d.id} · ${d.route} · ${d.ms}ms${realRows}${realTitle}${d.error ? ' · ' + d.error : ''}`, tag)
|
||
state.doneCount = d.index + 1
|
||
$('#prog').style.width = `${(state.doneCount / state.totalNodes) * 100}%`
|
||
paintLiveSummary()
|
||
if (state.selected === d.id) selectNode(d.id)
|
||
}
|
||
|
||
function paintLiveSummary() {
|
||
const g = state.graphs.find((x) => x.id === state.current)
|
||
let pass = 0, fail = 0
|
||
for (const k of Object.keys(state.nodeResults)) {
|
||
const r = state.nodeResults[k]
|
||
if (r.status === 'pass') pass++
|
||
else if (r.status === 'fail') fail++
|
||
}
|
||
const c = $('#summary')
|
||
c.innerHTML = ''
|
||
c.appendChild(el('span', { class: 'pill pass', text: `✔ 通过 ${pass}` }))
|
||
c.appendChild(el('span', { class: 'pill fail', text: `✘ 失败 ${fail}` }))
|
||
c.appendChild(el('span', { class: 'pill run', text: `⏳ ${state.liveNode ? '执行中…' : '已完成'}` }))
|
||
c.appendChild(el('span', { class: 'pill idle', text: `∑ ${g.nodes.length} 节点` }))
|
||
}
|
||
|
||
function paintFinalSummary(s, total) {
|
||
const c = $('#summary')
|
||
c.innerHTML = ''
|
||
c.appendChild(el('span', { class: 'pill pass', text: `✔ 通过 ${s.pass||0}` }))
|
||
c.appendChild(el('span', { class: 'pill fail', text: `✘ 失败 ${s.fail||0}` }))
|
||
c.appendChild(el('span', { class: 'pill idle', text: `∑ ${total} 节点` }))
|
||
}
|
||
|
||
function scrollNodeIntoView(id) {
|
||
const p = state.pos?.[id]
|
||
if (!p) return
|
||
const wrap = $('#wrap')
|
||
const rect = wrap.getBoundingClientRect()
|
||
const svg = $('#dag')
|
||
const svgRect = svg.getBoundingClientRect()
|
||
const scale = svgRect.width / svg.viewBox.baseVal.width
|
||
const px = p.cx * scale
|
||
const py = p.cy * scale
|
||
const right = px > rect.width - 200
|
||
const down = py > rect.height - 200
|
||
if (right || down) {
|
||
wrap.scrollTo({
|
||
left: right ? wrap.scrollLeft + (px - rect.width / 2) : wrap.scrollLeft,
|
||
top: down ? wrap.scrollTop + (py - rect.height / 2) : wrap.scrollTop,
|
||
behavior: 'smooth'
|
||
})
|
||
}
|
||
}
|
||
|
||
async function stopRun() {
|
||
await fetch('/api/stop', { method: 'POST' })
|
||
logLine('⊘ 已发送停止信号…', 'warn')
|
||
}
|
||
|
||
$('#run').addEventListener('click', startRun)
|
||
$('#stop').addEventListener('click', stopRun)
|
||
loadAll()
|
||
setInterval(async () => {
|
||
const r = await fetch('/api/status').then((r) => r.json()).catch(() => null)
|
||
if (r?.env) paintEnv(r.env)
|
||
}, 5000)
|
||
</script>
|
||
</body>
|
||
</html> |