viz_fragment.html 57 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851
  1. <!doctype html>
  2. <html lang="zh">
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>工序五层筛选</title>
  6. <style>
  7. :root {
  8. --bg: #f8fafc;
  9. --panel: #ffffff;
  10. --panel2: #f1f5f9;
  11. --border: #e2e8f0;
  12. --fg: #0f172a;
  13. --muted: #64748b;
  14. --accent: #3b82f6;
  15. --accent2: #8b5cf6;
  16. --tag-bg: #e2e8f0;
  17. --tag-bg-active: #3b82f6;
  18. --tag-fg-active: #fff;
  19. --code: #f1f5f9;
  20. --warn: #eab308;
  21. --suggest: #8b5cf6;
  22. --inferred: #94a3b8;
  23. }
  24. * {
  25. box-sizing: border-box;
  26. }
  27. html,
  28. body {
  29. margin: 0;
  30. height: 100%;
  31. background: var(--bg);
  32. color: var(--fg);
  33. font:
  34. 13px/1.55 -apple-system,
  35. BlinkMacSystemFont,
  36. "PingFang SC",
  37. "Helvetica Neue",
  38. sans-serif;
  39. }
  40. header {
  41. display: flex;
  42. align-items: center;
  43. gap: 12px;
  44. padding: 8px 14px;
  45. border-bottom: 1px solid var(--border);
  46. background: var(--panel);
  47. position: sticky;
  48. top: 0;
  49. z-index: 5;
  50. flex-wrap: wrap;
  51. }
  52. h1 {
  53. font-size: 14px;
  54. margin: 0;
  55. font-weight: 600;
  56. }
  57. .stats {
  58. color: var(--muted);
  59. font-size: 11px;
  60. }
  61. .clear-all {
  62. margin-left: auto;
  63. font-size: 11px;
  64. color: var(--muted);
  65. cursor: pointer;
  66. padding: 4px 10px;
  67. border: 1px solid var(--border);
  68. border-radius: 4px;
  69. background: transparent;
  70. }
  71. .clear-all:hover {
  72. color: var(--fg);
  73. border-color: var(--accent);
  74. }
  75. .clear-all.active {
  76. color: var(--warn);
  77. border-color: var(--warn);
  78. }
  79. .exit-fs {
  80. margin-left: auto;
  81. font-size: 11px;
  82. color: var(--muted);
  83. cursor: pointer;
  84. padding: 4px 10px;
  85. border: 1px solid var(--border);
  86. border-radius: 4px;
  87. background: transparent;
  88. display: none;
  89. }
  90. .exit-fs:hover {
  91. color: var(--fg);
  92. border-color: var(--accent);
  93. }
  94. main {
  95. display: grid;
  96. grid-template-columns: 160px 360px 220px 320px 1fr;
  97. height: 100vh;
  98. min-width: 1480px;
  99. background: var(--bg);
  100. }
  101. section {
  102. overflow: auto;
  103. border-right: 1px solid var(--border);
  104. padding: 8px 10px;
  105. }
  106. section:last-child {
  107. border-right: none;
  108. }
  109. section.fac1 {
  110. background: var(--panel);
  111. }
  112. section.fac2 {
  113. background: #f8fafc;
  114. }
  115. section.fac3 {
  116. background: var(--panel);
  117. }
  118. section.fac4 {
  119. background: #f4f4f5;
  120. }
  121. section.detail {
  122. background: var(--panel);
  123. }
  124. .col-title {
  125. font-size: 10px;
  126. text-transform: uppercase;
  127. letter-spacing: 0.6px;
  128. color: var(--muted);
  129. margin: 2px 4px 8px;
  130. display: flex;
  131. justify-content: space-between;
  132. align-items: baseline;
  133. }
  134. .col-count {
  135. font-size: 10px;
  136. color: var(--muted);
  137. }
  138. .col-clear {
  139. font-size: 10px;
  140. color: var(--accent);
  141. cursor: pointer;
  142. display: none;
  143. }
  144. .col-clear.show {
  145. display: inline;
  146. }
  147. .item {
  148. padding: 6px 8px;
  149. border-radius: 5px;
  150. cursor: pointer;
  151. margin-bottom: 3px;
  152. border: 1px solid transparent;
  153. display: flex;
  154. justify-content: space-between;
  155. align-items: center;
  156. gap: 6px;
  157. }
  158. .item:hover:not(.disabled):not(.active) {
  159. background: var(--panel2);
  160. }
  161. .item.active {
  162. background: var(--tag-bg-active);
  163. color: var(--tag-fg-active);
  164. border-color: var(--tag-bg-active);
  165. }
  166. .item.disabled {
  167. opacity: 0.32;
  168. cursor: not-allowed;
  169. }
  170. .item-name {
  171. flex: 1;
  172. min-width: 0;
  173. font-size: 12px;
  174. white-space: nowrap;
  175. overflow: hidden;
  176. text-overflow: ellipsis;
  177. }
  178. .item-count {
  179. font-size: 10px;
  180. background: var(--bg);
  181. padding: 1px 5px;
  182. border-radius: 8px;
  183. color: var(--muted);
  184. min-width: 20px;
  185. text-align: center;
  186. flex-shrink: 0;
  187. }
  188. .item.active .item-count {
  189. background: rgba(0, 0, 0, 0.3);
  190. color: #fff;
  191. }
  192. .item-def {
  193. display: block;
  194. font-size: 10px;
  195. color: var(--muted);
  196. margin-top: 2px;
  197. line-height: 1.4;
  198. }
  199. .item.active .item-def {
  200. color: rgba(255, 255, 255, 0.85);
  201. }
  202. .item-stack {
  203. flex: 1;
  204. min-width: 0;
  205. }
  206. /* col-2 tabs */
  207. .scope-tabs {
  208. display: flex;
  209. gap: 4px;
  210. margin: 0 0 8px;
  211. border-bottom: 1px solid var(--border);
  212. padding-bottom: 5px;
  213. }
  214. .scope-tab {
  215. padding: 4px 10px;
  216. border-radius: 5px 5px 0 0;
  217. cursor: pointer;
  218. font-size: 12px;
  219. color: var(--muted);
  220. background: transparent;
  221. border: 1px solid transparent;
  222. border-bottom: none;
  223. user-select: none;
  224. }
  225. .scope-tab.active {
  226. color: var(--fg);
  227. background: var(--panel2);
  228. border-color: var(--border);
  229. }
  230. .scope-tab:hover:not(.active) {
  231. color: var(--fg);
  232. }
  233. .scope-pane {
  234. display: none;
  235. }
  236. .scope-pane.active {
  237. display: block;
  238. }
  239. .scope-meta {
  240. font-size: 10px;
  241. color: var(--muted);
  242. margin: 0 4px 8px;
  243. line-height: 1.4;
  244. }
  245. /* facets */
  246. .facet-title {
  247. margin-top: 10px;
  248. padding: 4px 6px;
  249. font-size: 11px;
  250. color: var(--muted);
  251. font-weight: 600;
  252. border-bottom: 1px solid var(--border);
  253. text-transform: uppercase;
  254. letter-spacing: 0.5px;
  255. }
  256. .facet-title:first-child {
  257. margin-top: 0;
  258. }
  259. /* itemsets (pattern tab) */
  260. .iset {
  261. padding: 8px 10px;
  262. border-radius: 5px;
  263. cursor: pointer;
  264. margin-bottom: 5px;
  265. border: 1px solid var(--border);
  266. background: var(--panel2);
  267. }
  268. .iset:hover:not(.disabled):not(.active) {
  269. border-color: var(--accent);
  270. }
  271. .iset.active {
  272. border-color: var(--accent);
  273. background: #eff6ff;
  274. box-shadow: 0 0 0 1px var(--accent) inset;
  275. }
  276. .iset.disabled {
  277. opacity: 0.32;
  278. cursor: not-allowed;
  279. }
  280. .iset-head {
  281. display: flex;
  282. align-items: center;
  283. gap: 6px;
  284. margin-bottom: 5px;
  285. }
  286. .iset-sup {
  287. background: var(--accent);
  288. color: #fff;
  289. padding: 1px 7px;
  290. border-radius: 3px;
  291. font-weight: 700;
  292. font-size: 11px;
  293. }
  294. .iset-k {
  295. background: var(--tag-bg);
  296. color: var(--fg);
  297. padding: 1px 6px;
  298. border-radius: 3px;
  299. font-size: 10px;
  300. letter-spacing: 0.3px;
  301. }
  302. .iset-meta {
  303. font-size: 10px;
  304. color: var(--muted);
  305. margin-left: auto;
  306. }
  307. .iset-paths {
  308. display: flex;
  309. flex-direction: column;
  310. gap: 3px;
  311. }
  312. .iset-path {
  313. display: flex;
  314. gap: 5px;
  315. font-size: 11px;
  316. line-height: 1.4;
  317. align-items: flex-start;
  318. }
  319. .iset-fdot {
  320. width: 18px;
  321. flex-shrink: 0;
  322. font-size: 9px;
  323. font-weight: 700;
  324. text-align: center;
  325. border-radius: 3px;
  326. line-height: 16px;
  327. height: 16px;
  328. letter-spacing: 0;
  329. margin-top: 1px;
  330. }
  331. .iset-fdot.shi {
  332. background: #dbeafe;
  333. color: #1d4ed8;
  334. }
  335. .iset-fdot.xing {
  336. background: #f3e8ff;
  337. color: #7e22ce;
  338. }
  339. .iset-fdot.both {
  340. background: #fef9c3;
  341. color: #a16207;
  342. }
  343. .iset-leaf {
  344. font-weight: 600;
  345. color: var(--fg);
  346. word-break: break-all;
  347. }
  348. .iset-parent {
  349. color: var(--muted);
  350. font-size: 10px;
  351. margin-top: 1px;
  352. word-break: break-all;
  353. line-height: 1.3;
  354. font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  355. }
  356. /* tree */
  357. .tnode {
  358. margin-left: 0;
  359. }
  360. .tnode .tnode {
  361. margin-left: 12px;
  362. border-left: 1px dashed var(--border);
  363. padding-left: 6px;
  364. }
  365. .tline {
  366. display: flex;
  367. align-items: center;
  368. gap: 4px;
  369. padding: 3px 4px;
  370. border-radius: 4px;
  371. cursor: pointer;
  372. font-size: 12px;
  373. line-height: 1.35;
  374. }
  375. .tline:hover:not(.disabled):not(.active) {
  376. background: var(--panel2);
  377. }
  378. .tline.active {
  379. background: var(--tag-bg-active);
  380. color: var(--tag-fg-active);
  381. }
  382. .tline.disabled {
  383. opacity: 0.32;
  384. cursor: not-allowed;
  385. }
  386. .tline.suggested .tname {
  387. color: var(--suggest);
  388. font-style: italic;
  389. }
  390. .tline.suggested.active .tname {
  391. color: #fff;
  392. }
  393. .tline.inferred .tname {
  394. color: var(--inferred);
  395. font-style: italic;
  396. }
  397. .tline.inferred.active .tname {
  398. color: #fff;
  399. }
  400. .tcaret {
  401. width: 12px;
  402. display: inline-block;
  403. text-align: center;
  404. color: var(--muted);
  405. cursor: pointer;
  406. user-select: none;
  407. flex-shrink: 0;
  408. font-size: 10px;
  409. }
  410. .tcaret.invis {
  411. visibility: hidden;
  412. }
  413. .tname {
  414. flex: 1;
  415. min-width: 0;
  416. white-space: nowrap;
  417. overflow: hidden;
  418. text-overflow: ellipsis;
  419. }
  420. .tcount {
  421. font-size: 10px;
  422. color: var(--muted);
  423. background: var(--bg);
  424. padding: 1px 5px;
  425. border-radius: 8px;
  426. flex-shrink: 0;
  427. }
  428. .tline.active .tcount {
  429. background: rgba(0, 0, 0, 0.3);
  430. color: #fff;
  431. }
  432. .tcollapsed > .tnode {
  433. display: none;
  434. }
  435. /* fragments list */
  436. .frag {
  437. padding: 7px 9px;
  438. border-radius: 5px;
  439. cursor: pointer;
  440. margin-bottom: 4px;
  441. border: 1px solid var(--border);
  442. background: var(--panel);
  443. }
  444. .frag:hover {
  445. background: var(--panel2);
  446. }
  447. .frag.active {
  448. border-color: var(--accent);
  449. background: var(--panel2);
  450. }
  451. .frag-head {
  452. font-size: 10px;
  453. color: var(--muted);
  454. margin-bottom: 3px;
  455. display: flex;
  456. gap: 6px;
  457. align-items: center;
  458. }
  459. .case-badge {
  460. background: var(--accent);
  461. color: #fff;
  462. padding: 1px 5px;
  463. border-radius: 3px;
  464. font-weight: 600;
  465. font-size: 10px;
  466. }
  467. .frag-badge {
  468. background: var(--accent2);
  469. color: #fff;
  470. padding: 1px 5px;
  471. border-radius: 3px;
  472. font-weight: 600;
  473. font-size: 10px;
  474. }
  475. .act-badge {
  476. background: var(--warn);
  477. color: #000;
  478. padding: 1px 5px;
  479. border-radius: 3px;
  480. font-weight: 600;
  481. font-size: 10px;
  482. }
  483. .frag-sig {
  484. font-size: 11px;
  485. color: var(--muted);
  486. margin-top: 2px;
  487. font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  488. }
  489. .frag-body {
  490. font-size: 12px;
  491. color: #334155;
  492. margin-top: 4px;
  493. line-height: 1.45;
  494. display: -webkit-box;
  495. -webkit-line-clamp: 2;
  496. -webkit-box-orient: vertical;
  497. overflow: hidden;
  498. }
  499. /* detail */
  500. .detail-empty {
  501. color: var(--muted);
  502. text-align: center;
  503. padding: 60px 20px;
  504. font-size: 13px;
  505. }
  506. .detail h2 {
  507. font-size: 14px;
  508. margin: 0 0 8px;
  509. display: flex;
  510. gap: 8px;
  511. align-items: center;
  512. flex-wrap: wrap;
  513. }
  514. .case-title {
  515. font-size: 12px;
  516. color: var(--accent);
  517. margin: 6px 0;
  518. line-height: 1.5;
  519. }
  520. .case-title a {
  521. color: var(--accent);
  522. text-decoration: none;
  523. }
  524. .case-title a:hover {
  525. text-decoration: underline;
  526. }
  527. .detail-section {
  528. margin: 12px 0;
  529. }
  530. .detail-section h3 {
  531. font-size: 10px;
  532. color: var(--muted);
  533. text-transform: uppercase;
  534. letter-spacing: 0.6px;
  535. margin: 0 0 6px;
  536. font-weight: 600;
  537. }
  538. .body-text {
  539. font-size: 12px;
  540. line-height: 1.6;
  541. color: #334155;
  542. background: var(--code);
  543. padding: 8px 10px;
  544. border-radius: 5px;
  545. white-space: pre-wrap;
  546. }
  547. .effect-card {
  548. background: var(--code);
  549. border-radius: 5px;
  550. padding: 7px 9px;
  551. margin-bottom: 5px;
  552. border-left: 3px solid var(--accent2);
  553. font-size: 12px;
  554. }
  555. .effect-stmt {
  556. font-weight: 600;
  557. margin-bottom: 4px;
  558. }
  559. .effect-meta {
  560. color: var(--muted);
  561. font-size: 11px;
  562. margin-top: 3px;
  563. }
  564. .pill {
  565. display: inline-block;
  566. padding: 1px 6px;
  567. background: var(--tag-bg);
  568. border-radius: 8px;
  569. font-size: 11px;
  570. margin-right: 3px;
  571. margin-bottom: 3px;
  572. }
  573. .pill.in {
  574. background: #dbeafe;
  575. color: #1e3a8a;
  576. }
  577. .pill.out {
  578. background: #f3e8ff;
  579. color: #581c87;
  580. }
  581. .pill.cfg {
  582. background: #fef9c3;
  583. color: #854d0e;
  584. }
  585. .io-row {
  586. margin-bottom: 4px;
  587. font-size: 11px;
  588. }
  589. .io-row .lbl {
  590. color: var(--muted);
  591. font-size: 10px;
  592. margin-right: 6px;
  593. text-transform: uppercase;
  594. }
  595. .pathline {
  596. font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  597. font-size: 11px;
  598. color: var(--accent);
  599. margin-bottom: 2px;
  600. word-break: break-all;
  601. }
  602. .pathline.suggest {
  603. color: var(--suggest);
  604. }
  605. .rationale {
  606. color: var(--muted);
  607. font-size: 11px;
  608. margin-bottom: 6px;
  609. margin-left: 4px;
  610. line-height: 1.45;
  611. }
  612. .json-raw {
  613. font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  614. font-size: 10px;
  615. background: var(--code);
  616. padding: 8px;
  617. border-radius: 5px;
  618. white-space: pre-wrap;
  619. color: var(--fg);
  620. max-height: 240px;
  621. overflow: auto;
  622. }
  623. details summary {
  624. cursor: pointer;
  625. color: var(--muted);
  626. font-size: 10px;
  627. margin: 6px 0;
  628. user-select: none;
  629. }
  630. details summary:hover {
  631. color: var(--fg);
  632. }
  633. .empty-msg {
  634. color: var(--muted);
  635. text-align: center;
  636. padding: 30px 10px;
  637. font-size: 11px;
  638. font-style: italic;
  639. }
  640. /* modality side filter (column 3 internal) */
  641. .mod-filter {
  642. margin: 0 4px 8px;
  643. padding: 6px 6px 4px;
  644. background: var(--code);
  645. border: 1px solid var(--border);
  646. border-radius: 5px;
  647. }
  648. .mod-filter-row {
  649. display: flex;
  650. align-items: center;
  651. gap: 6px;
  652. margin-bottom: 4px;
  653. }
  654. .mod-filter-row:last-child {
  655. margin-bottom: 0;
  656. }
  657. .mod-filter-lbl {
  658. font-size: 10px;
  659. color: var(--muted);
  660. min-width: 42px;
  661. flex-shrink: 0;
  662. }
  663. .mod-chips {
  664. display: flex;
  665. gap: 4px;
  666. flex-wrap: wrap;
  667. }
  668. .mod-chip {
  669. font-size: 11px;
  670. padding: 1px 7px;
  671. background: var(--tag-bg);
  672. border-radius: 8px;
  673. cursor: pointer;
  674. color: var(--fg);
  675. user-select: none;
  676. border: 1px solid transparent;
  677. }
  678. .mod-chip:hover:not(.disabled) {
  679. background: var(--panel2);
  680. border-color: var(--border);
  681. }
  682. .mod-chip.active {
  683. background: var(--tag-bg-active);
  684. color: var(--tag-fg-active);
  685. }
  686. .mod-chip.disabled {
  687. opacity: 0.32;
  688. cursor: not-allowed;
  689. }
  690. /* selection summary chip in header */
  691. .filter-chip {
  692. font-size: 11px;
  693. padding: 3px 8px;
  694. background: var(--tag-bg);
  695. border-radius: 10px;
  696. color: var(--fg);
  697. display: inline-flex;
  698. align-items: center;
  699. gap: 6px;
  700. }
  701. .filter-chip .x {
  702. color: var(--muted);
  703. cursor: pointer;
  704. font-weight: bold;
  705. }
  706. .filter-chip .x:hover {
  707. color: var(--warn);
  708. }
  709. .filter-chip .lbl {
  710. color: var(--muted);
  711. font-size: 9px;
  712. text-transform: uppercase;
  713. }
  714. </style>
  715. </head>
  716. <body>
  717. <header>
  718. <h1>工序五层筛选</h1>
  719. <span class="stats" id="stats"></span>
  720. <span id="chips"></span>
  721. <button class="exit-fs" id="exitFs">退出全屏</button>
  722. <button class="clear-all" id="clearAll">清除全部筛选</button>
  723. </header>
  724. <main>
  725. <section class="fac1" id="actCol">
  726. <div class="col-title">
  727. <span>① 动作</span><span class="col-count" id="actCnt"></span>
  728. </div>
  729. <div id="actList"></div>
  730. </section>
  731. <section class="fac2" id="scopeCol">
  732. <div class="col-title">
  733. <span>② 作用域</span>
  734. <span class="col-count" id="scopeStat"></span>
  735. </div>
  736. <div class="scope-tabs">
  737. <div class="scope-tab" data-mode="node" id="tabNode">
  738. node · 内容树
  739. </div>
  740. <div class="scope-tab" data-mode="pattern" id="tabPattern">
  741. pattern · 频繁项集
  742. </div>
  743. <span
  744. class="col-clear"
  745. id="scopeClear"
  746. style="margin-left: auto; align-self: center"
  747. >清除</span
  748. >
  749. </div>
  750. <div class="scope-pane" id="paneNode">
  751. <div class="facet-title">实质</div>
  752. <div id="shizhiTree"></div>
  753. <div class="facet-title">形式</div>
  754. <div id="xingshiTree"></div>
  755. </div>
  756. <div class="scope-pane" id="panePattern">
  757. <div class="scope-meta" id="isParams"></div>
  758. <div id="isList"></div>
  759. </div>
  760. </section>
  761. <section class="fac3" id="modCol">
  762. <div class="col-title">
  763. <span>③ 输入 → 输出模态</span
  764. ><span class="col-clear" id="modClear">清除</span>
  765. </div>
  766. <div class="mod-filter">
  767. <div class="mod-filter-row">
  768. <span class="mod-filter-lbl">输入含</span>
  769. <span class="mod-chips" id="modInChips"></span>
  770. </div>
  771. <div class="mod-filter-row">
  772. <span class="mod-filter-lbl">输出含</span>
  773. <span class="mod-chips" id="modOutChips"></span>
  774. </div>
  775. </div>
  776. <div id="modList"></div>
  777. </section>
  778. <section class="fac4" id="fragCol">
  779. <div class="col-title">
  780. <span id="fragColTitle">④ Fragments</span
  781. ><span class="col-count" id="fragCnt"></span>
  782. </div>
  783. <div id="fragList"></div>
  784. </section>
  785. <section class="detail" id="detailCol">
  786. <div class="col-title"><span>⑤ 来源工序详情</span></div>
  787. <div id="detailBody">
  788. <div class="detail-empty">点击左侧 fragment 查看详情</div>
  789. </div>
  790. </section>
  791. </main>
  792. <script>
  793. let data = null;
  794. let SIDE_MODS = null;
  795. let shiDesc = null;
  796. let xingDesc = null;
  797. const urlParams = new URLSearchParams(window.location.search);
  798. const reqIdx = urlParams.get('req') || '108';
  799. Promise.all([
  800. fetch(`/output/${reqIdx}/case.json`).then(r => r.json()).catch(() => null),
  801. fetch(`/output/${reqIdx}/fragment.json`).then(r => r.json()).catch(() => null)
  802. ]).then(([caseData, fragData]) => {
  803. if (!caseData) {
  804. throw new Error("case.json is required but not found");
  805. }
  806. if (fragData && fragData.fragments && fragData.subtree) {
  807. data = fragData;
  808. } else {
  809. console.warn("fragment.json missing or invalid. Building data dynamically from case.json apply_to/apply_to_draft...");
  810. data = buildDataFromCase(caseData);
  811. }
  812. const casesMap = {};
  813. if (caseData && caseData.cases) {
  814. caseData.cases.forEach(c => casesMap[c.index] = c);
  815. }
  816. data.fragments.forEach(f => {
  817. if (casesMap[f.case_index]) {
  818. f.case_title = casesMap[f.case_index].title;
  819. f.case_url = casesMap[f.case_index].url;
  820. f.case_cover = casesMap[f.case_index].cover;
  821. f.case_body = casesMap[f.case_index].body;
  822. f.case_images = casesMap[f.case_index].images;
  823. }
  824. });
  825. initApp();
  826. }).catch(err => {
  827. document.body.innerHTML = `<div style="padding: 40px; text-align: center; color: var(--muted); font-size: 14px;">
  828. <h2>⚠️ 缺少必需的数据文件</h2>
  829. <p>无法加载 /output/${reqIdx}/case.json,或数据解析失败。</p>
  830. <p>请确保流水线已运行完毕并生成了 case.json。</p>
  831. </div>`;
  832. });
  833. function buildDataFromCase(caseData) {
  834. let frags = [];
  835. caseData.cases.forEach(c => {
  836. let groups = c.workflow_groups || [];
  837. groups.forEach(g => {
  838. let caps = g.capability || [];
  839. caps.forEach((cap, idx) => {
  840. let apply = cap.apply_to || cap.apply_to_draft || {};
  841. let apply_shizhi = [];
  842. let apply_xingshi = [];
  843. if (apply["实质"]) apply_shizhi = apply["实质"].map(s => typeof s === 'string' ? {category_path: s} : {category_path: s.category_path || s.path || s});
  844. if (apply["形式"]) apply_xingshi = apply["形式"].map(s => typeof s === 'string' ? {category_path: s} : {category_path: s.category_path || s.path || s});
  845. let inMod = cap.inputs ? cap.inputs.map(i=>i.modality).join('+') : '∅';
  846. let outMod = cap.outputs ? cap.outputs.map(i=>i.modality).join('+') : '∅';
  847. let sig = `${inMod} → ${outMod}`;
  848. frags.push({
  849. ...cap,
  850. case_index: c.index,
  851. fragment_id: cap.capability_id || `${g.workflow_id}_${idx}`,
  852. action: cap.action ? cap.action.description : '未知',
  853. apply_shizhi,
  854. apply_xingshi,
  855. modality_signature: sig,
  856. original_cap: cap
  857. });
  858. });
  859. });
  860. });
  861. let actMap = new Map();
  862. frags.forEach(f => actMap.set(f.action, (actMap.get(f.action) || 0) + 1));
  863. let actions = Array.from(actMap.entries()).map(([verb, count]) => ({verb, count}));
  864. actions.sort((a,b)=>b.count-a.count);
  865. let modMap = new Map();
  866. frags.forEach(f => modMap.set(f.modality_signature, (modMap.get(f.modality_signature) || 0) + 1));
  867. let modalities = Array.from(modMap.entries()).map(([sig, count]) => ({sig, count}));
  868. modalities.sort((a,b)=>b.count-a.count);
  869. function buildTree(pathList) {
  870. let rootNodes = [];
  871. let nodeMap = {};
  872. pathList.forEach(p => {
  873. if (!p) return;
  874. let parts = p.split('/').filter(x => x);
  875. let currPath = '';
  876. let currentLevelList = rootNodes;
  877. parts.forEach(part => {
  878. currPath += '/' + part;
  879. if (!nodeMap[currPath]) {
  880. let newNode = { path: currPath, name: part, children: [] };
  881. nodeMap[currPath] = newNode;
  882. currentLevelList.push(newNode);
  883. }
  884. currentLevelList = nodeMap[currPath].children;
  885. });
  886. });
  887. return rootNodes;
  888. }
  889. let shizhiPaths = new Set();
  890. let xingshiPaths = new Set();
  891. frags.forEach(f => {
  892. f.apply_shizhi.forEach(s => s.category_path && shizhiPaths.add(s.category_path));
  893. f.apply_xingshi.forEach(s => s.category_path && xingshiPaths.add(s.category_path));
  894. });
  895. return {
  896. fragments: frags,
  897. subtree: {
  898. shizhi: buildTree(Array.from(shizhiPaths)),
  899. xingshi: buildTree(Array.from(xingshiPaths))
  900. },
  901. actions,
  902. modalities,
  903. itemsets: [],
  904. itemsetsParams: { min_support: 0, max_k: 0, include_ancestors: false },
  905. stats: { fragments: frags.length, fragments_skipped: 0 }
  906. };
  907. }
  908. function initApp() {
  909. // State of selections (cascading filters)
  910. const state = {
  911. action: null, // verb string
  912. scopeMode: "node", // 'node' or 'pattern' — which sub-filter is active
  913. shizhiPath: null, // path (node mode)
  914. xingshiPath: null, // path (node mode)
  915. itemsetIdx: null, // index into data.itemsets (pattern mode)
  916. modSig: null,
  917. modInFilter: new Set(),
  918. modOutFilter: new Set(),
  919. fragKey: null,
  920. collapsed: new Set(),
  921. };
  922. // Parse a modality signature into input/output sets
  923. function sigParts(sig) {
  924. const [inS, outS] = sig.split(" → ");
  925. const parse = (s) =>
  926. new Set(s.split("+").filter((x) => x && x !== "∅"));
  927. return { in: parse(inS), out: parse(outS) };
  928. }
  929. // All non-config modalities seen in any signature (for the chip palette)
  930. const SIDE_MODS = (() => {
  931. const inSet = new Set(),
  932. outSet = new Set();
  933. for (const m of data.modalities) {
  934. const p = sigParts(m.sig);
  935. for (const x of p.in) inSet.add(x);
  936. for (const x of p.out) outSet.add(x);
  937. }
  938. return { in: [...inSet].sort(), out: [...outSet].sort() };
  939. })();
  940. function $(id) {
  941. return document.getElementById(id);
  942. }
  943. function el(tag, attrs, ...kids) {
  944. const e = document.createElement(tag);
  945. if (attrs)
  946. for (const k in attrs) {
  947. if (k === "class") e.className = attrs[k];
  948. else if (k === "onClick") e.addEventListener("click", attrs[k]);
  949. else if (k.startsWith("data-")) e.setAttribute(k, attrs[k]);
  950. else if (k === "title") e.title = attrs[k];
  951. else e[k] = attrs[k];
  952. }
  953. for (const kid of kids) {
  954. if (kid == null || kid === false) continue;
  955. if (typeof kid === "string")
  956. e.appendChild(document.createTextNode(kid));
  957. else e.appendChild(kid);
  958. }
  959. return e;
  960. }
  961. const fragKey = (f) => f.case_index + ":" + f.fragment_id;
  962. // build path -> all descendant paths map for tree filtering
  963. function buildDescMap(roots) {
  964. const map = new Map();
  965. function walk(node) {
  966. const all = [node.path];
  967. for (const c of node.children || []) {
  968. const sub = walk(c);
  969. for (const p of sub) all.push(p);
  970. }
  971. map.set(node.path, all);
  972. return all;
  973. }
  974. for (const r of roots) walk(r);
  975. return map;
  976. }
  977. const shiDesc = buildDescMap(data.subtree.shizhi || []);
  978. const xingDesc = buildDescMap(data.subtree.xingshi || []);
  979. function fragMatchesPath(f, key, selPath, descMap) {
  980. if (!selPath) return true;
  981. const allowed = descMap.get(selPath) || [selPath];
  982. const allowedSet = new Set(allowed);
  983. const list = key === "shizhi" ? f.apply_shizhi : f.apply_xingshi;
  984. for (const e of list || []) {
  985. if (allowedSet.has(e.category_path)) return true;
  986. }
  987. return false;
  988. }
  989. // Pattern mode helpers
  990. function fragPathSet(f) {
  991. const s = new Set();
  992. for (const e of f.apply_shizhi || [])
  993. if (e.category_path) s.add(e.category_path);
  994. for (const e of f.apply_xingshi || [])
  995. if (e.category_path) s.add(e.category_path);
  996. return s;
  997. }
  998. const fragPaths = new Map();
  999. for (const f of data.fragments)
  1000. fragPaths.set(f.case_index + ":" + f.fragment_id, fragPathSet(f));
  1001. function fragMatchesItemset(f, itemset) {
  1002. if (!itemset) return true;
  1003. const ps = fragPaths.get(f.case_index + ":" + f.fragment_id);
  1004. for (const p of itemset.items) if (!ps.has(p)) return false;
  1005. return true;
  1006. }
  1007. // Active scope filter only counts when we're on the matching tab.
  1008. function scopeFilterActive() {
  1009. if (state.scopeMode === "node")
  1010. return !!(state.shizhiPath || state.xingshiPath);
  1011. if (state.scopeMode === "pattern") return state.itemsetIdx != null;
  1012. return false;
  1013. }
  1014. // Compute filtered fragments given the current state, optionally excluding one filter dim
  1015. function applyFilters(except) {
  1016. return data.fragments.filter((f) => {
  1017. if (except !== "action" && state.action && f.action !== state.action)
  1018. return false;
  1019. if (except !== "scope" && scopeFilterActive()) {
  1020. if (state.scopeMode === "node") {
  1021. if (
  1022. state.shizhiPath &&
  1023. !fragMatchesPath(f, "shizhi", state.shizhiPath, shiDesc)
  1024. )
  1025. return false;
  1026. if (
  1027. state.xingshiPath &&
  1028. !fragMatchesPath(f, "xingshi", state.xingshiPath, xingDesc)
  1029. )
  1030. return false;
  1031. } else if (state.scopeMode === "pattern") {
  1032. const sel = data.itemsets[state.itemsetIdx];
  1033. if (sel && !fragMatchesItemset(f, sel)) return false;
  1034. }
  1035. }
  1036. if (
  1037. except !== "mod" &&
  1038. state.modSig &&
  1039. f.modality_signature !== state.modSig
  1040. )
  1041. return false;
  1042. return true;
  1043. });
  1044. }
  1045. // === RENDERERS ===
  1046. function renderActions() {
  1047. const baseFiltered = applyFilters("action");
  1048. const counts = {};
  1049. for (const f of baseFiltered)
  1050. counts[f.action] = (counts[f.action] || 0) + 1;
  1051. const wrap = $("actList");
  1052. wrap.innerHTML = "";
  1053. for (const a of data.actions) {
  1054. const c = counts[a.verb] || 0;
  1055. const node = el("div", {
  1056. class:
  1057. "item" +
  1058. (state.action === a.verb ? " active" : "") +
  1059. (c === 0 && state.action !== a.verb ? " disabled" : ""),
  1060. onClick: () => {
  1061. if (c === 0 && state.action !== a.verb) return;
  1062. state.action = state.action === a.verb ? null : a.verb;
  1063. renderAll();
  1064. },
  1065. });
  1066. const stack = el(
  1067. "div",
  1068. { class: "item-stack" },
  1069. el("div", { class: "item-name" }, a.verb),
  1070. el("div", { class: "item-def" }, a.definition),
  1071. );
  1072. node.appendChild(stack);
  1073. node.appendChild(el("span", { class: "item-count" }, String(c)));
  1074. wrap.appendChild(node);
  1075. }
  1076. $("actCnt").textContent = "共 " + data.actions.length + " 个";
  1077. }
  1078. function renderTreeFacet(roots, key, mountId, selPath, descMap) {
  1079. const wrap = $(mountId);
  1080. wrap.innerHTML = "";
  1081. const baseFiltered = applyFilters("scope"); // exclude scope filters so this column shows what could be selected
  1082. // Compute hits: each fragment puts its 实质/形式 leaf paths in hit set
  1083. const hitCounts = new Map();
  1084. for (const f of baseFiltered) {
  1085. const list = key === "shizhi" ? f.apply_shizhi : f.apply_xingshi;
  1086. const seen = new Set();
  1087. for (const e of list || []) {
  1088. // walk up the path adding to ancestor counts so subtree counts roll up
  1089. const parts = (e.category_path || "").split("/").filter(Boolean);
  1090. for (let i = 1; i <= parts.length; i++) {
  1091. const p = "/" + parts.slice(0, i).join("/");
  1092. if (seen.has(p)) continue;
  1093. seen.add(p);
  1094. }
  1095. }
  1096. for (const p of seen) hitCounts.set(p, (hitCounts.get(p) || 0) + 1);
  1097. }
  1098. function renderNode(node, parent) {
  1099. const c = hitCounts.get(node.path) || 0;
  1100. const collapsed = state.collapsed.has(node.path);
  1101. const hasChildren = (node.children || []).length > 0;
  1102. const tnode = el("div", {
  1103. class: "tnode" + (collapsed ? " tcollapsed" : ""),
  1104. });
  1105. const cls = ["tline"];
  1106. if (selPath === node.path) cls.push("active");
  1107. if (c === 0 && selPath !== node.path) cls.push("disabled");
  1108. if (node.is_suggested && !node.is_hit) cls.push("suggested");
  1109. if (node.is_inferred) cls.push("inferred");
  1110. const line = el("div", {
  1111. class: cls.join(" "),
  1112. title:
  1113. node.path + (node.description ? "\n\n" + node.description : ""),
  1114. });
  1115. const caret = el(
  1116. "span",
  1117. {
  1118. class: "tcaret" + (hasChildren ? "" : " invis"),
  1119. onClick: (ev) => {
  1120. ev.stopPropagation();
  1121. if (state.collapsed.has(node.path))
  1122. state.collapsed.delete(node.path);
  1123. else state.collapsed.add(node.path);
  1124. renderTrees();
  1125. },
  1126. },
  1127. hasChildren ? (collapsed ? "▶" : "▼") : "·",
  1128. );
  1129. line.appendChild(caret);
  1130. let label = node.name;
  1131. if (node.is_suggested && !node.is_hit) label += " ✦";
  1132. if (node.is_inferred) label += " (推断)";
  1133. line.appendChild(el("span", { class: "tname" }, label));
  1134. line.appendChild(el("span", { class: "tcount" }, String(c)));
  1135. line.addEventListener("click", () => {
  1136. if (c === 0 && selPath !== node.path) return;
  1137. const k = key === "shizhi" ? "shizhiPath" : "xingshiPath";
  1138. state[k] = state[k] === node.path ? null : node.path;
  1139. renderAll();
  1140. });
  1141. tnode.appendChild(line);
  1142. for (const ch of node.children || []) renderNode(ch, tnode);
  1143. parent.appendChild(tnode);
  1144. }
  1145. for (const r of roots) renderNode(r, wrap);
  1146. }
  1147. function renderTrees() {
  1148. renderTreeFacet(
  1149. data.subtree.shizhi || [],
  1150. "shizhi",
  1151. "shizhiTree",
  1152. state.shizhiPath,
  1153. shiDesc,
  1154. );
  1155. renderTreeFacet(
  1156. data.subtree.xingshi || [],
  1157. "xingshi",
  1158. "xingshiTree",
  1159. state.xingshiPath,
  1160. xingDesc,
  1161. );
  1162. }
  1163. function pathLeafAndParent(p) {
  1164. const parts = p.split("/").filter(Boolean);
  1165. if (!parts.length) return { leaf: p, parent: "" };
  1166. return {
  1167. leaf: parts[parts.length - 1],
  1168. parent: "/" + parts.slice(0, -1).join("/"),
  1169. };
  1170. }
  1171. function renderItemsets() {
  1172. const wrap = $("isList");
  1173. wrap.innerHTML = "";
  1174. $("isParams").textContent =
  1175. `${data.itemsets.length} closed · min_support=${data.itemsetsParams.min_support}, k≤${data.itemsetsParams.max_k}, ${data.itemsetsParams.include_ancestors ? "+ancestors" : "leaf-only"}`;
  1176. const baseFiltered = applyFilters("scope");
  1177. data.itemsets.forEach((iset, idx) => {
  1178. const supportNow = baseFiltered.filter((f) =>
  1179. fragMatchesItemset(f, iset),
  1180. ).length;
  1181. const isActive = state.itemsetIdx === idx;
  1182. const cls = ["iset"];
  1183. if (isActive) cls.push("active");
  1184. if (supportNow === 0 && !isActive) cls.push("disabled");
  1185. const node = el("div", {
  1186. class: cls.join(" "),
  1187. onClick: () => {
  1188. if (supportNow === 0 && !isActive) return;
  1189. state.itemsetIdx = isActive ? null : idx;
  1190. renderAll();
  1191. },
  1192. });
  1193. const head = el(
  1194. "div",
  1195. { class: "iset-head" },
  1196. el(
  1197. "span",
  1198. { class: "iset-sup", title: "当前筛选下的支持度" },
  1199. "×" + supportNow,
  1200. ),
  1201. el("span", { class: "iset-k" }, "k=" + iset.size),
  1202. el("span", { class: "iset-meta" }, "原始 sup " + iset.support),
  1203. );
  1204. node.appendChild(head);
  1205. const paths = el("div", { class: "iset-paths" });
  1206. for (const p of iset.items) {
  1207. const facet = data.pathToFacet[p] || "?";
  1208. const dot =
  1209. facet === "实质"
  1210. ? el("span", { class: "iset-fdot shi", title: "实质" }, "实")
  1211. : facet === "形式"
  1212. ? el("span", { class: "iset-fdot xing", title: "形式" }, "形")
  1213. : el(
  1214. "span",
  1215. { class: "iset-fdot both", title: "两侧都有" },
  1216. "双",
  1217. );
  1218. const lp = pathLeafAndParent(p);
  1219. const row = el(
  1220. "div",
  1221. { class: "iset-path", title: p },
  1222. dot,
  1223. el(
  1224. "div",
  1225. null,
  1226. el("span", { class: "iset-leaf" }, lp.leaf),
  1227. el("div", { class: "iset-parent" }, lp.parent),
  1228. ),
  1229. );
  1230. paths.appendChild(row);
  1231. }
  1232. node.appendChild(paths);
  1233. wrap.appendChild(node);
  1234. });
  1235. }
  1236. function renderScope() {
  1237. // tab visuals
  1238. $("tabNode").classList.toggle("active", state.scopeMode === "node");
  1239. $("tabPattern").classList.toggle(
  1240. "active",
  1241. state.scopeMode === "pattern",
  1242. );
  1243. $("paneNode").classList.toggle("active", state.scopeMode === "node");
  1244. $("panePattern").classList.toggle(
  1245. "active",
  1246. state.scopeMode === "pattern",
  1247. );
  1248. // status
  1249. if (state.scopeMode === "node") {
  1250. $("scopeStat").textContent = "路径树(双 facet)";
  1251. } else {
  1252. $("scopeStat").textContent = `${data.itemsets.length} 项集`;
  1253. }
  1254. $("scopeClear").classList.toggle("show", scopeFilterActive());
  1255. // body
  1256. if (state.scopeMode === "node") renderTrees();
  1257. else renderItemsets();
  1258. }
  1259. function sigPassesChipFilter(sig) {
  1260. const p = sigParts(sig);
  1261. for (const m of state.modInFilter) if (!p.in.has(m)) return false;
  1262. for (const m of state.modOutFilter) if (!p.out.has(m)) return false;
  1263. return true;
  1264. }
  1265. function renderModalityChips() {
  1266. const renderSide = (mountId, palette, selectedSet, side) => {
  1267. const wrap = $(mountId);
  1268. wrap.innerHTML = "";
  1269. // Counts: how many sigs would remain if THIS chip were toggled on (alongside the other already-selected chips on this side)
  1270. for (const m of palette) {
  1271. const trial = new Set(selectedSet);
  1272. if (!trial.has(m)) trial.add(m);
  1273. let c = 0;
  1274. for (const sig of data.modalities) {
  1275. const p = sigParts(sig.sig);
  1276. const inOK =
  1277. side === "in"
  1278. ? [...trial].every((x) => p.in.has(x)) &&
  1279. [...state.modOutFilter].every((x) => p.out.has(x))
  1280. : [...state.modInFilter].every((x) => p.in.has(x)) &&
  1281. [...trial].every((x) => p.out.has(x));
  1282. if (inOK) c++;
  1283. }
  1284. const isActive = selectedSet.has(m);
  1285. const chip = el(
  1286. "span",
  1287. {
  1288. class:
  1289. "mod-chip" +
  1290. (isActive ? " active" : "") +
  1291. (c === 0 && !isActive ? " disabled" : ""),
  1292. title: m + (c === 0 && !isActive ? " (无匹配)" : ""),
  1293. onClick: () => {
  1294. if (c === 0 && !isActive) return;
  1295. if (selectedSet.has(m)) selectedSet.delete(m);
  1296. else selectedSet.add(m);
  1297. // if the currently selected modSig no longer matches, drop it
  1298. if (state.modSig && !sigPassesChipFilter(state.modSig))
  1299. state.modSig = null;
  1300. renderAll();
  1301. },
  1302. },
  1303. m,
  1304. );
  1305. wrap.appendChild(chip);
  1306. }
  1307. };
  1308. renderSide("modInChips", SIDE_MODS.in, state.modInFilter, "in");
  1309. renderSide("modOutChips", SIDE_MODS.out, state.modOutFilter, "out");
  1310. }
  1311. function renderModalities() {
  1312. const baseFiltered = applyFilters("mod");
  1313. const counts = {};
  1314. for (const f of baseFiltered)
  1315. counts[f.modality_signature] =
  1316. (counts[f.modality_signature] || 0) + 1;
  1317. renderModalityChips();
  1318. const wrap = $("modList");
  1319. wrap.innerHTML = "";
  1320. const visible = data.modalities.filter((m) =>
  1321. sigPassesChipFilter(m.sig),
  1322. );
  1323. const sorted = [...visible].sort(
  1324. (a, b) => (counts[b.sig] || 0) - (counts[a.sig] || 0),
  1325. );
  1326. if (sorted.length === 0) {
  1327. wrap.appendChild(
  1328. el("div", { class: "empty-msg" }, "当前 chip 筛选下没有匹配签名"),
  1329. );
  1330. }
  1331. for (const m of sorted) {
  1332. const c = counts[m.sig] || 0;
  1333. const node = el(
  1334. "div",
  1335. {
  1336. class:
  1337. "item" +
  1338. (state.modSig === m.sig ? " active" : "") +
  1339. (c === 0 && state.modSig !== m.sig ? " disabled" : ""),
  1340. onClick: () => {
  1341. if (c === 0 && state.modSig !== m.sig) return;
  1342. state.modSig = state.modSig === m.sig ? null : m.sig;
  1343. renderAll();
  1344. },
  1345. },
  1346. el("span", { class: "item-name" }, m.sig),
  1347. el("span", { class: "item-count" }, String(c)),
  1348. );
  1349. wrap.appendChild(node);
  1350. }
  1351. $("modClear").classList.toggle(
  1352. "show",
  1353. !!state.modSig ||
  1354. state.modInFilter.size > 0 ||
  1355. state.modOutFilter.size > 0,
  1356. );
  1357. }
  1358. function renderFragments() {
  1359. const filtered = applyFilters(null);
  1360. const wrap = $("fragList");
  1361. wrap.innerHTML = "";
  1362. $("fragCnt").textContent =
  1363. filtered.length + " / " + data.fragments.length;
  1364. $("fragColTitle").textContent =
  1365. "④ Fragments · " +
  1366. (state.scopeMode === "pattern" ? "分子能力" : "原子能力");
  1367. if (filtered.length === 0) {
  1368. wrap.appendChild(
  1369. el("div", { class: "empty-msg" }, "当前筛选下没有命中的 fragment"),
  1370. );
  1371. return;
  1372. }
  1373. for (const f of filtered) {
  1374. const k = fragKey(f);
  1375. const head = el(
  1376. "div",
  1377. { class: "frag-head" },
  1378. el("span", { class: "case-badge" }, "案例" + f.case_index),
  1379. el("span", { class: "frag-badge" }, f.fragment_id),
  1380. el("span", { class: "act-badge" }, f.action),
  1381. );
  1382. const sig = el("div", { class: "frag-sig" }, f.modality_signature);
  1383. const body = el("div", { class: "frag-body" }, f.body || "");
  1384. const node = el(
  1385. "div",
  1386. {
  1387. class: "frag" + (state.fragKey === k ? " active" : ""),
  1388. onClick: () => {
  1389. state.fragKey = k;
  1390. renderFragments();
  1391. renderDetail();
  1392. },
  1393. },
  1394. head,
  1395. sig,
  1396. body,
  1397. );
  1398. wrap.appendChild(node);
  1399. }
  1400. }
  1401. function renderDetail() {
  1402. const wrap = $("detailBody");
  1403. wrap.innerHTML = "";
  1404. const f = data.fragments.find((x) => fragKey(x) === state.fragKey);
  1405. if (!f) {
  1406. wrap.appendChild(
  1407. el("div", { class: "detail-empty" }, "点击左侧 fragment 查看详情"),
  1408. );
  1409. return;
  1410. }
  1411. // Header
  1412. wrap.appendChild(
  1413. el(
  1414. "h2",
  1415. null,
  1416. el("span", { class: "case-badge" }, "案例 " + f.case_index),
  1417. el("span", { class: "frag-badge" }, f.fragment_id),
  1418. el("span", { class: "act-badge" }, f.action),
  1419. f.workflow_step_ref && f.workflow_step_ref.step_id
  1420. ? el(
  1421. "span",
  1422. { class: "pill" },
  1423. "step " + f.workflow_step_ref.step_id,
  1424. )
  1425. : null,
  1426. ),
  1427. );
  1428. if (f.case_title) {
  1429. const det = el("details", { style: "margin: 8px 0; padding-bottom: 8px; border-bottom: 1px solid var(--border);" });
  1430. const sum = el("summary", { class: "case-title", style: "cursor: pointer; margin: 0; outline: none; font-weight: bold; color: var(--accent); padding: 6px 8px; background: var(--panel2); border-radius: 4px; font-size: 11px;" }, "📄 源: " + f.case_title);
  1431. det.appendChild(sum);
  1432. const caseContent = el("div", { style: "padding: 10px; background: var(--code); border-radius: 5px; margin-top: 4px; border: 1px solid var(--border);" });
  1433. const imgsToRender = f.case_images && f.case_images.length ? f.case_images : (f.case_cover ? [f.case_cover] : []);
  1434. if (imgsToRender.length > 0) {
  1435. const imgContainer = el("div", { style: "display: flex; gap: 8px; overflow-x: auto; margin-bottom: 8px; padding-bottom: 4px;" });
  1436. for (const imgSrc of imgsToRender) {
  1437. const img = el("img", { src: imgSrc, style: "height: 160px; border-radius: 5px; object-fit: contain; background: var(--panel2); border: 1px solid var(--border);" });
  1438. imgContainer.appendChild(img);
  1439. }
  1440. caseContent.appendChild(imgContainer);
  1441. }
  1442. if (f.case_body) {
  1443. const body = el("div", { style: "font-size: 12px; line-height: 1.6; color: var(--fg); white-space: pre-wrap; margin-bottom: 10px; max-height: 250px; overflow-y: auto; padding-right: 4px;" }, f.case_body);
  1444. caseContent.appendChild(body);
  1445. }
  1446. if (f.case_url) {
  1447. const link = el("a", { href: f.case_url, target: "_blank", rel: "noopener", style: "font-size: 11px; color: var(--accent); display: inline-block; background: var(--panel2); padding: 4px 8px; border-radius: 4px; text-decoration: none;" }, "🔗 访问原始链接");
  1448. caseContent.appendChild(link);
  1449. }
  1450. det.appendChild(caseContent);
  1451. wrap.appendChild(det);
  1452. }
  1453. // I/O modalities
  1454. const ioSec = el(
  1455. "div",
  1456. { class: "detail-section" },
  1457. el("h3", null, "I/O 模态"),
  1458. );
  1459. ioSec.appendChild(
  1460. el(
  1461. "div",
  1462. { class: "frag-sig", style: "font-size:13px;margin-bottom:6px" },
  1463. f.modality_signature,
  1464. ),
  1465. );
  1466. const ioRow = (lbl, arr, kind) => {
  1467. const row = el(
  1468. "div",
  1469. { class: "io-row" },
  1470. el("span", { class: "lbl" }, lbl),
  1471. );
  1472. if (!arr || !arr.length) {
  1473. row.appendChild(
  1474. el("span", { style: "color:var(--muted)" }, "(无)"),
  1475. );
  1476. return row;
  1477. }
  1478. for (const x of arr) {
  1479. const isCfg = x.modality === "模型" || x.modality === "参数";
  1480. const txt =
  1481. (x.description || "") +
  1482. (x.modality ? "[" + x.modality + "]" : "") +
  1483. (x.relation ? " " + x.relation : "");
  1484. row.appendChild(
  1485. el("span", { class: "pill " + (isCfg ? "cfg" : kind) }, txt),
  1486. );
  1487. }
  1488. return row;
  1489. };
  1490. ioSec.appendChild(ioRow("IN", f.inputs, "in"));
  1491. ioSec.appendChild(ioRow("OUT", f.outputs, "out"));
  1492. wrap.appendChild(ioSec);
  1493. // Body
  1494. if (f.body) {
  1495. wrap.appendChild(
  1496. el(
  1497. "div",
  1498. { class: "detail-section" },
  1499. el("h3", null, "Body"),
  1500. el("div", { class: "body-text" }, f.body),
  1501. ),
  1502. );
  1503. }
  1504. // apply_to (实质 + 形式) — highlight rule depends on scope mode
  1505. let hotPaths = new Set();
  1506. if (state.scopeMode === "pattern" && state.itemsetIdx != null) {
  1507. const sel = data.itemsets[state.itemsetIdx];
  1508. if (sel) for (const p of sel.items) hotPaths.add(p);
  1509. }
  1510. const renderApply = (label, arr) => {
  1511. const sec = el(
  1512. "div",
  1513. { class: "detail-section" },
  1514. el("h3", null, "Apply to · " + label),
  1515. );
  1516. if (!arr || !arr.length) {
  1517. sec.appendChild(
  1518. el("div", { class: "empty-msg", style: "padding:8px" }, "无"),
  1519. );
  1520. return sec;
  1521. }
  1522. for (const e of arr) {
  1523. let isHighlighted = false;
  1524. if (state.scopeMode === "node") {
  1525. isHighlighted =
  1526. (label === "实质" &&
  1527. state.shizhiPath &&
  1528. (shiDesc.get(state.shizhiPath) || []).includes(
  1529. e.category_path,
  1530. )) ||
  1531. (label === "形式" &&
  1532. state.xingshiPath &&
  1533. (xingDesc.get(state.xingshiPath) || []).includes(
  1534. e.category_path,
  1535. ));
  1536. } else {
  1537. isHighlighted = hotPaths.has(e.category_path);
  1538. }
  1539. sec.appendChild(
  1540. el(
  1541. "div",
  1542. {
  1543. class: "pathline",
  1544. style: isHighlighted ? "color:#f1e05a" : "",
  1545. },
  1546. e.category_path,
  1547. ),
  1548. );
  1549. if (e.rationale)
  1550. sec.appendChild(
  1551. el("div", { class: "rationale" }, "— " + e.rationale),
  1552. );
  1553. }
  1554. return sec;
  1555. };
  1556. wrap.appendChild(renderApply("实质", f.apply_shizhi));
  1557. wrap.appendChild(renderApply("形式", f.apply_xingshi));
  1558. // suggest_apply_to
  1559. if (f.suggest_apply_to && f.suggest_apply_to.length) {
  1560. const sec = el(
  1561. "div",
  1562. { class: "detail-section" },
  1563. el("h3", null, "Suggest Apply to ✦(建议新增节点)")
  1564. );
  1565. let arr = Array.isArray(f.suggest_apply_to) ? f.suggest_apply_to : [f.suggest_apply_to];
  1566. for (const s of arr) {
  1567. let p = typeof s === 'string' ? s : (s.path || s.category_path || JSON.stringify(s));
  1568. sec.appendChild(el("div", { class: "pathline suggest" }, p));
  1569. if (s && typeof s === 'object' && s.rationale) {
  1570. sec.appendChild(el("div", { class: "rationale" }, "— " + s.rationale));
  1571. }
  1572. }
  1573. wrap.appendChild(sec);
  1574. }
  1575. // effects
  1576. if (f.effects && f.effects.length) {
  1577. const sec = el(
  1578. "div",
  1579. { class: "detail-section" },
  1580. el("h3", null, "Effects"),
  1581. );
  1582. f.effects.forEach((e, i) => {
  1583. const card = el("div", { class: "effect-card" });
  1584. card.appendChild(
  1585. el(
  1586. "div",
  1587. { class: "effect-stmt" },
  1588. "#" + i + " " + (e.statement || "-"),
  1589. ),
  1590. );
  1591. if (e.criteria)
  1592. card.appendChild(
  1593. el("div", { class: "effect-meta" }, "判定标准:" + e.criteria),
  1594. );
  1595. if (e.judge_method)
  1596. card.appendChild(
  1597. el(
  1598. "div",
  1599. { class: "effect-meta" },
  1600. "判定方式:" + e.judge_method,
  1601. ),
  1602. );
  1603. if (e.negative_examples && e.negative_examples.length) {
  1604. const ne = el("div", { class: "effect-meta" }, "反例:");
  1605. for (const n of e.negative_examples)
  1606. ne.appendChild(
  1607. el("div", { style: "margin-left:8px" }, "· " + n),
  1608. );
  1609. card.appendChild(ne);
  1610. }
  1611. sec.appendChild(card);
  1612. });
  1613. wrap.appendChild(sec);
  1614. }
  1615. // misc
  1616. const miscRows = [];
  1617. miscRows.push(["tools", (f.tools && f.tools.length) ? f.tools.join(", ") : "-"]);
  1618. miscRows.push(["artifact_type", f.artifact_type ? f.artifact_type : "-"]);
  1619. miscRows.push(["control_target", (f.control_target && f.control_target.length) ? f.control_target.join(", ") : "-"]);
  1620. miscRows.push(["alt_to", (f.is_alternative_to && f.is_alternative_to.length) ? f.is_alternative_to.join(", ") : "-"]);
  1621. if (miscRows.length) {
  1622. const sec = el(
  1623. "div",
  1624. { class: "detail-section" },
  1625. el("h3", null, "其他"),
  1626. );
  1627. for (const [k2, v2] of miscRows) {
  1628. const row = el(
  1629. "div",
  1630. { style: "font-size:11px;margin-bottom:3px" },
  1631. el("span", { style: "color:var(--muted);margin-right:8px" }, k2),
  1632. el("span", null, v2),
  1633. );
  1634. sec.appendChild(row);
  1635. }
  1636. wrap.appendChild(sec);
  1637. }
  1638. // raw fold-out
  1639. wrap.appendChild(
  1640. el(
  1641. "details",
  1642. null,
  1643. el("summary", null, "查看原始 fragment JSON"),
  1644. el("pre", { class: "json-raw" }, JSON.stringify(f, null, 2)),
  1645. ),
  1646. );
  1647. }
  1648. function renderChips() {
  1649. const c = $("chips");
  1650. c.innerHTML = "";
  1651. let any = false;
  1652. const mk = (lbl, val, onX) => {
  1653. any = true;
  1654. c.appendChild(
  1655. el(
  1656. "span",
  1657. { class: "filter-chip" },
  1658. el("span", { class: "lbl" }, lbl),
  1659. el("span", null, val),
  1660. el(
  1661. "span",
  1662. {
  1663. class: "x",
  1664. onClick: () => {
  1665. onX();
  1666. renderAll();
  1667. },
  1668. },
  1669. "×",
  1670. ),
  1671. ),
  1672. );
  1673. };
  1674. if (state.action)
  1675. mk("动作", state.action, () => {
  1676. state.action = null;
  1677. });
  1678. if (state.scopeMode === "node") {
  1679. if (state.shizhiPath)
  1680. mk(
  1681. "实质",
  1682. state.shizhiPath.split("/").pop() || state.shizhiPath,
  1683. () => {
  1684. state.shizhiPath = null;
  1685. },
  1686. );
  1687. if (state.xingshiPath)
  1688. mk(
  1689. "形式",
  1690. state.xingshiPath.split("/").pop() || state.xingshiPath,
  1691. () => {
  1692. state.xingshiPath = null;
  1693. },
  1694. );
  1695. } else if (state.scopeMode === "pattern" && state.itemsetIdx != null) {
  1696. const sel = data.itemsets[state.itemsetIdx];
  1697. const desc = sel.items.map((p) => p.split("/").pop()).join(" + ");
  1698. mk("项集 k=" + sel.size, desc, () => {
  1699. state.itemsetIdx = null;
  1700. });
  1701. }
  1702. if (state.modSig)
  1703. mk("模态", state.modSig, () => {
  1704. state.modSig = null;
  1705. });
  1706. $("clearAll").classList.toggle("active", any);
  1707. }
  1708. function renderStats() {
  1709. $("stats").textContent =
  1710. `${data.stats.fragments} fragments · ${data.actions.length} 动作 · ${data.modalities.length} 模态组合${data.stats.fragments_skipped ? ` · 已跳过 ${data.stats.fragments_skipped} 个空模态片段` : ""}`;
  1711. }
  1712. function renderAll() {
  1713. renderActions();
  1714. renderScope();
  1715. renderModalities();
  1716. renderFragments();
  1717. renderDetail();
  1718. renderChips();
  1719. }
  1720. $("clearAll").addEventListener("click", () => {
  1721. state.action = null;
  1722. state.shizhiPath = null;
  1723. state.xingshiPath = null;
  1724. state.itemsetIdx = null;
  1725. state.modSig = null;
  1726. state.modInFilter.clear();
  1727. state.modOutFilter.clear();
  1728. renderAll();
  1729. });
  1730. $("scopeClear").addEventListener("click", () => {
  1731. // clear only the current tab's selection
  1732. if (state.scopeMode === "node") {
  1733. state.shizhiPath = null;
  1734. state.xingshiPath = null;
  1735. } else {
  1736. state.itemsetIdx = null;
  1737. }
  1738. renderAll();
  1739. });
  1740. $("tabNode").addEventListener("click", () => {
  1741. state.scopeMode = "node";
  1742. renderAll();
  1743. });
  1744. $("tabPattern").addEventListener("click", () => {
  1745. state.scopeMode = "pattern";
  1746. renderAll();
  1747. });
  1748. $("modClear").addEventListener("click", () => {
  1749. state.modSig = null;
  1750. state.modInFilter.clear();
  1751. state.modOutFilter.clear();
  1752. renderAll();
  1753. });
  1754. renderStats();
  1755. renderAll();
  1756. }
  1757. document.getElementById('exitFs').addEventListener('click', () => {
  1758. window.parent.postMessage({ type: 'EXIT_FULLSCREEN' }, '*');
  1759. });
  1760. window.addEventListener('message', (e) => {
  1761. if (e.data && e.data.type === 'SET_FULLSCREEN') {
  1762. const btn = document.getElementById('exitFs');
  1763. const clearAll = document.getElementById('clearAll');
  1764. if (e.data.isFullscreen) {
  1765. btn.style.display = 'inline-block';
  1766. clearAll.style.marginLeft = '8px';
  1767. } else {
  1768. btn.style.display = 'none';
  1769. clearAll.style.marginLeft = 'auto';
  1770. }
  1771. }
  1772. });
  1773. </script>
  1774. </body>
  1775. </html>