demo(scql): 流程图线条清理,去除跨界椭圆弧 + 边端点对齐节点
用户反馈:SCQL 流程图线条混乱。原因: - 原 PSI 阶段有两条跨界虚线(145→1175→145)形成跨整个宽度的椭圆弧 ,与 ECDH-PSI 大节点重叠,造成视觉混乱 - 多个边端点设在节点中心而非边缘,穿越节点内部 修法(重写 buildFlowSvg 边和位置): - 删 e2ba / e2ab 两条跨界椭圆弧 - PSI 节点内嵌副标「双方行序对齐 · 只看到交集 · 盲化点交换 ↔」表达握手语义 - 所有边端点对齐节点边界:e1a (side→handle) 水平直线;e2a (handle→PSI) 短下直线;e3 (PSI→COMPUTE) 紧邻短线;e4a (COMPUTE→reveal) 斜线;e4b (COMPUTE→noreveal) 虚线斜线 - e4b 改虚线强调「不揭示」语义 Playwright 实测:6 条边端点全部对齐节点边界,无节点穿越,stage=5 全激活无 JS 报错。
This commit is contained in:
1 parent
960b2d7301
commit
fc5e3cf9bd
1 file changed
+37
-32
+37
-32
@@ -244,7 +244,6 @@ function buildFlowSvg() {
|
||||
const aliceBg = get('--alice-bg');
|
||||
const bobBg = get('--bob-bg');
|
||||
const panel = get('--panel');
|
||||
const panel2 = get('--panel-2)');
|
||||
|
||||
let s = `<defs>
|
||||
<marker id="arrA" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" fill="${alice}"/></marker>
|
||||
@@ -267,64 +266,70 @@ function buildFlowSvg() {
|
||||
s += `<text x="1100" y="22" text-anchor="middle" font-size="13" font-weight="700" fill="${bob}">🛒 shop 电商</text>`;
|
||||
s += `<text x="660" y="22" text-anchor="middle" font-size="13" font-weight="700" fill="${dim}">⚙️ SCQL 引擎</text>`;
|
||||
|
||||
// 节点 y 坐标
|
||||
const Y_INPUT = 88;
|
||||
const Y_PSI = 170;
|
||||
const Y_COMPUTE= 218;
|
||||
const Y_REVEAL = 260;
|
||||
const cx = 660;
|
||||
|
||||
// 两侧 site.put 节点
|
||||
const sides = [
|
||||
{ x: 80, color: alice, label: 'uid / city / age', revealStage: 1 },
|
||||
{ x: 80, color: alice, label: 'uid / city / age', revealStage: 1 },
|
||||
{ x: 1240, color: bob, label: 'uid / amount', revealStage: 1 },
|
||||
];
|
||||
sides.forEach(side => {
|
||||
s += `<g class="flow-side" data-reveal-stage="${side.revealStage}">`;
|
||||
s += `<rect x="${side.x - 65}" y="60" width="130" height="56" rx="8" fill="${side.color}" opacity="0.18" stroke="${side.color}" stroke-width="1.5" class="flow-side-bg"/>`;
|
||||
s += `<text x="${side.x}" y="84" text-anchor="middle" font-size="14" font-weight="700" fill="${side.color}">📥 site.put(df)</text>`;
|
||||
s += `<text x="${side.x}" y="102" text-anchor="middle" font-size="10" fill="${dim}">${side.label}</text>`;
|
||||
s += `<rect x="${side.x - 65}" y="${Y_INPUT - 28}" width="130" height="56" rx="8" fill="${side.color}" opacity="0.18" stroke="${side.color}" stroke-width="1.5" class="flow-side-bg"/>`;
|
||||
s += `<text x="${side.x}" y="${Y_INPUT - 4}" text-anchor="middle" font-size="14" font-weight="700" fill="${side.color}">📥 site.put(df)</text>`;
|
||||
s += `<text x="${side.x}" y="${Y_INPUT + 14}" text-anchor="middle" font-size="10" fill="${dim}">${side.label}</text>`;
|
||||
s += `</g>`;
|
||||
});
|
||||
|
||||
// 中央 SCQL handle 节点
|
||||
const cx = 660, cy = 88;
|
||||
s += `<g class="flow-node" data-id="HANDLE" data-reveal-stage="1">`;
|
||||
s += `<rect x="${cx-90}" y="${cy-28}" width="180" height="56" rx="10" fill="${panel}" stroke="${border}" stroke-width="1.5" class="flow-node-bg"/>`;
|
||||
s += `<text x="${cx}" y="${cy-7}" text-anchor="middle" font-size="13" font-weight="600" fill="${dim}">🔒 secret handle</text>`;
|
||||
s += `<text x="${cx}" y="${cy+13}" text-anchor="middle" font-size="10" fill="${faint}">本地密文引用(不出域)</text>`;
|
||||
s += `<rect x="${cx-90}" y="${Y_INPUT - 28}" width="180" height="56" rx="10" fill="${panel}" stroke="${border}" stroke-width="1.5" class="flow-node-bg"/>`;
|
||||
s += `<text x="${cx}" y="${Y_INPUT - 4}" text-anchor="middle" font-size="13" font-weight="600" fill="${dim}">🔒 secret handle</text>`;
|
||||
s += `<text x="${cx}" y="${Y_INPUT + 14}" text-anchor="middle" font-size="10" fill="${faint}">本地密文引用(不出域)</text>`;
|
||||
s += `</g>`;
|
||||
|
||||
// 第 2 层:PSI 大节点
|
||||
const psiY = 160;
|
||||
// 第 2 层:ECDH-PSI 大节点(内嵌握手 ↔ 标识,避免跨界椭圆弧)
|
||||
s += `<g class="flow-node" data-id="PSI" data-reveal-stage="2">`;
|
||||
s += `<rect x="200" y="${psiY-22}" width="920" height="44" rx="22" fill="rgba(77,139,255,0.12)" stroke="${alice}" stroke-width="2" class="flow-node-bg"/>`;
|
||||
s += `<text x="660" y="${psiY-9}" text-anchor="middle" font-size="10" fill="${dim}">双方行序对齐 · 只看到交集(盲化点交换)</text>`;
|
||||
s += `<text x="660" y="${psiY+5}" text-anchor="middle" font-size="14" font-weight="700" fill="${alice}">🤝 ECDH-PSI · nax.data.intersect</text>`;
|
||||
s += `<text x="1100" y="${psiY+5}" text-anchor="middle" font-size="11" fill="${alice}" id="psi-count">→ ? 行命中</text>`;
|
||||
s += `<rect x="200" y="${Y_PSI - 25}" width="920" height="50" rx="25" fill="rgba(77,139,255,0.12)" stroke="${alice}" stroke-width="2" class="flow-node-bg"/>`;
|
||||
s += `<text x="660" y="${Y_PSI - 9}" text-anchor="middle" font-size="10" fill="${dim}">双方行序对齐 · 只看到交集 · 盲化点交换 ↔</text>`;
|
||||
s += `<text x="660" y="${Y_PSI + 6}" text-anchor="middle" font-size="14" font-weight="700" fill="${alice}">🤝 ECDH-PSI · nax.data.intersect</text>`;
|
||||
s += `<text x="1100" y="${Y_PSI + 6}" text-anchor="middle" font-size="11" fill="${alice}" id="psi-count">→ ? 行命中</text>`;
|
||||
s += `</g>`;
|
||||
|
||||
// 第 3 层:密文计算长条
|
||||
const cmY = 210;
|
||||
s += `<g class="flow-node" data-id="COMPUTE" data-reveal-stage="3">`;
|
||||
s += `<rect x="280" y="${cmY-20}" width="760" height="40" rx="8" fill="rgba(74,222,128,0.10)" stroke="${ok}" stroke-width="1.5" class="flow-node-bg"/>`;
|
||||
s += `<text x="660" y="${cmY+5}" text-anchor="middle" font-size="13" font-weight="600" fill="${ok}">⚙️ WHERE → 0/1 共享位 · GROUP BY city · COUNT / AVG</text>`;
|
||||
s += `<rect x="280" y="${Y_COMPUTE - 20}" width="760" height="40" rx="8" fill="rgba(74,222,128,0.10)" stroke="${ok}" stroke-width="1.5" class="flow-node-bg"/>`;
|
||||
s += `<text x="660" y="${Y_COMPUTE + 5}" text-anchor="middle" font-size="13" font-weight="600" fill="${ok}">⚙️ WHERE → 0/1 共享位 · GROUP BY city · COUNT / AVG</text>`;
|
||||
s += `</g>`;
|
||||
|
||||
// 第 4 层:reveal(左侧 → bank)+ 不向 shop 揭示(右侧虚线)
|
||||
const rvY = 258;
|
||||
s += `<g class="flow-node" data-id="REVEAL" data-reveal-stage="5">`;
|
||||
s += `<rect x="120" y="${rvY-16}" width="180" height="32" rx="6" fill="${ok}" opacity="0.18" stroke="${ok}" stroke-width="1.5" class="flow-node-bg"/>`;
|
||||
s += `<text x="210" y="${rvY+4}" text-anchor="middle" font-size="12" font-weight="600" fill="${ok}">🔓 reveal → bank</text>`;
|
||||
s += `<rect x="120" y="${Y_REVEAL - 16}" width="180" height="32" rx="6" fill="${ok}" opacity="0.18" stroke="${ok}" stroke-width="1.5" class="flow-node-bg"/>`;
|
||||
s += `<text x="210" y="${Y_REVEAL + 4}" text-anchor="middle" font-size="12" font-weight="600" fill="${ok}">🔓 reveal → bank</text>`;
|
||||
s += `</g>`;
|
||||
s += `<g class="flow-node" data-id="REVEAL_NOSHOP" data-reveal-stage="4">`;
|
||||
s += `<rect x="1020" y="${rvY-16}" width="180" height="32" rx="6" fill="${bobBg}" stroke="${bob}" stroke-width="1" stroke-dasharray="3 3" class="flow-node-bg"/>`;
|
||||
s += `<text x="1110" y="${rvY+4}" text-anchor="middle" font-size="12" fill="${bob}">🚫 不向 shop 揭示</text>`;
|
||||
s += `<rect x="1020" y="${Y_REVEAL - 16}" width="180" height="32" rx="6" fill="${bobBg}" stroke="${bob}" stroke-width="1" stroke-dasharray="3 3" class="flow-node-bg"/>`;
|
||||
s += `<text x="1110" y="${Y_REVEAL + 4}" text-anchor="middle" font-size="12" fill="${bob}">🚫 不向 shop 揭示</text>`;
|
||||
s += `</g>`;
|
||||
|
||||
// 连线(按 stage reveal 顺序)
|
||||
// 连线(端点对齐节点边界,不穿越节点)
|
||||
const edges = [
|
||||
{ id: 'e1a', d: `M145,116 C300,116 480,116 ${cx-90},116`, color: alice, marker: 'arrA', rs: 1 },
|
||||
{ id: 'e1b', d: `M${cx+90},116 C840,116 1020,116 1175,116`, color: bob, marker: 'arrB', rs: 1 },
|
||||
{ id: 'e2a', d: `M${cx},${cy+28} L${cx},${psiY-22}`, color: dim, marker: 'arrD', rs: 2 },
|
||||
{ id: 'e2ba', d: `M145,${psiY-22} C145,${psiY-50} ${W-145},${psiY-50} ${W-145},${psiY-22}`, color: alice, marker: 'arrB', rs: 2, dash: '6 4' },
|
||||
{ id: 'e2ab', d: `M${W-145},${psiY-22} C${W-145},${psiY-44} 145,${psiY-44} 145,${psiY-22}`, color: bob, marker: 'arrA', rs: 2, dash: '6 4' },
|
||||
{ id: 'e3', d: `M${cx},${psiY+22} L${cx},${cmY-20}`, color: dim, marker: 'arrD', rs: 3 },
|
||||
{ id: 'e4a', d: `M${cx-200},${cmY+20} L210,${rvY-16}`, color: ok, marker: 'arrE', rs: 5 },
|
||||
{ id: 'e4b', d: `M${cx+200},${cmY+20} L1110,${rvY-16}`, color: bob, marker: 'arrB', rs: 4 },
|
||||
// ① side → handle(直线,端点在节点边缘)
|
||||
{ id: 'e1a', d: `M145,${Y_INPUT} L${cx - 90},${Y_INPUT}`, color: alice, marker: 'arrA', rs: 1 },
|
||||
{ id: 'e1b', d: `M${cx + 90},${Y_INPUT} L1175,${Y_INPUT}`, color: bob, marker: 'arrB', rs: 1 },
|
||||
// ② handle → PSI 顶部(直线)
|
||||
{ id: 'e2a', d: `M${cx},${Y_INPUT + 28} L${cx},${Y_PSI - 25}`, color: dim, marker: 'arrD', rs: 2 },
|
||||
// ③ PSI → COMPUTE(紧邻,几乎直线)
|
||||
{ id: 'e3', d: `M${cx},${Y_PSI + 25} L${cx},${Y_COMPUTE - 20}`, color: dim, marker: 'arrD', rs: 3 },
|
||||
// ④ COMPUTE → reveal(bank,左下)
|
||||
{ id: 'e4a', d: `M${cx - 200},${Y_COMPUTE + 20} L210,${Y_REVEAL - 16}`, color: ok, marker: 'arrE', rs: 5 },
|
||||
// ⑤ COMPUTE → 不向 shop 揭示(右下,虚线)
|
||||
{ id: 'e4b', d: `M${cx + 200},${Y_COMPUTE + 20} L1110,${Y_REVEAL - 16}`, color: bob, marker: 'arrB', rs: 4, dash: '5 4' },
|
||||
];
|
||||
edges.forEach(e => {
|
||||
const dash = e.dash ? ` stroke-dasharray="${e.dash}"` : '';
|
||||
|
||||
Reference in new issue
Block a user