index.html 121 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157
  1. <!doctype html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <title>搜索评估 · 案例总览</title>
  7. <style>
  8. :root {
  9. --ink: #24211d;
  10. --muted: #6f6961;
  11. --line: #ded8ce;
  12. --paper: #fbfaf7;
  13. --panel: #ffffff;
  14. --mint: #1f8a70;
  15. --rose: #b24b63;
  16. --amber: #b87918;
  17. --cyan: #2a6f8f;
  18. --soft-mint: #e9f5f0;
  19. --soft-rose: #f8e9ee;
  20. --soft-amber: #fff2d9;
  21. --soft-cyan: #e7f2f7;
  22. --shadow: 0 18px 45px rgba(41, 35, 28, .08);
  23. }
  24. * {
  25. box-sizing: border-box;
  26. }
  27. body {
  28. margin: 0;
  29. color: var(--ink);
  30. background: var(--paper);
  31. font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  32. line-height: 1.55;
  33. }
  34. header {
  35. padding: 40px 32px 22px;
  36. border-bottom: 1px solid var(--line);
  37. background: linear-gradient(180deg, #fff 0%, #fbfaf7 100%);
  38. }
  39. .wrap {
  40. max-width: 1220px;
  41. margin: 0 auto;
  42. }
  43. .eyebrow {
  44. display: flex;
  45. gap: 8px;
  46. align-items: center;
  47. color: var(--mint);
  48. font-size: 13px;
  49. font-weight: 700;
  50. text-transform: uppercase;
  51. letter-spacing: 0;
  52. }
  53. h1 {
  54. margin: 10px 0 10px;
  55. font-size: clamp(32px, 5vw, 58px);
  56. line-height: 1.06;
  57. letter-spacing: 0;
  58. }
  59. .lede {
  60. max-width: 860px;
  61. margin: 0;
  62. color: var(--muted);
  63. font-size: 17px;
  64. }
  65. .stats {
  66. display: grid;
  67. grid-template-columns: repeat(4, minmax(0, 1fr));
  68. gap: 12px;
  69. margin-top: 24px;
  70. }
  71. .stat {
  72. background: var(--panel);
  73. border: 1px solid var(--line);
  74. border-radius: 8px;
  75. padding: 14px;
  76. box-shadow: var(--shadow);
  77. min-height: 86px;
  78. }
  79. .stat strong {
  80. display: block;
  81. font-size: 26px;
  82. line-height: 1.1;
  83. }
  84. .stat span {
  85. color: var(--muted);
  86. font-size: 13px;
  87. }
  88. main {
  89. padding: 24px 32px 48px;
  90. }
  91. .toolbar {
  92. display: flex;
  93. gap: 10px;
  94. align-items: center;
  95. justify-content: space-between;
  96. margin-bottom: 18px;
  97. flex-wrap: wrap;
  98. }
  99. .filters {
  100. display: flex;
  101. gap: 8px;
  102. flex-wrap: wrap;
  103. }
  104. button,
  105. select {
  106. border: 1px solid var(--line);
  107. background: #fff;
  108. color: var(--ink);
  109. border-radius: 8px;
  110. padding: 9px 12px;
  111. font: inherit;
  112. }
  113. button {
  114. cursor: pointer;
  115. }
  116. button.active {
  117. color: #fff;
  118. background: var(--ink);
  119. border-color: var(--ink);
  120. }
  121. select {
  122. min-width: 190px;
  123. }
  124. .grid {
  125. display: grid;
  126. grid-template-columns: repeat(3, minmax(0, 1fr));
  127. gap: 16px;
  128. }
  129. .result {
  130. min-height: 500px;
  131. background: var(--panel);
  132. border: 1px solid var(--line);
  133. border-radius: 8px;
  134. overflow: hidden;
  135. box-shadow: var(--shadow);
  136. display: flex;
  137. flex-direction: column;
  138. position: relative;
  139. transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.25s ease;
  140. }
  141. .result:hover {
  142. transform: translateY(-2px);
  143. box-shadow: 0 22px 50px rgba(41, 35, 28, .12);
  144. }
  145. .result.discard {
  146. border-color: rgba(178, 75, 99, 0.15);
  147. }
  148. .discard-overlay {
  149. position: absolute;
  150. top: 0;
  151. left: 0;
  152. right: 0;
  153. bottom: 0;
  154. background: rgba(251, 250, 247, 0.85);
  155. backdrop-filter: blur(5px);
  156. -webkit-backdrop-filter: blur(5px);
  157. display: flex;
  158. flex-direction: column;
  159. align-items: center;
  160. justify-content: center;
  161. padding: 20px;
  162. text-align: center;
  163. z-index: 5;
  164. opacity: 1;
  165. transition: opacity 0.25s ease;
  166. pointer-events: none;
  167. }
  168. .result.discard:hover .discard-overlay {
  169. opacity: 0;
  170. }
  171. .discard-badge {
  172. background: var(--soft-rose);
  173. color: var(--rose);
  174. border: 1px solid rgba(178, 75, 99, 0.25);
  175. padding: 6px 16px;
  176. border-radius: 999px;
  177. font-size: 13px;
  178. font-weight: 700;
  179. text-transform: uppercase;
  180. letter-spacing: 1px;
  181. margin-bottom: 12px;
  182. box-shadow: 0 2px 8px rgba(178, 75, 99, 0.1);
  183. }
  184. .discard-reason {
  185. color: var(--muted);
  186. font-size: 13px;
  187. line-height: 1.6;
  188. max-width: 90%;
  189. margin: 0 auto;
  190. display: -webkit-box;
  191. -webkit-line-clamp: 6;
  192. -webkit-box-orient: vertical;
  193. overflow: hidden;
  194. font-weight: 500;
  195. }
  196. .thumbs {
  197. display: grid;
  198. grid-template-columns: repeat(3, 1fr);
  199. gap: 2px;
  200. height: 150px;
  201. background: #eee7dc;
  202. overflow: hidden;
  203. }
  204. .thumbs img {
  205. width: 100%;
  206. height: 100%;
  207. object-fit: cover;
  208. display: block;
  209. background: #eee7dc;
  210. }
  211. .thumbs img:first-child:nth-last-child(1) {
  212. grid-column: 1 / -1;
  213. }
  214. .body {
  215. padding: 15px;
  216. flex: 1;
  217. display: flex;
  218. flex-direction: column;
  219. }
  220. .meta {
  221. display: flex;
  222. justify-content: space-between;
  223. gap: 10px;
  224. color: var(--muted);
  225. font-size: 12px;
  226. margin-bottom: 8px;
  227. }
  228. .platform {
  229. color: #fff;
  230. border-radius: 999px;
  231. padding: 2px 8px;
  232. font-weight: 700;
  233. white-space: nowrap;
  234. }
  235. .p-xhs {
  236. background: var(--rose);
  237. }
  238. .p-gzh {
  239. background: var(--mint);
  240. }
  241. .p-x {
  242. background: var(--cyan);
  243. }
  244. h2 {
  245. margin: 0 0 8px;
  246. font-size: 18px;
  247. line-height: 1.25;
  248. letter-spacing: 0;
  249. }
  250. .excerpt {
  251. color: var(--muted);
  252. font-size: 13px;
  253. display: -webkit-box;
  254. -webkit-line-clamp: 5;
  255. -webkit-box-orient: vertical;
  256. overflow: hidden;
  257. }
  258. .tags {
  259. display: flex;
  260. flex-wrap: wrap;
  261. gap: 6px;
  262. margin: 12px 0;
  263. }
  264. .tag {
  265. background: #f2eee7;
  266. border-radius: 999px;
  267. padding: 3px 8px;
  268. font-size: 12px;
  269. color: #514a42;
  270. }
  271. .scorebar {
  272. margin-top: auto;
  273. }
  274. .overall {
  275. display: flex;
  276. align-items: end;
  277. justify-content: space-between;
  278. border-top: 1px solid var(--line);
  279. padding-top: 12px;
  280. }
  281. .score {
  282. font-size: 36px;
  283. line-height: .9;
  284. font-weight: 800;
  285. }
  286. .decision {
  287. color: var(--mint);
  288. font-weight: 800;
  289. }
  290. .decision.discard {
  291. color: var(--amber);
  292. }
  293. .mini-bars {
  294. display: grid;
  295. grid-template-columns: repeat(5, 1fr);
  296. gap: 4px;
  297. margin-top: 10px;
  298. }
  299. .mini-bars span {
  300. height: 7px;
  301. border-radius: 999px;
  302. background: #eee;
  303. overflow: hidden;
  304. position: relative;
  305. }
  306. .mini-bars span .fill {
  307. display: block;
  308. height: 100%;
  309. background: var(--mint);
  310. border-radius: 999px;
  311. }
  312. .group-snapshot {
  313. display: grid;
  314. grid-template-columns: repeat(4, minmax(0, 1fr));
  315. gap: 5px;
  316. margin-top: 10px;
  317. }
  318. .mini-bars.new-schema {
  319. grid-template-columns: repeat(2, 1fr) !important;
  320. }
  321. .group-snapshot.new-schema {
  322. grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  323. }
  324. .group-pill {
  325. border: 1px solid var(--line);
  326. border-radius: 8px;
  327. padding: 5px 6px;
  328. background: #fff;
  329. min-width: 0;
  330. }
  331. .group-pill span {
  332. display: block;
  333. color: var(--muted);
  334. font-size: 11px;
  335. white-space: nowrap;
  336. overflow: hidden;
  337. text-overflow: ellipsis;
  338. }
  339. .group-pill strong {
  340. display: block;
  341. font-size: 14px;
  342. line-height: 1.1;
  343. }
  344. .actions {
  345. display: flex;
  346. gap: 8px;
  347. margin-top: 12px;
  348. }
  349. .actions a,
  350. .actions button {
  351. flex: 1;
  352. text-align: center;
  353. text-decoration: none;
  354. color: var(--ink);
  355. background: #fff;
  356. border: 1px solid var(--line);
  357. border-radius: 8px;
  358. padding: 8px 10px;
  359. font-size: 13px;
  360. }
  361. dialog {
  362. width: min(980px, calc(100vw - 28px));
  363. max-height: calc(100vh - 32px);
  364. border: 1px solid var(--line);
  365. border-radius: 8px;
  366. padding: 0;
  367. box-shadow: 0 28px 90px rgba(0, 0, 0, .25);
  368. }
  369. dialog::backdrop {
  370. background: rgba(38, 33, 27, .42);
  371. }
  372. dialog.fullscreen {
  373. width: 100vw !important;
  374. max-width: 100vw !important;
  375. height: 100vh !important;
  376. max-height: 100vh !important;
  377. border: none !important;
  378. border-radius: 0 !important;
  379. margin: 0 !important;
  380. top: 0 !important;
  381. left: 0 !important;
  382. }
  383. dialog.fullscreen #modalContentProcedure {
  384. height: calc(100vh - 120px) !important;
  385. max-height: none !important;
  386. }
  387. dialog.fullscreen #modalContentDetail {
  388. height: calc(100vh - 120px) !important;
  389. max-height: none !important;
  390. overflow-y: auto !important;
  391. }
  392. .modal-head {
  393. position: sticky;
  394. top: 0;
  395. background: #fff;
  396. border-bottom: 1px solid var(--line);
  397. padding: 16px;
  398. z-index: 2;
  399. display: flex;
  400. justify-content: space-between;
  401. gap: 14px;
  402. align-items: start;
  403. }
  404. .modal-head h3 {
  405. margin: 0;
  406. font-size: 20px;
  407. line-height: 1.25;
  408. }
  409. .modal-content {
  410. display: grid;
  411. grid-template-columns: 1.1fr .9fr;
  412. gap: 18px;
  413. padding: 16px;
  414. }
  415. .modal-content > section,
  416. .modal-content > aside {
  417. min-width: 0;
  418. }
  419. .section-title {
  420. margin: 18px 0 8px;
  421. font-weight: 800;
  422. }
  423. .raw {
  424. white-space: pre-wrap;
  425. background: #faf7f1;
  426. border: 1px solid var(--line);
  427. border-radius: 8px;
  428. padding: 12px;
  429. max-height: 330px;
  430. overflow: auto;
  431. color: #3d3831;
  432. font-size: 13px;
  433. }
  434. .images {
  435. display: grid;
  436. grid-template-columns: repeat(2, minmax(0, 1fr));
  437. gap: 8px;
  438. }
  439. .images img {
  440. width: 100%;
  441. max-height: 260px;
  442. object-fit: contain;
  443. border: 1px solid var(--line);
  444. border-radius: 8px;
  445. background: #f1ece4;
  446. }
  447. .scores {
  448. display: grid;
  449. gap: 12px;
  450. }
  451. .score-group {
  452. border: 1px solid var(--line);
  453. border-radius: 8px;
  454. background: #fff;
  455. overflow: hidden;
  456. }
  457. .score-group-head {
  458. display: flex;
  459. justify-content: space-between;
  460. gap: 10px;
  461. align-items: center;
  462. padding: 10px 11px;
  463. background: #faf7f1;
  464. border-bottom: 1px solid var(--line);
  465. font-size: 13px;
  466. font-weight: 800;
  467. }
  468. .score-group-head small {
  469. color: var(--muted);
  470. font-weight: 700;
  471. white-space: nowrap;
  472. }
  473. .score-group-body {
  474. display: grid;
  475. gap: 8px;
  476. padding: 10px;
  477. }
  478. .score-row {
  479. display: grid;
  480. grid-template-columns: 128px 1fr 34px;
  481. gap: 10px;
  482. align-items: center;
  483. font-size: 13px;
  484. }
  485. .score-row.missing {
  486. color: #a39b91;
  487. }
  488. .score-row.missing .meter span {
  489. display: none;
  490. }
  491. .meter {
  492. height: 9px;
  493. border-radius: 999px;
  494. background: #eee7dc;
  495. overflow: hidden;
  496. }
  497. .meter span {
  498. display: block;
  499. height: 100%;
  500. width: calc(var(--v) * 20%);
  501. background: var(--rose);
  502. }
  503. .rubric-note {
  504. background: var(--soft-cyan);
  505. border-left: 4px solid var(--cyan);
  506. padding: 10px 12px;
  507. color: #254c5d;
  508. border-radius: 4px;
  509. font-size: 13px;
  510. }
  511. @media (max-width: 980px) {
  512. .grid {
  513. grid-template-columns: repeat(2, minmax(0, 1fr));
  514. }
  515. .stats {
  516. grid-template-columns: repeat(2, minmax(0, 1fr));
  517. }
  518. .modal-content {
  519. grid-template-columns: 1fr;
  520. }
  521. }
  522. @media (max-width: 640px) {
  523. header,
  524. main {
  525. padding-left: 16px;
  526. padding-right: 16px;
  527. }
  528. .grid,
  529. .stats {
  530. grid-template-columns: 1fr;
  531. }
  532. .toolbar {
  533. align-items: stretch;
  534. }
  535. select {
  536. width: 100%;
  537. }
  538. .result {
  539. min-height: auto;
  540. }
  541. .group-snapshot {
  542. grid-template-columns: repeat(2, minmax(0, 1fr));
  543. }
  544. }
  545. /* Extra styles for interactive navigation & matrix */
  546. .stats {
  547. display: grid;
  548. grid-template-columns: repeat(5, 1fr);
  549. gap: 12px;
  550. }
  551. .stats .stat {
  552. min-width: 0;
  553. }
  554. .p-zhihu {
  555. background: #2a6f8f;
  556. }
  557. .p-x {
  558. background: #2a6f8f;
  559. }
  560. .p-bili {
  561. background: #b24b63;
  562. }
  563. .p-douyin {
  564. background: #24211d;
  565. }
  566. .p-sph {
  567. background: #07c160;
  568. }
  569. .p-youtube {
  570. background: #c4302b;
  571. }
  572. .p-github {
  573. background: #24292e;
  574. }
  575. .p-toutiao {
  576. background: #f04142;
  577. }
  578. .p-weibo {
  579. background: #e6162d;
  580. }
  581. .nav {
  582. display: flex;
  583. flex-direction: column;
  584. gap: 8px;
  585. margin-bottom: 14px;
  586. }
  587. .navrow {
  588. display: flex;
  589. gap: 8px;
  590. align-items: center;
  591. flex-wrap: wrap;
  592. }
  593. .navlab {
  594. width: 54px;
  595. flex: 0 0 54px;
  596. color: var(--muted);
  597. font-size: 12px;
  598. font-weight: 700;
  599. text-transform: uppercase;
  600. }
  601. .navrow .tab {
  602. border: 1px solid var(--line);
  603. background: #fff;
  604. color: var(--ink);
  605. border-radius: 999px;
  606. padding: 6px 14px;
  607. font-size: 13px;
  608. cursor: pointer;
  609. }
  610. .navrow .tab.on {
  611. background: var(--ink);
  612. color: #fff;
  613. border-color: var(--ink);
  614. }
  615. .navrow .tab .q {
  616. font-family: ui-monospace, Menlo, monospace;
  617. }
  618. .navrow .tab small {
  619. color: var(--muted);
  620. margin-left: 4px;
  621. }
  622. .navrow .tab.on small {
  623. color: #cfd8dc;
  624. }
  625. #navQ .qtab {
  626. max-width: 100%;
  627. white-space: normal;
  628. text-align: left;
  629. line-height: 1.4;
  630. }
  631. .navrow .tab {
  632. white-space: normal;
  633. }
  634. #refresh {
  635. cursor: pointer;
  636. }
  637. /* 1:1 Morandi Matrix Replicated Style Rules */
  638. .btn {
  639. padding: 3px 10px;
  640. border-radius: 14px;
  641. border: 1px solid #d1d5db;
  642. background: #fff;
  643. cursor: pointer;
  644. font-size: .74rem;
  645. color: #444;
  646. }
  647. .g-form .btn.on {
  648. background: #4f46e5;
  649. border-color: #4f46e5;
  650. color: #fff;
  651. }
  652. .g-lens .btn.on {
  653. background: #be185d;
  654. border-color: #be185d;
  655. color: #fff;
  656. }
  657. .g-mod .btn.on {
  658. background: #2e7d32;
  659. border-color: #2e7d32;
  660. color: #fff;
  661. }
  662. .g-tool .btn.on {
  663. background: #c2410c;
  664. border-color: #c2410c;
  665. color: #fff;
  666. }
  667. .g-tier .btn.on {
  668. background: #374151;
  669. border-color: #374151;
  670. color: #fff;
  671. }
  672. .g-mxview .btn.on {
  673. background: var(--mint);
  674. border-color: var(--mint);
  675. color: #fff;
  676. }
  677. .mxwrap {
  678. max-height: 55vh;
  679. overflow: auto;
  680. border: 1px solid var(--line);
  681. border-radius: 0 0 8px 8px;
  682. margin-bottom: 12px;
  683. background: #fff;
  684. position: relative;
  685. }
  686. table#comboMx {
  687. border-collapse: separate;
  688. border-spacing: 0;
  689. background: #fff;
  690. font-size: .65rem;
  691. width: 100%;
  692. }
  693. table#comboMx th,
  694. table#comboMx td {
  695. border-right: 1px solid #f0f1f5;
  696. border-bottom: 1px solid #f0f1f5;
  697. text-align: center;
  698. }
  699. table#comboMx thead th {
  700. position: sticky;
  701. background: #fff;
  702. }
  703. table#comboMx thead tr.l1 th {
  704. top: 0;
  705. z-index: 11;
  706. background: #eef2ff;
  707. color: #4338ca;
  708. font-weight: 700;
  709. font-size: .72rem;
  710. height: 20px;
  711. border-bottom: 1px solid #c7d2fe;
  712. }
  713. table#comboMx thead tr.l2 th {
  714. top: 20px;
  715. z-index: 11;
  716. background: #f5f7ff;
  717. color: #6366f1;
  718. font-weight: 600;
  719. font-size: .66rem;
  720. height: 18px;
  721. border-bottom: 1px solid #e0e7ff;
  722. }
  723. table#comboMx thead tr.leaf th {
  724. top: 38px;
  725. z-index: 9;
  726. background: #fff;
  727. color: #1f2937;
  728. font-size: .66rem;
  729. min-width: 120px;
  730. max-width: 120px;
  731. height: 24px;
  732. padding: 3px;
  733. }
  734. table#comboMx thead .corner {
  735. left: 0;
  736. top: 0;
  737. z-index: 13;
  738. background: #fff;
  739. min-width: 96px;
  740. }
  741. .l1div {
  742. border-left: 3px solid #818cf8 !important;
  743. }
  744. .l2div {
  745. border-left: 1.5px solid #cbd5e8 !important;
  746. }
  747. table#comboMx tbody th.rh {
  748. position: sticky;
  749. left: 0;
  750. z-index: 8;
  751. background: #fffaf0;
  752. color: #92580c;
  753. text-align: left;
  754. padding: 4px 8px;
  755. font-weight: 600;
  756. white-space: nowrap;
  757. min-width: 96px;
  758. border-right: 1px solid #e6e8ef;
  759. }
  760. table#comboMx tbody tr.l1row td {
  761. background: #eef2ff;
  762. color: #4338ca;
  763. font-weight: 700;
  764. font-size: .7rem;
  765. text-align: left;
  766. padding: 3px 8px;
  767. position: sticky;
  768. left: 0;
  769. }
  770. td.cell {
  771. min-width: 120px;
  772. max-width: 120px;
  773. height: 30px;
  774. padding: 2px 5px;
  775. cursor: pointer;
  776. font-family: ui-monospace, Menlo, monospace;
  777. font-size: .65rem;
  778. color: #1f2937;
  779. text-align: left;
  780. line-height: 1.25;
  781. border-left: 4px solid transparent;
  782. overflow: hidden;
  783. position: relative;
  784. }
  785. td.cell:hover {
  786. box-shadow: inset 0 0 0 2px #f59e0b;
  787. }
  788. td.cell.t0 {
  789. border-left-color: #e5e7eb;
  790. background: #fbfbfc;
  791. color: #aeb3bd;
  792. }
  793. td.cell.t1 {
  794. border-left-color: #bbf7d0;
  795. }
  796. td.cell.t2 {
  797. border-left-color: #4ade80;
  798. background: #f3fdf6;
  799. }
  800. td.cell.t3 {
  801. border-left-color: #15803d;
  802. background: #ecfdf3;
  803. }
  804. td.cell.tNA {
  805. border-left-color: #fcd34d;
  806. background: repeating-linear-gradient(45deg, #fff, #fff 4px, #fef9ec 4px, #fef9ec 8px);
  807. color: #b6bac4;
  808. }
  809. td.cell.gq-cell {
  810. color: #15803d;
  811. font-weight: 600;
  812. }
  813. td.cell.rowdim {
  814. opacity: .26;
  815. }
  816. td.cell.hide {
  817. visibility: hidden;
  818. }
  819. td.cell.sel {
  820. outline: 2px solid var(--ink);
  821. outline-offset: -2px;
  822. font-weight: bold;
  823. }
  824. td.cell.rowsel,
  825. td.cell.colsel {
  826. box-shadow: inset 0 0 0 999px rgba(255, 193, 7, .12);
  827. }
  828. td.cell.rowsel.colsel {
  829. box-shadow: inset 0 0 0 999px rgba(255, 193, 7, .22);
  830. }
  831. th.rh.rowsel {
  832. background: rgba(255, 193, 7, .22);
  833. color: var(--ink);
  834. font-weight: 700;
  835. }
  836. thead th.colsel {
  837. background: rgba(255, 193, 7, .22);
  838. color: var(--ink);
  839. font-weight: 700;
  840. }
  841. /* Database hit badge inside matrix cells */
  842. td.cell .hit-badge {
  843. position: absolute;
  844. right: 2px;
  845. top: 2px;
  846. background: #10b981;
  847. color: #fff;
  848. font-size: 9px;
  849. font-weight: bold;
  850. border-radius: 3px;
  851. padding: 0 3px;
  852. line-height: 1.2;
  853. box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  854. }
  855. /* Pop-up floating panel styling */
  856. .pop {
  857. position: fixed;
  858. background: #fff;
  859. border: 1px solid #d1d5db;
  860. border-radius: 9px;
  861. box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
  862. padding: 13px 15px;
  863. max-width: 450px;
  864. z-index: 200;
  865. display: none;
  866. font-size: .82rem;
  867. line-height: 1.5;
  868. }
  869. .pop .pt {
  870. font-weight: 700;
  871. color: #1f2937;
  872. margin-bottom: 7px;
  873. display: flex;
  874. gap: 6px;
  875. align-items: center;
  876. flex-wrap: wrap;
  877. padding-right: 18px;
  878. }
  879. .pop .path {
  880. font-size: .66rem;
  881. padding: 1px 6px;
  882. border-radius: 3px;
  883. }
  884. .pop .path.a {
  885. background: #eef2ff;
  886. color: #4338ca;
  887. }
  888. .pop .path.t {
  889. background: #fef3c7;
  890. color: #92400e;
  891. }
  892. .pop .tier {
  893. font-size: .64rem;
  894. padding: 1px 7px;
  895. border-radius: 3px;
  896. font-weight: 600;
  897. }
  898. .tb0 {
  899. background: #e5e7eb;
  900. color: #6b7280;
  901. }
  902. .tb1 {
  903. background: #dcfce7;
  904. color: #166534;
  905. }
  906. .tb2 {
  907. background: #bbf7d0;
  908. color: #14532d;
  909. }
  910. .tb3 {
  911. background: #15803d;
  912. color: #fff;
  913. }
  914. .tbNA {
  915. background: #fef3c7;
  916. color: #92400e;
  917. }
  918. .pop .reason {
  919. background: #fffbeb;
  920. border-left: 3px solid #f59e0b;
  921. padding: 7px 11px;
  922. border-radius: 3px;
  923. color: #78350f;
  924. margin: 7px 0;
  925. font-size: .8rem;
  926. }
  927. .pop .reason.inv {
  928. background: #fef2f2;
  929. border-left-color: #ef4444;
  930. color: #991b1b;
  931. }
  932. .pop .gq {
  933. background: #ecfdf3;
  934. border: 1px solid #a7f3d0;
  935. border-radius: 6px;
  936. padding: 7px 11px;
  937. margin: 7px 0;
  938. font-family: ui-monospace, Menlo, monospace;
  939. font-size: .84rem;
  940. color: #15803d;
  941. }
  942. .pop .gq .t {
  943. font-family: inherit;
  944. font-size: .64rem;
  945. color: #6b7280;
  946. display: block;
  947. margin-bottom: 2px;
  948. }
  949. .pop .small {
  950. font-size: .7rem;
  951. color: #9aa0ad;
  952. margin: 4px 0;
  953. }
  954. .pop .lbl {
  955. font-size: .66rem;
  956. color: #6b7280;
  957. font-weight: 600;
  958. margin: 9px 0 3px;
  959. }
  960. .pop ul {
  961. margin: 0;
  962. padding: 0;
  963. list-style: none;
  964. }
  965. .pop li {
  966. padding: 3px 8px;
  967. background: #f9fafb;
  968. border-radius: 4px;
  969. margin-bottom: 3px;
  970. font-family: ui-monospace, Menlo, monospace;
  971. font-size: .78rem;
  972. color: #1f2937;
  973. }
  974. .pop li.gen {
  975. background: #eef0ff;
  976. color: #3730a3;
  977. }
  978. .pop li.cur {
  979. box-shadow: inset 0 0 0 2px #818cf8;
  980. }
  981. .pop li .fm {
  982. font-size: .62rem;
  983. color: #4f46e5;
  984. margin-right: 6px;
  985. }
  986. .pop .note {
  987. font-size: .7rem;
  988. color: #2e7d32;
  989. margin-top: 6px;
  990. }
  991. .pop .close {
  992. position: absolute;
  993. top: 6px;
  994. right: 9px;
  995. cursor: pointer;
  996. color: #9ca3af;
  997. font-size: 1.15rem;
  998. }
  999. .fac {
  1000. border: 1px solid var(--line);
  1001. background: #fff;
  1002. border-radius: 999px;
  1003. padding: 4px 11px;
  1004. font-size: 12px;
  1005. cursor: pointer;
  1006. color: var(--ink);
  1007. }
  1008. .fac.on {
  1009. background: var(--mint);
  1010. color: #fff;
  1011. border-color: var(--mint);
  1012. }
  1013. .fac small {
  1014. opacity: .65;
  1015. margin-left: 3px;
  1016. }
  1017. #navQ .qtab .hit {
  1018. display: inline-block;
  1019. margin-left: 7px;
  1020. background: var(--soft-mint);
  1021. color: var(--mint);
  1022. border-radius: 999px;
  1023. padding: 0 8px;
  1024. font-size: 11px;
  1025. font-weight: 700;
  1026. }
  1027. #navQ .qtab.on .hit {
  1028. background: rgba(255, 255, 255, .22);
  1029. color: #fff;
  1030. }
  1031. .modal-tabs {
  1032. display: flex;
  1033. gap: 4px;
  1034. padding: 0 16px;
  1035. border-bottom: 1px solid var(--line);
  1036. background: #faf7f1;
  1037. }
  1038. .modal-tab {
  1039. background: transparent;
  1040. border: none;
  1041. border-bottom: 3px solid transparent;
  1042. border-radius: 0;
  1043. padding: 10px 16px;
  1044. font-size: 14px;
  1045. font-weight: 600;
  1046. color: var(--muted);
  1047. cursor: pointer;
  1048. transition: all 0.2s ease;
  1049. }
  1050. .modal-tab:hover {
  1051. color: var(--ink);
  1052. background: rgba(0, 0, 0, 0.02);
  1053. }
  1054. .modal-tab.active {
  1055. color: var(--mint);
  1056. border-bottom-color: var(--mint);
  1057. }
  1058. /* 新版评估分数卡片可视化样式 */
  1059. .sc-card {
  1060. background: #fff;
  1061. border: 1px solid var(--line);
  1062. border-radius: 12px;
  1063. padding: 16px 20px;
  1064. margin-bottom: 16px;
  1065. box-shadow: 0 4px 15px rgba(0,0,0,0.02);
  1066. }
  1067. .sc-card-head {
  1068. display: flex;
  1069. justify-content: space-between;
  1070. align-items: center;
  1071. margin-bottom: 14px;
  1072. border-bottom: 1px solid #f3f0ea;
  1073. padding-bottom: 10px;
  1074. }
  1075. .sc-card-head .title {
  1076. font-size: 16px;
  1077. font-weight: 700;
  1078. display: flex;
  1079. align-items: center;
  1080. gap: 8px;
  1081. }
  1082. .sc-card-head .badge {
  1083. background: #eef2ff;
  1084. color: #2563eb;
  1085. font-size: 11px;
  1086. padding: 2px 6px;
  1087. border-radius: 4px;
  1088. font-weight: 700;
  1089. }
  1090. .sc-card-head .avg-score {
  1091. font-size: 14px;
  1092. color: var(--muted);
  1093. font-weight: 600;
  1094. }
  1095. .sc-card-head .avg-score strong {
  1096. font-size: 26px;
  1097. color: #2563eb;
  1098. font-weight: 800;
  1099. margin-left: 6px;
  1100. }
  1101. .sc-sub-header {
  1102. font-size: 12px;
  1103. color: var(--muted);
  1104. font-weight: 700;
  1105. margin: 14px 0 8px;
  1106. border-bottom: 1px dashed #f0ebd8;
  1107. padding-bottom: 4px;
  1108. text-transform: uppercase;
  1109. letter-spacing: 0.5px;
  1110. }
  1111. .sc-row {
  1112. display: flex;
  1113. justify-content: space-between;
  1114. align-items: center;
  1115. padding: 6px 0;
  1116. font-size: 13.5px;
  1117. gap: 10px;
  1118. }
  1119. .sc-row .label {
  1120. color: var(--ink);
  1121. font-weight: 500;
  1122. flex: 1;
  1123. min-width: 100px;
  1124. word-break: break-all;
  1125. }
  1126. .sc-row .bar-wrap {
  1127. display: flex;
  1128. align-items: center;
  1129. gap: 10px;
  1130. width: 170px;
  1131. flex-shrink: 0;
  1132. }
  1133. .sc-row .bar {
  1134. height: 6px;
  1135. background: #eee7dc;
  1136. border-radius: 999px;
  1137. flex: 1;
  1138. overflow: hidden;
  1139. }
  1140. .sc-row .bar-fill {
  1141. height: 100%;
  1142. background: #2563eb;
  1143. border-radius: 999px;
  1144. width: calc(var(--v) * 10%);
  1145. }
  1146. .sc-row .value {
  1147. font-weight: 700;
  1148. font-size: 13.5px;
  1149. width: 20px;
  1150. text-align: right;
  1151. }
  1152. .sc-row .info-icon {
  1153. cursor: pointer;
  1154. color: #9ca3af;
  1155. transition: color 0.15s ease;
  1156. font-size: 13px;
  1157. user-select: none;
  1158. }
  1159. .sc-row .info-icon:hover {
  1160. color: #3b82f6;
  1161. }
  1162. #reevalBtn {
  1163. background: #faf7f1;
  1164. color: var(--amber);
  1165. border-color: rgba(184, 121, 24, 0.3);
  1166. height: 38px;
  1167. padding: 0 16px;
  1168. font-size: 13px;
  1169. font-weight: 600;
  1170. border-radius: 8px;
  1171. box-shadow: var(--shadow);
  1172. }
  1173. #reevalBtn:hover {
  1174. background: var(--soft-amber);
  1175. color: var(--amber);
  1176. border-color: var(--amber);
  1177. }
  1178. #editSpecBtn {
  1179. background: #f0f7f6;
  1180. color: var(--cyan);
  1181. border-color: rgba(42, 111, 143, 0.3);
  1182. height: 38px;
  1183. padding: 0 16px;
  1184. font-size: 13px;
  1185. font-weight: 600;
  1186. border-radius: 8px;
  1187. box-shadow: var(--shadow);
  1188. }
  1189. #editSpecBtn:hover {
  1190. background: var(--soft-cyan);
  1191. color: var(--cyan);
  1192. border-color: var(--cyan);
  1193. }
  1194. </style>
  1195. </head>
  1196. <body>
  1197. <header>
  1198. <div class="wrap">
  1199. <div class="eyebrow">Content Search · runs/ 实时 · query → 形式 → 渠道</div>
  1200. <h1>搜索评估 · 案例总览</h1>
  1201. <p class="lede" id="lede" style="margin:0">加载中…</p>
  1202. <div class="stats" id="stats"></div>
  1203. </div>
  1204. </header>
  1205. <main>
  1206. <div class="wrap">
  1207. <div class="nav">
  1208. <div class="navrow" style="margin-bottom:4px;">
  1209. <span class="navlab">组合矩阵</span>
  1210. <span style="color:var(--muted);font-size:12px;flex:1">行=类型 列=动作 格子色=评分,角标=帖子数/工序数。点击选组合且弹出详情。</span>
  1211. <span class="g-mxview" style="display:inline-flex;gap:4px;margin-right:12px;align-items:center;">
  1212. <button class="btn on" id="btnMxFull" onclick="setMatrixView('full')">完整矩阵</button>
  1213. <button class="btn" id="btnMxHits" onclick="setMatrixView('hits')">只看帖子命中</button>
  1214. <button class="btn" id="btnMxProcedures" onclick="setMatrixView('procedures')">只看工序</button>
  1215. </span>
  1216. <button id="refresh" onclick="loadData(true)">↻ 刷新 runs</button>
  1217. </div>
  1218. <div class="mx-header"
  1219. style="background:#fff; border: 1px solid var(--line); border-radius: 8px 8px 0 0; padding:12px 16px 8px; border-bottom: none;">
  1220. <h4
  1221. style="margin:0 0 4px; font-size:13px; color:#1f2937; display:flex; justify-content:space-between; align-items:center; font-weight:700;">
  1222. <span>动作 × 类型 · 组合矩阵 <span style="font-weight:400;font-size:11px;color:#9aa0ad">基于 <b
  1223. id="gm">gemini-3.1-flash-lite</b></span></span>
  1224. <span class="legend" style="display:flex;gap:9px;align-items:center;color:#6b7280;font-size:11px;">
  1225. <span><span class="sw"
  1226. style="display:inline-block;width:10px;height:10px;border-radius:2px;background:#15803d;vertical-align:middle;margin-right:3px;"></span>高
  1227. · <b id="s3" style="color:#15803d;">0</b></span>
  1228. <span><span class="sw"
  1229. style="display:inline-block;width:10px;height:10px;border-radius:2px;background:#4ade80;vertical-align:middle;margin-right:3px;"></span>中
  1230. · <b id="s2" style="color:#4ade80;">0</b></span>
  1231. <span><span class="sw"
  1232. style="display:inline-block;width:10px;height:10px;border-radius:2px;background:#bbf7d0;vertical-align:middle;margin-right:3px;"></span>低
  1233. · <b id="s1" style="color:#10b981;">0</b></span>
  1234. <span><span class="sw"
  1235. style="display:inline-block;width:10px;height:10px;border-radius:2px;background:#e5e7eb;vertical-align:middle;margin-right:3px;"></span>无效
  1236. · <b id="s0" style="color:#9ca3af;">0</b></span>
  1237. <span><span class="sw"
  1238. style="display:inline-block;width:10px;height:10px;border-radius:2px;background:#fcd34d;vertical-align:middle;margin-right:3px;"></span>未判
  1239. · <b id="sna" style="color:#b87918;">0</b></span>
  1240. </span>
  1241. </h4>
  1242. <div class="sub" style="font-size:11px;color:#6b7280;margin-bottom:8px;">
  1243. 共 1350 格 · 形式①原词不替换 · ②句子套模板 · ③同义池替换。
  1244. </div>
  1245. <div class="ctl"
  1246. style="display:flex;gap:6px;flex-wrap:wrap;align-items:center;font-size:11px;border-top:1px solid #f3f4f6;padding-top:8px;">
  1247. <span class="lab" style="color:#9aa0ad;font-weight:600;">query生成方式</span>
  1248. <span class="g-form">
  1249. <button class="btn on" data-k="form" data-v="A">①原词</button>
  1250. <button class="btn" data-k="form" data-v="B">②句子</button>
  1251. <button class="btn" data-k="form" data-v="C">③同义</button>
  1252. </span>
  1253. <span class="lab" style="color:#9aa0ad;font-weight:600;margin-left:8px;">知识类型</span>
  1254. <span class="g-lens">
  1255. <button class="btn on" data-k="lens" data-v="工序">工序</button>
  1256. <button class="btn" data-k="lens" data-v="工具">工具</button>
  1257. <button class="btn" data-k="lens" data-v="能力">能力</button>
  1258. </span>
  1259. <span class="lab" style="color:#9aa0ad;font-weight:600;margin-left:8px;">约束·工具类型</span>
  1260. <span class="g-tool">
  1261. <button class="btn on" data-k="tool" data-v="">无</button>
  1262. <span id="toolBtns"></span>
  1263. </span>
  1264. <span class="lab" style="color:#9aa0ad;font-weight:600;margin-left:8px;">搜索优先级</span>
  1265. <span class="g-tier">
  1266. <button class="btn on" data-k="tier" data-v="0">全部</button>
  1267. <button class="btn" data-k="tier" data-v="2">≥中</button>
  1268. <button class="btn" data-k="tier" data-v="3">仅高</button>
  1269. </span>
  1270. </div>
  1271. </div>
  1272. <div class="mxwrap"
  1273. style="max-height:55vh; overflow:auto; border:1px solid var(--line); border-radius: 0 0 8px 8px; margin-bottom:12px; background:#fff; position:relative;">
  1274. <table id="comboMx"></table>
  1275. </div>
  1276. <div class="pop" id="pop"></div>
  1277. <div class="navrow"><span class="navlab">渠道</span>
  1278. <div id="navC" style="display:flex;gap:8px;flex-wrap:wrap"></div>
  1279. </div>
  1280. </div>
  1281. <div class="toolbar">
  1282. <div class="filters"></div>
  1283. <!-- 动态相关性过滤阈值 -->
  1284. <div class="threshold-control" style="display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 4px 12px; font-size: 13px; font-weight: 600; box-shadow: var(--shadow);">
  1285. <span style="color: var(--muted); font-size: 12px; font-weight: 700;">相关性过滤阈值:</span>
  1286. <input type="number" id="relThreshold" min="0" max="10" step="0.5" value="4.0"
  1287. oninput="renderGrid(); renderHead();"
  1288. style="width: 55px; border: 1px solid #d1d5db; border-radius: 4px; padding: 2px 6px; font-weight: 700; text-align: center; color: #2563eb; outline: none; transition: border-color 0.2s;"
  1289. onfocus="this.style.borderColor='#2563eb'" onblur="this.style.borderColor='#d1d5db'">
  1290. </div>
  1291. <button id="reevalBtn" onclick="reevalCurrentQuery()" title="只对当前 query 的所有 form/帖子复评(不重新搜索)">♻️ 重评当前 query</button>
  1292. <button id="editSpecBtn" onclick="openSpecEditor()" title="查看或修改 spec/ 提示词规范文件">📝 编辑 Spec 提示词</button>
  1293. <select id="sort">
  1294. <option value="score">按综合分排序</option>
  1295. <option value="date">按发布时间排序</option>
  1296. <option value="platform">按平台排序</option>
  1297. </select>
  1298. </div>
  1299. <div class="grid" id="grid"></div>
  1300. </div>
  1301. </main>
  1302. <dialog id="detailDialog">
  1303. <div class="modal-head">
  1304. <div>
  1305. <div id="modalMeta" class="meta"></div>
  1306. <h3 id="modalTitle"></h3>
  1307. </div>
  1308. <div style="display: flex; gap: 8px; align-items: center;">
  1309. <button id="toggleFullscreenBtn" onclick="toggleModalFullscreen()" style="padding: 5px 12px; font-weight: 600; font-size: 13px;">📺 全屏</button>
  1310. <button onclick="detailDialog.close()">关闭</button>
  1311. </div>
  1312. </div>
  1313. <div class="modal-tabs" id="modalTabs" style="display: none;">
  1314. <button class="modal-tab active" onclick="switchModalTab('detail')" id="tabDetailBtn">帖子详情</button>
  1315. <button class="modal-tab" onclick="switchModalTab('procedure')" id="tabProcedureBtn">对应工序</button>
  1316. </div>
  1317. <div class="modal-content" id="modalContentDetail">
  1318. <section>
  1319. <div class="rubric-note" id="modalReason"></div>
  1320. <div class="section-title">抓取文本节选</div>
  1321. <div class="raw" id="modalText"></div>
  1322. <div class="section-title">图片预览</div>
  1323. <div class="images" id="modalImages"></div>
  1324. </section>
  1325. <aside>
  1326. <div class="section-title" style="display: flex; justify-content: space-between; align-items: center;">
  1327. <span>评分详情</span>
  1328. <span id="modalOverallScore" style="font-size: 13.5px; font-weight: 700; color: var(--muted); display: flex; align-items: center; gap: 4px; background: #faf7f1; border: 1px solid var(--line); padding: 3px 10px; border-radius: 6px; box-shadow: 0 2px 6px rgba(0,0,0,0.01);">
  1329. 综合评分 <strong style="font-size: 19px; color: #2563eb; font-weight: 900; line-height: 1;" id="modalOverallScoreVal">—</strong>
  1330. </span>
  1331. </div>
  1332. <div class="scores" id="modalScores"></div>
  1333. <div class="section-title">类型 / 命中 query</div>
  1334. <div class="tags" id="modalTags"></div>
  1335. </aside>
  1336. </div>
  1337. <div id="modalContentProcedure" style="display: none; min-height: 500px; height: calc(100vh - 180px); max-height: 700px; padding: 16px; box-sizing: border-box; flex-direction: column;">
  1338. <!-- Top Action Bar (inside tab) -->
  1339. <div id="procActionBar" style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line); flex-shrink: 0;">
  1340. <div style="font-size: 14px; font-weight: bold; color: var(--ink);" id="procStatusText">工序状态: 检测中...</div>
  1341. <div style="display: flex; gap: 8px;" id="procActionBtns">
  1342. <!-- Dynamically populated buttons (Regenerate, View Logs, etc) -->
  1343. </div>
  1344. </div>
  1345. <!-- Main view container -->
  1346. <div style="flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column;">
  1347. <!-- Configuration / Setup panel (when not generated) -->
  1348. <div id="procSetupPanel" style="display: none; flex-direction: column; align-items: center; justify-content: center; text-align: center; height: 100%; padding: 40px 20px;">
  1349. <div style="font-size: 36px; margin-bottom: 16px;">✨</div>
  1350. <h4 style="margin: 0 0 10px; font-size: 18px;">提取本帖工序</h4>
  1351. <p style="color: var(--muted); font-size: 14px; max-width: 500px; margin: 0 0 24px;">该帖子目前尚未生成对应的结构化工序。请在下方选择提取引擎和模型,点击开始提取。</p>
  1352. <div style="display: flex; gap: 16px; margin-bottom: 24px; text-align: left; background: #fff; border: 1px solid var(--line); padding: 16px; border-radius: 8px; box-shadow: var(--shadow);">
  1353. <div>
  1354. <label style="display: block; font-size: 12px; font-weight: bold; margin-bottom: 6px; color: var(--muted);">提取引擎 (Engine)</label>
  1355. <select id="procEngineSelect" style="min-width: 180px; padding: 6px 10px;" onchange="onProcEngineChange()">
  1356. <option value="cyber_runner">Cyber Runner (自研/OpenRouter)</option>
  1357. <option value="claude_sdk">Claude SDK (OAuth)</option>
  1358. </select>
  1359. </div>
  1360. <div>
  1361. <label style="display: block; font-size: 12px; font-weight: bold; margin-bottom: 6px; color: var(--muted);">AI 模型 (Model)</label>
  1362. <select id="procModelSelect" style="min-width: 240px; padding: 6px 10px;">
  1363. <!-- Dynamically populated options -->
  1364. </select>
  1365. </div>
  1366. </div>
  1367. <button id="startProcBtn" onclick="startProcedureExtraction()" style="background: var(--mint); color: #fff; border-color: var(--mint); padding: 10px 24px; font-size: 15px; font-weight: bold; border-radius: 8px; cursor: pointer; transition: all 0.2s;">开始提取工序</button>
  1368. </div>
  1369. <!-- Live Log Terminal View -->
  1370. <div id="procConsolePanel" style="display: none; flex-direction: column; height: 100%; min-height: 0; background: #1e1b18; border: 1px solid #3d352e; border-radius: 8px; overflow: hidden; box-shadow: inset 0 2px 10px rgba(0,0,0,0.5);">
  1371. <!-- Console header -->
  1372. <div style="background: #2b2520; padding: 6px 12px; border-bottom: 1px solid #3d352e; display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; font-family: monospace; font-size: 12px; color: #a3968d;">
  1373. <span>TERMINAL CONSOLE</span>
  1374. <span id="procConsoleStatus">idle</span>
  1375. </div>
  1376. <!-- Console log output -->
  1377. <pre id="procConsoleOutput" style="flex: 1; margin: 0; padding: 12px; overflow: auto; font-family: ui-monospace, Menlo, Monaco, Consolas, monospace; font-size: 13px; line-height: 1.45; color: #cbbba9; background: #1e1b18; white-space: pre-wrap; word-break: break-all;"></pre>
  1378. </div>
  1379. <!-- Iframe Panel for completed HTML -->
  1380. <iframe id="procedureIframe" style="display: none; width: 100%; height: 100%; border: 1px solid var(--line); border-radius: 8px; background: #fff;" referrerpolicy="no-referrer"></iframe>
  1381. </div>
  1382. </div>
  1383. </dialog>
  1384. <!-- Spec Editor Dialog -->
  1385. <dialog id="specEditorDialog" style="width: 850px; max-width: 95%; border: 1px solid var(--line); border-radius: 12px; padding: 0; box-shadow: var(--shadow); background: var(--panel);">
  1386. <div style="display: flex; justify-content: space-between; align-items: center; background: #faf7f1; border-bottom: 1px solid var(--line); padding: 16px 20px;">
  1387. <h3 style="margin: 0; font-size: 18px; color: var(--ink); font-weight: 800;">📝 编辑 Spec 提示词规范</h3>
  1388. <button onclick="document.getElementById('specEditorDialog').close()" style="background: none; border: 1px solid var(--line); padding: 5px 14px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 12px;">关闭</button>
  1389. </div>
  1390. <div style="padding: 20px;">
  1391. <div style="margin-bottom: 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;">
  1392. <span style="font-size: 13.5px; font-weight: 700; color: var(--ink);">选择提示词文件:</span>
  1393. <select id="specFileSelect" onchange="loadSpecFileContent()" style="padding: 6px 12px; border-radius: 8px; border: 1px solid #d1d5db; outline: none; min-width: 320px; font-family: monospace; font-size: 13px; font-weight: 600;">
  1394. <!-- Spec files options will be populated -->
  1395. </select>
  1396. <span id="specLoadStatus" style="font-size: 13px; font-weight: 600;"></span>
  1397. </div>
  1398. <div style="position: relative; margin-bottom: 20px;">
  1399. <textarea id="specContentTextarea" style="width: 100%; height: 500px; font-family: ui-monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13.5px; line-height: 1.55; padding: 14px; border: 1px solid #d1d5db; border-radius: 8px; box-sizing: border-box; outline: none; background: #fafaf9; color: #1f2937; resize: vertical; border-left: 4px solid var(--cyan); box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);"></textarea>
  1400. </div>
  1401. <div style="display: flex; justify-content: flex-end; gap: 12px; align-items: center; border-top: 1px solid var(--line); padding-top: 16px;">
  1402. <span id="specSaveStatus" style="font-size: 13.5px; font-weight: 700; margin-right: auto;"></span>
  1403. <button onclick="document.getElementById('specEditorDialog').close()" class="btn" style="background: #f3f4f6; height: 38px; padding: 0 18px; border-radius: 8px; font-weight: 600;">取消</button>
  1404. <button onclick="saveSpecFileContent()" class="btn" style="background: var(--mint); color: #fff; border-color: var(--mint); font-weight: bold; height: 38px; padding: 0 20px; border-radius: 8px; box-shadow: var(--shadow);">💾 保存修改</button>
  1405. </div>
  1406. </div>
  1407. </dialog>
  1408. <script>
  1409. let DATA = { queries: [], actions: [], types: [], matrix: [] }, st = { form: 'A', lens: '工序', tools: [], tier: 0, qi: 0, fi: 0, channel: "all", matrixView: 'full' }, VIEW = [];
  1410. let currentProcTask = null;
  1411. let procPollInterval = null;
  1412. let isLogViewActive = false;
  1413. let reevalPollIntervals = {};
  1414. function startReevalPolling(q) {
  1415. if (reevalPollIntervals[q]) return;
  1416. const btn = document.getElementById('reevalBtn');
  1417. const poll = () => {
  1418. fetch(`/api/reeval_status?q=${q}`)
  1419. .then(r => r.json())
  1420. .then(d => {
  1421. const isCurrent = DATA.queries[st.qi] && DATA.queries[st.qi].key === q;
  1422. if (d.status === "success") {
  1423. clearInterval(reevalPollIntervals[q]);
  1424. delete reevalPollIntervals[q];
  1425. if (isCurrent) {
  1426. btn.disabled = false;
  1427. btn.textContent = '♻️ 重评当前 query';
  1428. }
  1429. // Mark local status as finished
  1430. if (DATA.active_reevals) {
  1431. delete DATA.active_reevals[q];
  1432. }
  1433. loadData(true);
  1434. alert(`Query ${q} 重评完成!已自动重新扫描并更新数据。`);
  1435. } else if (d.status === "failed") {
  1436. clearInterval(reevalPollIntervals[q]);
  1437. delete reevalPollIntervals[q];
  1438. if (isCurrent) {
  1439. btn.disabled = false;
  1440. btn.textContent = '♻️ 重评当前 query';
  1441. }
  1442. if (DATA.active_reevals) {
  1443. delete DATA.active_reevals[q];
  1444. }
  1445. alert(`Query ${q} 重评失败:${d.error}`);
  1446. } else if (d.status === "running") {
  1447. if (isCurrent) {
  1448. btn.disabled = true;
  1449. btn.textContent = `♻️ 重评中 ${q}...`;
  1450. }
  1451. }
  1452. })
  1453. .catch(err => console.error("Poll error:", err));
  1454. };
  1455. poll();
  1456. reevalPollIntervals[q] = setInterval(poll, 3000);
  1457. }
  1458. // Spec Prompt Editor Functions
  1459. const ALLOWED_SPEC_FILES = [
  1460. "README.md",
  1461. "tools.md",
  1462. "extraction/phase1-skeleton.md",
  1463. "extraction/phase2-normalize.md",
  1464. "extraction/phase3-finalize.md",
  1465. "taxonomy/type_suggestions.md"
  1466. ];
  1467. function openSpecEditor() {
  1468. const select = document.getElementById("specFileSelect");
  1469. select.innerHTML = ALLOWED_SPEC_FILES.map(f => `<option value="${esc(f)}">${esc(f)}</option>`).join("");
  1470. document.getElementById("specLoadStatus").textContent = "";
  1471. document.getElementById("specSaveStatus").textContent = "";
  1472. document.getElementById("specContentTextarea").value = "";
  1473. const dialog = document.getElementById("specEditorDialog");
  1474. dialog.showModal();
  1475. loadSpecFileContent();
  1476. }
  1477. function loadSpecFileContent() {
  1478. const file = document.getElementById("specFileSelect").value;
  1479. const status = document.getElementById("specLoadStatus");
  1480. const textarea = document.getElementById("specContentTextarea");
  1481. status.textContent = "⏳ 正在读取...";
  1482. status.style.color = "var(--amber)";
  1483. textarea.disabled = true;
  1484. fetch(`/api/spec_content?file=${encodeURIComponent(file)}`)
  1485. .then(r => r.json().then(d => ({ ok: r.ok, d })))
  1486. .then(({ ok, d }) => {
  1487. textarea.disabled = false;
  1488. if (ok) {
  1489. textarea.value = d.content || "";
  1490. status.textContent = "✓ 读取成功";
  1491. status.style.color = "var(--mint)";
  1492. } else {
  1493. status.textContent = "❌ 读取失败: " + (d.error || "未知错误");
  1494. status.style.color = "var(--rose)";
  1495. }
  1496. })
  1497. .catch(err => {
  1498. textarea.disabled = false;
  1499. status.textContent = "❌ 读取失败: " + err;
  1500. status.style.color = "var(--rose)";
  1501. });
  1502. }
  1503. function saveSpecFileContent() {
  1504. const file = document.getElementById("specFileSelect").value;
  1505. const content = document.getElementById("specContentTextarea").value;
  1506. const status = document.getElementById("specSaveStatus");
  1507. status.textContent = "⏳ 正在保存到磁盘...";
  1508. status.style.color = "var(--amber)";
  1509. fetch("/api/save_spec", {
  1510. method: "POST",
  1511. headers: { "Content-Type": "application/json" },
  1512. body: JSON.stringify({ file, content })
  1513. })
  1514. .then(r => r.json().then(d => ({ ok: r.ok, d })))
  1515. .then(({ ok, d }) => {
  1516. if (ok) {
  1517. status.textContent = "✅ 保存成功!新的 Prompt 规则已在本地生效。";
  1518. status.style.color = "var(--mint)";
  1519. setTimeout(() => {
  1520. if (status.textContent.includes("保存成功")) {
  1521. status.textContent = "";
  1522. }
  1523. }, 4000);
  1524. } else {
  1525. status.textContent = "❌ 保存失败: " + (d.error || "未知错误");
  1526. status.style.color = "var(--rose)";
  1527. }
  1528. })
  1529. .catch(err => {
  1530. status.textContent = "❌ 网络错误: " + err;
  1531. status.style.color = "var(--rose)";
  1532. });
  1533. }
  1534. function esc(s) { return (s === undefined || s === null ? "" : String(s)).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;"); }
  1535. const ACTIONS = [{ "name": "检索", "l1": "获取", "l2": "搜索" }, { "name": "下载", "l1": "获取", "l2": "搜索" }, { "name": "调取", "l1": "获取", "l2": "查询" }, { "name": "上传", "l1": "获取", "l2": "录入" }, { "name": "拍摄", "l1": "获取", "l2": "录入" }, { "name": "录音", "l1": "获取", "l2": "录入" }, { "name": "键入", "l1": "获取", "l2": "录入" }, { "name": "选取", "l1": "获取", "l2": "引用" }, { "name": "裁切", "l1": "提取", "l2": "物理提取" }, { "name": "抠取", "l1": "提取", "l2": "物理提取" }, { "name": "抽帧", "l1": "提取", "l2": "物理提取" }, { "name": "识别", "l1": "提取", "l2": "化学提取" }, { "name": "反推", "l1": "提取", "l2": "化学提取" }, { "name": "解构", "l1": "提取", "l2": "化学提取" }, { "name": "元素生成", "l1": "生成", "l2": "元素生成" }, { "name": "数组生成", "l1": "生成", "l2": "关系生成" }, { "name": "结构生成", "l1": "生成", "l2": "关系生成" }, { "name": "添加", "l1": "修改", "l2": "增" }, { "name": "叠加", "l1": "修改", "l2": "增" }, { "name": "抹除", "l1": "修改", "l2": "删" }, { "name": "剪除", "l1": "修改", "l2": "删" }, { "name": "重述", "l1": "修改", "l2": "变" }, { "name": "风格化", "l1": "修改", "l2": "变" }, { "name": "转换", "l1": "修改", "l2": "变" }, { "name": "替换", "l1": "修改", "l2": "变" }, { "name": "调整", "l1": "修改", "l2": "变" }, { "name": "增强", "l1": "修改", "l2": "变" }];
  1536. const TYPES = [{ "name": "提示词", "l1": "程序控制类型", "l2": "指令" }, { "name": "负向提示词", "l1": "程序控制类型", "l2": "指令" }, { "name": "描述", "l1": "程序控制类型", "l2": "指令" }, { "name": "生成参数", "l1": "程序控制类型", "l2": "参数" }, { "name": "规格参数", "l1": "程序控制类型", "l2": "参数" }, { "name": "模型权重", "l1": "程序控制类型", "l2": "参数" }, { "name": "评分", "l1": "程序控制类型", "l2": "评估" }, { "name": "评语", "l1": "程序控制类型", "l2": "评估" }, { "name": "工作流", "l1": "程序控制类型", "l2": "流程" }, { "name": "批处理", "l1": "程序控制类型", "l2": "流程" }, { "name": "数字人", "l1": "数据复用类型", "l2": "原子" }, { "name": "版式", "l1": "数据复用类型", "l2": "原子" }, { "name": "模板", "l1": "数据复用类型", "l2": "序列" }, { "name": "参考图", "l1": "内容类型", "l2": "素材/化学变化" }, { "name": "参考视频", "l1": "内容类型", "l2": "素材/化学变化" }, { "name": "参考音频", "l1": "内容类型", "l2": "素材/化学变化" }, { "name": "对标内容", "l1": "内容类型", "l2": "素材/化学变化" }, { "name": "分镜图", "l1": "内容类型", "l2": "素材/化学变化" }, { "name": "转场", "l1": "内容类型", "l2": "素材/化学变化" }, { "name": "蒙版", "l1": "内容类型", "l2": "素材/化学变化" }, { "name": "控制图", "l1": "内容类型", "l2": "素材/化学变化" }, { "name": "运动轨迹", "l1": "内容类型", "l2": "素材/化学变化" }, { "name": "滤镜", "l1": "内容类型", "l2": "素材/化学变化" }, { "name": "构图布局", "l1": "内容类型", "l2": "素材/化学变化" }, { "name": "截图", "l1": "内容类型", "l2": "素材/物理变化" }, { "name": "视频片段", "l1": "内容类型", "l2": "素材/物理变化" }, { "name": "转场片段", "l1": "内容类型", "l2": "素材/物理变化" }, { "name": "关键帧", "l1": "内容类型", "l2": "素材/物理变化" }, { "name": "音效", "l1": "内容类型", "l2": "素材/物理变化" }, { "name": "特效", "l1": "内容类型", "l2": "素材/物理变化" }, { "name": "大纲", "l1": "内容类型", "l2": "半成品/序列" }, { "name": "脚本", "l1": "内容类型", "l2": "半成品/序列" }, { "name": "分镜脚本", "l1": "内容类型", "l2": "半成品/序列" }, { "name": "剪辑脚本", "l1": "内容类型", "l2": "半成品/序列" }, { "name": "配音文案", "l1": "内容类型", "l2": "半成品/序列" }, { "name": "底图", "l1": "内容类型", "l2": "半成品/原子" }, { "name": "样图", "l1": "内容类型", "l2": "半成品/原子" }, { "name": "分镜视频", "l1": "内容类型", "l2": "半成品/原子" }, { "name": "图层组合", "l1": "内容类型", "l2": "半成品/组合" }, { "name": "拼图", "l1": "内容类型", "l2": "半成品/组合" }, { "name": "歌词", "l1": "内容类型", "l2": "准成品" }, { "name": "配音", "l1": "内容类型", "l2": "准成品" }, { "name": "BGM", "l1": "内容类型", "l2": "准成品" }, { "name": "字幕", "l1": "内容类型", "l2": "准成品" }, { "name": "标题", "l1": "内容类型", "l2": "准成品" }, { "name": "正文", "l1": "内容类型", "l2": "准成品" }, { "name": "成品图", "l1": "内容类型", "l2": "成品" }, { "name": "视频成品", "l1": "内容类型", "l2": "成品" }, { "name": "合成图", "l1": "内容类型", "l2": "成品" }, { "name": "知识库", "l1": "知识类型", "l2": "知识库" }];
  1537. const POOLS = { "action_leaves": { "检索": ["找", "搜", "哪里找", "在哪找", "搜索"], "下载": ["下载", "怎么下载", "获取", "导入"], "调取": ["复用", "调用", "套用", "加载"], "上传": ["上传", "导入", "怎么导入", "用自己的"], "拍摄": ["拍", "拍摄", "录制", "录屏", "怎么拍"], "录音": ["录音", "录", "怎么录", "录制"], "键入": ["写", "输入", "怎么写", "编写"], "选取": ["挑选", "怎么选", "筛选", "选"], "裁切": ["裁剪", "截取", "怎么裁", "切片"], "抠取": ["抠图", "抠", "分割", "怎么抠"], "抽帧": ["抽帧", "提取帧", "怎么抽帧", "导出帧"], "识别": ["识别", "检测", "OCR", "提取文字", "转录"], "反推": ["反推", "分析", "推断", "怎么反推"], "解构": ["拆解", "解构", "分析结构"], "元素生成": ["生成", "制作", "怎么做", "做", "创作"], "数组生成": ["批量生成", "生成多张", "怎么批量", "批量做"], "结构生成": ["生成", "搭建", "怎么生成", "构建"], "添加": ["添加", "加", "怎么加", "加上"], "叠加": ["叠加", "合成", "叠", "加"], "抹除": ["去除", "去掉", "怎么去掉", "抹除", "消除"], "剪除": ["剪掉", "删掉", "怎么剪", "截短"], "重述": ["改写", "润色", "怎么改", "重写"], "风格化": ["风格化", "转风格", "风格迁移", "怎么转风格"], "转换": ["转换", "转", "怎么转", "转格式"], "替换": ["替换", "换", "怎么换", "替换成"], "调整": ["调整", "调", "怎么调", "优化"], "增强": ["增强", "提升画质", "怎么增强", "修复", "超分"] }, "types": { "提示词": ["提示词", "prompt", "咒语"], "负向提示词": ["负向提示词", "反向提示词", "negative prompt"], "描述": ["描述", "描述词", "提示描述"], "生成参数": ["参数", "出图参数", "生成参数", "seed"], "规格参数": ["尺寸", "分辨率", "画幅", "规格"], "模型权重": ["模型", "LoRA", "底模", "checkpoint"], "评分": ["评分", "打分", "评级"], "评语": ["评语", "点评", "反馈", "修改意见"], "工作流": ["工作流", "workflow", "流程图", "节点"], "批处理": ["批处理", "批量", "batch"], "数字人": ["数字人", "虚拟人", "数字分身", "AI分身"], "版式": ["版式", "排版", "版面", "layout"], "模板": ["模板", "template", "套版"], "参考图": ["参考图", "参考", "垫图", "ref"], "参考视频": ["参考视频", "参考片", "参考素材"], "参考音频": ["参考音频", "参考音色", "音色样本"], "对标内容": ["对标", "爆款参考", "竞品", "标杆案例"], "分镜图": ["分镜图", "分镜", "故事板", "storyboard"], "转场": ["转场", "转场效果", "transition"], "蒙版": ["蒙版", "抠像", "遮罩", "mask"], "控制图": ["控制图", "ControlNet", "结构图", "线稿"], "运动轨迹": ["运镜", "运动轨迹", "运动笔刷", "motion brush"], "滤镜": ["滤镜", "filter", "调色", "LUT"], "构图布局": ["构图", "布局", "构图布局"], "截图": ["截图", "屏幕截图", "截屏"], "视频片段": ["视频片段", "片段", "素材", "clip"], "转场片段": ["转场片段", "转场素材"], "关键帧": ["关键帧", "帧", "视频帧"], "音效": ["音效", "声音", "SFX", "音效素材"], "特效": ["特效", "视频特效", "VFX", "effect"], "大纲": ["大纲", "内容大纲", "提纲"], "脚本": ["脚本", "文案脚本", "剧本"], "分镜脚本": ["分镜脚本", "分镜表", "分镜"], "剪辑脚本": ["剪辑脚本", "剪辑表", "卡点表", "时间轴"], "配音文案": ["配音文案", "口播文案", "旁白文案"], "底图": ["底图", "背景图", "打底图"], "样图": ["样图", "效果图", "候选图", "draft"], "分镜视频": ["分镜视频", "分镜片段"], "图层组合": ["图层组合", "图层", "图层合成"], "拼图": ["拼图", "九宫格", "长图", "对比图"], "歌词": ["歌词", "词", "lyrics"], "配音": ["配音", "旁白", "解说", "人声"], "BGM": ["BGM", "背景音乐", "配乐"], "字幕": ["字幕", "视频字幕", "字幕条"], "标题": ["标题", "文案标题", "爆款标题"], "正文": ["正文", "文案", "内容正文"], "成品图": ["成品图", "出图", "图", "海报"], "视频成品": ["视频成品", "成片", "视频"], "合成图": ["合成图", "拼合图", "融合图", "合成"], "知识库": ["知识库", "资料库", "knowledge base"] }, "knowledge": { "工序": { "单步": ["教程", "流程", "步骤", "怎么做", "方法", "教学"], "全程": ["完整流程", "全流程", "pipeline", "SOP"] }, "能力": { "标记": ["一键", "自动", "直出", "秒出"], "达成": ["同款", "复刻", "效果"], "载体": ["提示词", "参数", "预设", "公式"] }, "工具": { "发现": ["用什么软件", "用什么工具", "工具推荐", "哪个好用", "有哪些工具"] } }, "tool_type": { "AI 模型": ["AI"], "桌面 APP": ["软件", "电脑端"], "云端 Web": ["在线", "网页版"], "API·CLI": ["代码", "命令行"], "插件扩展": ["插件"] } };
  1538. const TOOL_TYPES = ["AI 模型", "桌面 APP", "云端 Web", "API·CLI", "插件扩展"];
  1539. const GMODEL = "gemini-3.1-flash-lite";
  1540. const AL = POOLS.action_leaves, TP = POOLS.types, KN = POOLS.knowledge, TQ = POOLS.tool_type;
  1541. function aPool(a) { return AL[a] || [a]; }
  1542. function tPool(t) { return TP[t] || [t]; }
  1543. function pick(arr, i) { return arr[Math.min(i, arr.length - 1)]; }
  1544. function toolPrefix(lens) { return (st.tools.length && lens !== '工具') ? st.tools.map(t => TQ[t][0]).join('/') + ' ' : ''; }
  1545. function genForms(leaf, ty, lens, tq) {
  1546. tq = tq || ''; const aP = aPool(leaf), tP = tPool(ty);
  1547. const aNat = aP[0], tNat = tP[0], aSyn = pick(aP, 1), tSyn = pick(tP, 1), K = KN[lens];
  1548. if (lens === '工序') {
  1549. const s = K['单步'];
  1550. return [['①原词', `${tq}${leaf} ${ty} 流程`], ['②句子', `${tq}怎么${aNat}${tNat}`], ['③同义', `${tq}${aSyn} ${tSyn} ${pick(s, 2)}`]];
  1551. }
  1552. if (lens === '能力') {
  1553. const mk = K['标记'];
  1554. return [['①原词', `${tq}${leaf} ${ty} 技巧`], ['②句子', `${tq}有没有能${mk[0]}${aNat}${tNat}的功能`], ['③同义', `${tq}${pick(mk, 1)} ${aSyn}${tSyn}`]];
  1555. }
  1556. const fd = K['发现'];
  1557. return [['①原词', `${leaf} ${ty} 工具`], ['②句子', `${aNat}${tNat}用什么软件好`], ['③同义', `${aSyn} ${tSyn} ${pick(fd, 2)}`]];
  1558. }
  1559. const FIDX = { A: 0, B: 1, C: 2 };
  1560. function genQ(leaf, ty) { return genForms(leaf, ty, st.lens, toolPrefix(st.lens))[FIDX[st.form]][1]; }
  1561. // 兼容老版 1-5 维度的英文和中文对应标签
  1562. const commonLabels = { relevance: "相关性", result_quality: "成品质量", credibility: "可信度", novelty_coverage: "新增覆盖", concrete_use_case: "具体用例", completeness: "流程完整", step_structure: "步骤结构", step_reproducibility: "可复现性", capability_definition: "能力定义", implementation_depth: "实现深度", boundary_failure_eval: "边界/踩坑", generality: "通用性", capability_coverage: "工具覆盖", effective_comparison: "有效对比", param_specificity: "参数具体", worked_example: "示例完整", version_limits: "限制说明" };
  1563. const filterLabels = { production_relevance: "制作相关性", recency_hard: "发布时效", overall: "综合均分" };
  1564. const filterMax = { production_relevance: 3, recency_hard: 3, overall: 5 };
  1565. // 新版 0-10 分数维度的中文标签
  1566. const newLabels = {
  1567. relevance_production: "和内容制作知识相关",
  1568. relevance_query: "和 query 相关",
  1569. recency: "时效性",
  1570. popularity: "热度性",
  1571. feedback: "评论反馈",
  1572. realism: "真实感 (非AI)",
  1573. expressiveness: "表现力",
  1574. procedure_completeness: "流程完整性",
  1575. procedure_input: "输入完整性",
  1576. procedure_implementation: "实现完整性",
  1577. procedure_output: "输出完整性",
  1578. procedure_generality: "泛化性",
  1579. step_input: "输入完整性",
  1580. step_implementation: "实现完整性",
  1581. step_output: "输出完整性",
  1582. step_generality: "泛化性",
  1583. tool_boundary: "能力边界覆盖",
  1584. tool_comparison: "有效比较",
  1585. tool_specificity: "参数/接口具体性",
  1586. tool_example: "实操示例",
  1587. tool_limits: "版本&限制"
  1588. };
  1589. const scoreGroupsOld = [
  1590. { id: "filter", title: "过滤指标", short: "过滤", hint: "独立于通用维度·过滤逻辑待定", topLevelKeys: ["production_relevance", "recency_hard", "overall"] },
  1591. { id: "common", title: "通用维度", short: "通用", keys: ["relevance", "result_quality", "credibility", "novelty_coverage", "concrete_use_case"] },
  1592. { id: "procedure", title: "工序维度", short: "工序", keys: ["completeness", "step_structure", "step_reproducibility"] },
  1593. { id: "step", title: "步骤维度", short: "步骤", keys: ["capability_definition", "implementation_depth", "boundary_failure_eval", "generality"] },
  1594. { id: "tool", title: "工具维度", short: "工具", keys: ["capability_coverage", "effective_comparison", "param_specificity", "worked_example", "version_limits"] }
  1595. ];
  1596. const scoreGroupsNew = [
  1597. { id: "relevance", title: "相关性", short: "相关", keys: ["relevance_production", "relevance_query"] },
  1598. { id: "fixed", title: "固定维度", short: "固定", keys: ["recency", "popularity", "feedback"] },
  1599. { id: "usecase", title: "用例维度", short: "用例", keys: ["realism", "expressiveness"] },
  1600. { id: "dynamic", title: "动态维度", short: "动态", keys: [] }
  1601. ];
  1602. function makeRow(label, scoreKey, it) {
  1603. const rawV = it.scores[scoreKey];
  1604. const v = (rawV !== undefined && rawV !== null) ? parseFloat(rawV) : NaN;
  1605. const hasScore = !isNaN(v);
  1606. const valStr = hasScore ? (Number.isInteger(v) ? v : v.toFixed(1)) : '-';
  1607. const barV = hasScore ? v : 0;
  1608. const reason = it.score_reasons ? it.score_reasons[scoreKey] : '';
  1609. const infoIcon = reason ? `<span class="info-icon" onclick="pinScoreReason(this, '${esc(label)}', '${esc(scoreKey)}')" title="点击定格查看评判理由" style="margin-left: 5px; cursor: pointer; color: var(--muted); opacity: 0.7; font-size: 13px; font-weight: normal; user-select: none;">ⓘ</span>` : '';
  1610. return `
  1611. <div class="sc-row ${!hasScore ? 'missing' : ''}">
  1612. <span class="label">${esc(label)}</span>
  1613. <div class="bar-wrap">
  1614. <div class="bar">
  1615. <div class="bar-fill" style="--v: ${barV}"></div>
  1616. </div>
  1617. <span class="value">${valStr}</span>
  1618. ${infoIcon}
  1619. </div>
  1620. </div>
  1621. `;
  1622. }
  1623. function getQualityAverage(it) {
  1624. if (!it.scores) return null;
  1625. const keys = ["recency", "popularity", "feedback", "realism", "expressiveness"];
  1626. if (it.knowledge_type && (it.knowledge_type.includes("procedure") || it.knowledge_type.includes("工序"))) {
  1627. keys.push("procedure_completeness", "procedure_input", "procedure_implementation", "procedure_output", "procedure_generality");
  1628. }
  1629. if (it.knowledge_type && (it.knowledge_type.includes("step") || it.knowledge_type.includes("能力") || it.knowledge_type.includes("步骤"))) {
  1630. keys.push("step_input", "step_implementation", "step_output", "step_generality");
  1631. }
  1632. if (it.knowledge_type && (it.knowledge_type.includes("tool") || it.knowledge_type.includes("工具"))) {
  1633. keys.push("tool_boundary", "tool_comparison", "tool_specificity", "tool_example", "tool_limits");
  1634. }
  1635. const vs = keys.map(k => parseFloat(it.scores[k])).filter(v => !isNaN(v));
  1636. return vs.length ? vs.reduce((a, b) => a + b, 0) / vs.length : null;
  1637. }
  1638. function renderNewScores(it) {
  1639. // 1. Relevance Card
  1640. const relAvg = groupAverage(it, scoreGroupsNew[0], true);
  1641. const relAvgStr = relAvg !== null ? relAvg.toFixed(1) : 'N/A';
  1642. let relevanceHtml = `
  1643. <div class="sc-card">
  1644. <div class="sc-card-head">
  1645. <div class="title"><span class="badge">01</span>相关性</div>
  1646. <div class="avg-score">avg <strong>${relAvgStr}</strong><span style="font-size: 13px; color: #9ca3af; font-weight: 500;">/10</span></div>
  1647. </div>
  1648. <div class="sc-card-body">
  1649. ${makeRow("和内容制作知识相关", "relevance_production", it)}
  1650. ${makeRow("和 query 相关", "relevance_query", it)}
  1651. </div>
  1652. </div>
  1653. `;
  1654. // 2. Quality Card
  1655. const qualAvg = getQualityAverage(it);
  1656. const qualAvgStr = qualAvg !== null ? qualAvg.toFixed(1) : 'N/A';
  1657. let qualityHtml = `
  1658. <div class="sc-card">
  1659. <div class="sc-card-head">
  1660. <div class="title"><span class="badge">02</span>质量</div>
  1661. <div class="avg-score">avg <strong>${qualAvgStr}</strong><span style="font-size: 13px; color: #9ca3af; font-weight: 500;">/10</span></div>
  1662. </div>
  1663. <div class="sc-card-body">
  1664. <div class="sc-sub-header">固定维度</div>
  1665. ${makeRow("时效性", "recency", it)}
  1666. ${makeRow("热度性", "popularity", it)}
  1667. ${makeRow("评论反馈", "feedback", it)}
  1668. <div class="sc-sub-header">用例</div>
  1669. ${makeRow("真实感 (非AI)", "realism", it)}
  1670. ${makeRow("表现力", "expressiveness", it)}
  1671. `;
  1672. // Dynamic Dimensions
  1673. let dynamicHtml = '';
  1674. if (it.knowledge_type && (it.knowledge_type.includes("procedure") || it.knowledge_type.includes("工序"))) {
  1675. dynamicHtml += `
  1676. <div class="sc-sub-header">工序</div>
  1677. ${makeRow("流程完整性", "procedure_completeness", it)}
  1678. ${makeRow("输入完整性", "procedure_input", it)}
  1679. ${makeRow("实现完整性", "procedure_implementation", it)}
  1680. ${makeRow("输出完整性", "procedure_output", it)}
  1681. ${makeRow("泛化性", "procedure_generality", it)}
  1682. `;
  1683. }
  1684. if (it.knowledge_type && (it.knowledge_type.includes("step") || it.knowledge_type.includes("能力") || it.knowledge_type.includes("步骤"))) {
  1685. dynamicHtml += `
  1686. <div class="sc-sub-header">能力</div>
  1687. ${makeRow("输入完整性", "step_input", it)}
  1688. ${makeRow("实现完整性", "step_implementation", it)}
  1689. ${makeRow("输出完整性", "step_output", it)}
  1690. ${makeRow("泛化性", "step_generality", it)}
  1691. `;
  1692. }
  1693. if (it.knowledge_type && (it.knowledge_type.includes("tool") || it.knowledge_type.includes("工具"))) {
  1694. dynamicHtml += `
  1695. <div class="sc-sub-header">工具</div>
  1696. ${makeRow("能力边界覆盖", "tool_boundary", it)}
  1697. ${makeRow("有效比较", "tool_comparison", it)}
  1698. ${makeRow("参数/接口具体性", "tool_specificity", it)}
  1699. ${makeRow("实操示例", "tool_example", it)}
  1700. ${makeRow("版本&限制", "tool_limits", it)}
  1701. `;
  1702. }
  1703. qualityHtml += dynamicHtml + `
  1704. </div>
  1705. </div>
  1706. `;
  1707. return relevanceHtml + qualityHtml;
  1708. }
  1709. function isItemDiscarded(it) {
  1710. if (it.anomaly) return false;
  1711. const input = document.getElementById("relThreshold");
  1712. const userThreshold = input ? parseFloat(input.value) : NaN;
  1713. const isNewSchema = it.scores && (it.scores.relevance_production !== undefined || it.scores.relevance_query !== undefined);
  1714. let isDiscard = false;
  1715. // 1. Relevance check
  1716. const relVal = it.production_relevance !== null && it.production_relevance !== undefined ? parseFloat(it.production_relevance) : null;
  1717. if (relVal !== null && !isNaN(relVal)) {
  1718. const activeThreshold = !isNaN(userThreshold) ? userThreshold : (isNewSchema ? 4.0 : 2.0);
  1719. if (relVal < activeThreshold) {
  1720. isDiscard = true;
  1721. }
  1722. }
  1723. // 2. Recency check
  1724. if (it.recency_hard !== null && it.recency_hard !== undefined && it.recency_hard < 2) {
  1725. isDiscard = true;
  1726. }
  1727. // 3. Overall average check
  1728. if (it.overall !== null && it.overall !== undefined) {
  1729. const threshold_ov = isNewSchema ? 6.0 : 3.0;
  1730. if (it.overall < threshold_ov) {
  1731. isDiscard = true;
  1732. }
  1733. }
  1734. return isDiscard;
  1735. }
  1736. function updateThresholdLimits() {
  1737. const f = curForm();
  1738. const input = document.getElementById("relThreshold");
  1739. if (!f || !f.results || f.results.length === 0 || !input) return;
  1740. const isNew = f.results.some(r => r.scores && (r.scores.relevance_production !== undefined || r.scores.relevance_query !== undefined));
  1741. const schemaKey = isNew ? "new" : "old";
  1742. if (input.dataset.schema !== schemaKey) {
  1743. input.dataset.schema = schemaKey;
  1744. input.max = isNew ? "10" : "5";
  1745. input.value = isNew ? "4.0" : "2.0";
  1746. input.step = isNew ? "0.5" : "1";
  1747. }
  1748. }
  1749. const PLATC = { xhs: "小红书", gzh: "公众号", zhihu: "知乎", x: "X", bili: "B站", douyin: "抖音", sph: "视频号", youtube: "YouTube", github: "GitHub", toutiao: "头条", weibo: "微博" };
  1750. const FN = { A: "原词", B: "句子", C: "同义" };
  1751. const NOIMG = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='600' height='400'%3E%3Crect width='600' height='400' fill='%23eee7dc'/%3E%3Ctext x='50%25' y='50%25' dominant-baseline='middle' text-anchor='middle' fill='%236f6961' font-size='28'%3ENo image%3C/text%3E%3C/svg%3E";
  1752. function curForm() { return st.qi === -1 ? null : (DATA.queries[st.qi] ? DATA.queries[st.qi].forms[st.fi] : null); }
  1753. function groupAverage(it, g, isNewSchema) {
  1754. if (!it.scores) return null;
  1755. let keys = g.keys;
  1756. if (isNewSchema && g.id === "dynamic") {
  1757. keys = [];
  1758. if (it.knowledge_type && (it.knowledge_type.includes("procedure") || it.knowledge_type.includes("工序"))) {
  1759. keys.push("procedure_completeness", "procedure_input", "procedure_implementation", "procedure_output", "procedure_generality");
  1760. }
  1761. if (it.knowledge_type && (it.knowledge_type.includes("step") || it.knowledge_type.includes("能力") || it.knowledge_type.includes("步骤"))) {
  1762. keys.push("step_input", "step_implementation", "step_output", "step_generality");
  1763. }
  1764. if (it.knowledge_type && (it.knowledge_type.includes("tool") || it.knowledge_type.includes("工具"))) {
  1765. keys.push("tool_boundary", "tool_comparison", "tool_specificity", "tool_example", "tool_limits");
  1766. }
  1767. }
  1768. const vs = keys.map(k => parseFloat(it.scores[k])).filter(v => !isNaN(v));
  1769. return vs.length ? vs.reduce((a, b) => a + b, 0) / vs.length : null;
  1770. }
  1771. function fmt(v) { return v === null ? "N/A" : v.toFixed(1); }
  1772. function groupSnapshot(it) {
  1773. const isNewSchema = it.scores && (it.scores.relevance_production !== undefined || it.scores.relevance_query !== undefined);
  1774. if (isNewSchema) {
  1775. const relAvg = groupAverage(it, scoreGroupsNew[0], true);
  1776. const qualAvg = getQualityAverage(it);
  1777. return `
  1778. <div class="group-pill"><span>相关</span><strong>${fmt(relAvg)}</strong></div>
  1779. <div class="group-pill"><span>质量</span><strong>${fmt(qualAvg)}</strong></div>
  1780. `;
  1781. }
  1782. const groups = scoreGroupsOld;
  1783. return groups.map(g => {
  1784. if (!isNewSchema && g.id === 'filter') {
  1785. const pr = it.production_relevance, rh = it.recency_hard, ov = it.overall;
  1786. const f = (v, max) => (v == null || !Number.isFinite(v)) ? '-' : (max === 5 ? (typeof v === 'number' ? v.toFixed(1) : v) : v);
  1787. return `<div class="group-pill" title="${g.hint || ''}"><span>${g.short}</span><strong style="font-size:12px;">${f(pr, 3)}·${f(rh, 3)}·${f(ov, 5)}</strong></div>`;
  1788. }
  1789. const a = groupAverage(it, g, isNewSchema);
  1790. return `<div class="group-pill"><span>${g.short}</span><strong>${fmt(a)}</strong></div>`;
  1791. }).join("");
  1792. }
  1793. // filter 组:数据从 it 顶层、量程按 filterMax 归一化到 5 量程(meter 的 --v*20% 公式不动)
  1794. function renderScoreGroup(it, g) {
  1795. const isFilter = g.id === 'filter';
  1796. const keys = g.topLevelKeys || g.keys;
  1797. const src = isFilter ? it : it.scores;
  1798. if (!src) return '';
  1799. const labels = isFilter ? filterLabels : commonLabels;
  1800. const rows = keys.map(k => {
  1801. const v = src[k];
  1802. const m = !Number.isFinite(v);
  1803. const max = isFilter ? (filterMax[k] || 5) : 5;
  1804. const meterV = m ? 0 : (v * 5 / max);
  1805. const suffix = isFilter && max !== 5 ? `/${max}` : '';
  1806. const valStr = m ? '-' : (typeof v === 'number' ? (Number.isInteger(v) ? v : v.toFixed(1)) : v);
  1807. const reason = (it.score_reasons) ? it.score_reasons[k] : '';
  1808. const infoIcon = reason ? `<span class="info-icon" onclick="pinScoreReason(this, '${esc(labels[k] || k)}', '${esc(k)}')" title="点击定格查看评判理由" style="margin-left: 5px; cursor: pointer; color: var(--muted); opacity: 0.7; font-size: 11px; font-weight: normal; user-select: none;">ⓘ</span>` : '';
  1809. return `<div class="score-row ${m ? 'missing' : ''}"><span>${labels[k] || k}</span><div class="meter" style="--v:${meterV}"><span></span></div><strong style="display: inline-flex; align-items: center;">${valStr}${suffix}${infoIcon}</strong></div>`;
  1810. }).join("");
  1811. const headRight = isFilter ? (g.hint ? `<small>${g.hint}</small>` : '') : `<small>均分 ${fmt(groupAverage(it, g))}</small>`;
  1812. return `<section class="score-group"><div class="score-group-head"><span>${g.title}</span>${headRight}</div><div class="score-group-body">${rows}</div></section>`;
  1813. }
  1814. function curDims() {
  1815. if (st.qi === -1) { if (openCell) { const ai = +openCell.dataset.ai, ti = +openCell.dataset.ti; return { type: TYPES[ti].name, action: ACTIONS[ai].name }; } return {}; }
  1816. const q = DATA.queries[st.qi]; return (q && q.dims) ? q.dims : {};
  1817. }
  1818. function spans(arr, key) { const o = []; let cur = null, s = 0; arr.forEach((x, i) => { if (x[key] !== cur) { if (cur !== null) o.push([cur, s, i - s]); cur = x[key]; s = i; } }); o.push([cur, s, arr.length - s]); return o; }
  1819. const l1sp = spans(ACTIONS, 'l1'), l2sp = spans(ACTIONS, 'l2');
  1820. const l1Start = new Set(l1sp.map(s => s[1])), l2Start = new Set(l2sp.map(s => s[1]));
  1821. function detectLens(q) {
  1822. const text = (q.original_q || (q.forms && q.forms[0] && q.forms[0].query) || "").toLowerCase();
  1823. if (/流程|步骤|教程|方法|教学|SOP|pipeline|工序/.test(text)) return '工序';
  1824. if (/一键|自动|直出|秒出|同款|复刻|效果|技巧|能力/.test(text)) return '能力';
  1825. if (/用什么|软件|工具|推荐|哪个好用|有哪些/.test(text)) return '工具';
  1826. return '工序';
  1827. }
  1828. function findQuery(aName, tName, lens, tool) {
  1829. const matches = DATA.queries.filter(q => {
  1830. if (!q.dims || q.dims.action !== aName || q.dims.type !== tName) return false;
  1831. const qLens = detectLens(q);
  1832. if (qLens !== lens) return false;
  1833. const hasToolConstraint = q.dims.constraint && q.dims.constraint.kind === "工具类型";
  1834. if (tool) {
  1835. if (!hasToolConstraint || q.dims.constraint.value !== tool) return false;
  1836. }
  1837. return true;
  1838. });
  1839. if (matches.length > 0) {
  1840. matches.sort((x, y) => {
  1841. if (!tool) {
  1842. const hasX = x.dims.constraint && x.dims.constraint.kind === "工具类型";
  1843. const hasY = y.dims.constraint && y.dims.constraint.kind === "工具类型";
  1844. if (hasX !== hasY) return hasX ? 1 : -1;
  1845. }
  1846. return (y.hits || 0) - (x.hits || 0);
  1847. });
  1848. return matches[0];
  1849. }
  1850. return null;
  1851. }
  1852. function selectQueryByActiveCellAndControls(aName, tName) {
  1853. const activeTool = st.tools[0] || null;
  1854. let match = findQuery(aName, tName, st.lens, activeTool);
  1855. const isProcedureView = st.matrixView === 'procedures';
  1856. const isHitsView = st.matrixView === 'hits';
  1857. const hasContent = q => {
  1858. if (isProcedureView) return getFormProcedureCount(q) > 0;
  1859. if (isHitsView) return getFormReportCount(q) > 0;
  1860. return q.hits > 0;
  1861. };
  1862. if (match) {
  1863. st.qi = DATA.queries.indexOf(match);
  1864. const fi = match.forms.findIndex(f => f.form === st.form);
  1865. st.fi = fi >= 0 ? fi : 0;
  1866. st.selectedAction = aName;
  1867. st.selectedType = tName;
  1868. } else {
  1869. // Fallback: search for any query matching active lens & tool constraint with hits
  1870. const matches = DATA.queries.filter(q => {
  1871. if (!q.dims || !q.dims.action || !q.dims.type) return false;
  1872. const qLens = detectLens(q);
  1873. if (qLens !== st.lens) return false;
  1874. const hasToolConstraint = q.dims.constraint && q.dims.constraint.kind === "工具类型";
  1875. if (activeTool) {
  1876. if (!hasToolConstraint || q.dims.constraint.value !== activeTool) return false;
  1877. } else {
  1878. if (hasToolConstraint) return false;
  1879. }
  1880. return hasContent(q);
  1881. });
  1882. if (matches.length > 0) {
  1883. matches.sort((x, y) => {
  1884. if (!activeTool) {
  1885. const hasX = x.dims.constraint && x.dims.constraint.kind === "工具类型";
  1886. const hasY = y.dims.constraint && y.dims.constraint.kind === "工具类型";
  1887. if (hasX !== hasY) return hasX ? 1 : -1;
  1888. }
  1889. const countX = isProcedureView ? getFormProcedureCount(x) : (isHitsView ? getFormReportCount(x) : x.hits);
  1890. const countY = isProcedureView ? getFormProcedureCount(y) : (isHitsView ? getFormReportCount(y) : y.hits);
  1891. return countY - countX;
  1892. });
  1893. const anyMatch = matches[0];
  1894. st.qi = DATA.queries.indexOf(anyMatch);
  1895. const fi = anyMatch.forms.findIndex(f => f.form === st.form);
  1896. st.fi = fi >= 0 ? fi : 0;
  1897. st.selectedAction = anyMatch.dims.action;
  1898. st.selectedType = anyMatch.dims.type;
  1899. } else {
  1900. st.qi = -1;
  1901. st.fi = 0;
  1902. }
  1903. }
  1904. }
  1905. function getFormReportCount(q) {
  1906. const f = q.forms && q.forms.find(x => x.form === st.form);
  1907. if (!f || !f.results) return 0;
  1908. return f.results.filter(r => !r.anomaly && !isItemDiscarded(r)).length;
  1909. }
  1910. function getFormProcedureCount(q) {
  1911. const f = q.forms && q.forms.find(x => x.form === st.form);
  1912. if (!f || !f.results) return 0;
  1913. return f.results.filter(r => !r.anomaly && !isItemDiscarded(r) && r.procedure_html).length;
  1914. }
  1915. function getFilteredHitsMap() {
  1916. const cm = {};
  1917. const activeTool = st.tools[0] || null;
  1918. const isProcedureView = st.matrixView === 'procedures';
  1919. DATA.queries.forEach((q, i) => {
  1920. const d = q.dims;
  1921. if (!d || !d.type || !d.action) return;
  1922. // Filter by lens
  1923. if (detectLens(q) !== st.lens) return;
  1924. // Filter by active tool constraint
  1925. const hasToolConstraint = d.constraint && d.constraint.kind === "工具类型";
  1926. if (activeTool) {
  1927. if (!hasToolConstraint || d.constraint.value !== activeTool) return;
  1928. } else {
  1929. if (hasToolConstraint) return;
  1930. }
  1931. const k = d.type + '|' + d.action;
  1932. const h = isProcedureView ? getFormProcedureCount(q) : getFormReportCount(q);
  1933. if (!cm[k] || h > cm[k].hits) {
  1934. cm[k] = { i, hits: h };
  1935. }
  1936. });
  1937. return cm;
  1938. }
  1939. function renderMatrix() {
  1940. const viewMode = st.matrixView || 'full';
  1941. const showFull = viewMode === 'full';
  1942. const cm = getFilteredHitsMap();
  1943. const activeActions = showFull ? ACTIONS : ACTIONS.filter(a => TYPES.some(t => {
  1944. const c = cm[t.name + '|' + a.name];
  1945. return c && c.hits > 0;
  1946. }));
  1947. const activeTypes = showFull ? TYPES : TYPES.filter(t => ACTIONS.some(a => {
  1948. const c = cm[t.name + '|' + a.name];
  1949. return c && c.hits > 0;
  1950. }));
  1951. const displayActions = activeActions.length ? activeActions : ACTIONS;
  1952. const displayTypes = activeTypes.length ? activeTypes : TYPES;
  1953. const l1sp = spans(displayActions, 'l1'), l2sp = spans(displayActions, 'l2');
  1954. const l1Start = new Set(l1sp.map(s => s[1])), l2Start = new Set(l2sp.map(s => s[1]));
  1955. let h = '<thead><tr class="l1"><th class="corner" rowspan="3">类型 \ 动作</th>' + l1sp.map(([v, s, c]) => `<th colspan="${c}" class="l1div">${v}</th>`).join('') + '</tr>';
  1956. h += '<tr class="l2">' + l2sp.map(([v, s, c]) => `<th colspan="${c}" class="${l1Start.has(s) ? 'l1div' : 'l2div'}">${v}</th>`).join('') + '</tr>';
  1957. h += '<tr class="leaf">' + displayActions.map((a, i) => `<th data-ai="${ACTIONS.indexOf(a)}" class="${l1Start.has(i) ? 'l1div' : (l2Start.has(i) ? 'l2div' : '')}">${a.name}</th>`).join('') + '</tr></thead><tbody>';
  1958. const typeCategories = ['程序控制类型', '数据复用类型', '内容类型', '知识类型'];
  1959. typeCategories.forEach(l1 => {
  1960. const catTypes = displayTypes.filter(t => t.l1 === l1);
  1961. if (catTypes.length === 0) return;
  1962. h += `<tr class="l1row"><td colspan="${displayActions.length + 1}">${l1}</td></tr>`;
  1963. catTypes.forEach((t) => {
  1964. h += `<tr data-type="${t.name}"><th class="rh" data-ti="${TYPES.indexOf(t)}">${t.name}</th>` + displayActions.map((a) => {
  1965. const ai = ACTIONS.indexOf(a);
  1966. const ti = TYPES.indexOf(t);
  1967. const cell = (DATA.matrix && DATA.matrix[ai]) ? (DATA.matrix[ai][ti] || {}) : {};
  1968. const s = cell.tier !== undefined ? cell.tier : cell.s;
  1969. const cls = (s === null || s === undefined) ? 'tNA' : ('t' + s);
  1970. const isSel = (st.selectedAction === a.name && st.selectedType === t.name) ? ' sel' : '';
  1971. return `<td class="cell ${cls}${isSel}" data-ai="${ai}" data-ti="${ti}"></td>`;
  1972. }).join('') + '</tr>';
  1973. });
  1974. });
  1975. document.getElementById('comboMx').innerHTML = h + '</tbody>';
  1976. refresh();
  1977. applyCrosshair();
  1978. }
  1979. // 点中 cell 时浅高亮整行整列(含 row/col 表头),方便定位
  1980. function applyCrosshair() {
  1981. document.querySelectorAll('.rowsel,.colsel').forEach(el => el.classList.remove('rowsel', 'colsel'));
  1982. const ai = st.selectedAction ? ACTIONS.findIndex(a => a.name === st.selectedAction) : -1;
  1983. const ti = st.selectedType ? TYPES.findIndex(t => t.name === st.selectedType) : -1;
  1984. if (ai < 0 && ti < 0) return;
  1985. document.querySelectorAll(`#comboMx [data-ai="${ai}"]`).forEach(el => el.classList.add('colsel'));
  1986. document.querySelectorAll(`#comboMx [data-ti="${ti}"]`).forEach(el => el.classList.add('rowsel'));
  1987. }
  1988. function refresh() {
  1989. const cm = getFilteredHitsMap();
  1990. document.querySelectorAll('tr[data-type]').forEach(tr => {
  1991. const ty = tr.dataset.type;
  1992. tr.querySelectorAll('td.cell').forEach(td => {
  1993. const ai = +td.dataset.ai, ti = +td.dataset.ti, a = ACTIONS[ai];
  1994. const cell = (DATA.matrix && DATA.matrix[ai]) ? (DATA.matrix[ai][ti] || {}) : {};
  1995. const s = cell.tier !== undefined ? cell.tier : cell.s;
  1996. const c = cm[ty + '|' + a.name];
  1997. const hits = c ? c.hits : 0;
  1998. td.textContent = genQ(a.name, ty);
  1999. if (hits > 0) {
  2000. const badge = document.createElement('span');
  2001. badge.className = 'hit-badge';
  2002. badge.textContent = hits;
  2003. td.appendChild(badge);
  2004. }
  2005. td.classList.toggle('hide', (s == null ? 0 : s) < (+st.tier));
  2006. const hitsLabel = st.matrixView === 'procedures' ? '有工序' : '命中';
  2007. td.title = `${ty} × ${a.name}\nGemini评分: ${(s === null || s === undefined) ? '未判' : ['无效', '低', '中', '高'][s]}\n当前 form(${st.form}) ${hitsLabel}: ${hits} 篇`;
  2008. });
  2009. });
  2010. }
  2011. const pop = document.getElementById('pop'); let openCell = null;
  2012. function showPop(td, x, y) {
  2013. openCell = td;
  2014. const ai = +td.dataset.ai, ti = +td.dataset.ti, a = ACTIONS[ai], t = TYPES[ti];
  2015. const cell = (DATA.matrix && DATA.matrix[ai]) ? (DATA.matrix[ai][ti] || {}) : {};
  2016. const s = cell.tier !== undefined ? cell.tier : cell.s;
  2017. const tn = (s == null) ? '未判' : ['无效', '低', '中', '高'][s], tb = (s == null) ? 'NA' : s;
  2018. const gen = genForms(a.name, t.name, st.lens, toolPrefix(st.lens));
  2019. // Find matching query in database for this cell
  2020. const activeTool = st.tools[0] || null;
  2021. const matches = DATA.queries.filter(q => {
  2022. if (!q.dims || q.dims.action !== a.name || q.dims.type !== t.name) return false;
  2023. const qLens = detectLens(q);
  2024. if (qLens !== st.lens) return false;
  2025. const hasToolConstraint = q.dims.constraint && q.dims.constraint.kind === "工具类型";
  2026. if (activeTool) {
  2027. if (!hasToolConstraint || q.dims.constraint.value !== activeTool) return false;
  2028. } else {
  2029. if (hasToolConstraint) return false;
  2030. }
  2031. return true;
  2032. });
  2033. let dbQuery = null;
  2034. if (matches.length > 0) {
  2035. matches.sort((x, y) => (y.hits || 0) - (x.hits || 0));
  2036. dbQuery = matches[0];
  2037. }
  2038. const dbFormMap = {};
  2039. if (dbQuery) {
  2040. dbQuery.forms.forEach(f => {
  2041. dbFormMap[f.form] = f.query;
  2042. });
  2043. }
  2044. const formKeys = ['A', 'B', 'C'];
  2045. let html = `<span class="close">×</span>
  2046. <div class="pt">
  2047. <span class="path a">${a.l1}›${a.l2}›${a.name}</span>
  2048. <span class="path t">${t.l1}›${t.name}</span>
  2049. <span class="path" style="background: var(--soft-amber); color: var(--amber); font-family: monospace; font-weight: bold; border: 1px solid rgba(184, 121, 24, 0.2);">${dbQuery ? dbQuery.key : '未匹配'}</span>
  2050. <span class="tier tb${tb}">gemini·${tn}</span>
  2051. </div>
  2052. <div class="reason${s === 0 ? ' inv' : ''}">${esc(cell.r || '(模型未给该格评分)')}</div>
  2053. <div class="lbl">系统生成 · 知识类型=${st.lens}${st.tools.length ? ' · 工具类型=' + st.tools.join('/') : ''}</div>
  2054. <ul>` + gen.map(([fName, genQStr], idx) => {
  2055. const formKey = formKeys[idx];
  2056. const actualQ = dbFormMap[formKey];
  2057. const isCurrent = formKey === st.form;
  2058. let content = `<span class="fm">${fName}</span>${esc(genQStr)}`;
  2059. if (actualQ) {
  2060. if (actualQ !== genQStr) {
  2061. content += `<div style="font-size: 13px; margin-top: 6px; color: #047857; font-weight: 600; font-family: ui-monospace, Menlo, Monaco, Consolas, monospace; line-height: 1.45; background: #ecfdf5; border: 1px dashed #34d399; padding: 6px 10px; border-radius: 6px; width: 100%; box-sizing: border-box; display: flex; align-items: center; gap: 4px; box-shadow: inset 0 1px 2px rgba(4, 120, 87, 0.04);">
  2062. <span style="background: #10b981; padding: 2px 6px; border-radius: 4px; font-size: 11px; color: #fff; font-weight: bold; font-family: -apple-system, sans-serif; white-space: nowrap;">实际搜索</span>
  2063. <span style="word-break: break-all; font-family: inherit;">${esc(actualQ)}</span>
  2064. </div>`;
  2065. } else {
  2066. content += `<div style="font-size: 13px; margin-top: 6px; color: #374151; font-weight: 600; font-family: ui-monospace, Menlo, Monaco, Consolas, monospace; line-height: 1.45; background: #f9fafb; border: 1px dashed #d1d5db; padding: 6px 10px; border-radius: 6px; width: 100%; box-sizing: border-box; display: flex; align-items: center; gap: 4px; box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);">
  2067. <span style="background: #9ca3af; padding: 2px 6px; border-radius: 4px; font-size: 11px; color: #fff; font-weight: bold; font-family: -apple-system, sans-serif; white-space: nowrap;">实际搜索</span>
  2068. <span style="font-style: italic; font-family: inherit; color: #6b7280;">(同上)</span>
  2069. </div>`;
  2070. }
  2071. }
  2072. return `<li class="gen${isCurrent ? ' cur' : ''}" style="display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 6px 8px;">${content}</li>`;
  2073. }).join('') + '</ul>';
  2074. pop.innerHTML = html;
  2075. pop.style.display = 'block';
  2076. pop.style.left = Math.max(8, Math.min(x, window.innerWidth - 466)) + 'px';
  2077. pop.style.top = Math.max(8, Math.min(y, window.innerHeight - pop.offsetHeight - 12)) + 'px';
  2078. pop.querySelector('.close').onclick = () => {
  2079. pop.style.display = 'none';
  2080. openCell = null;
  2081. };
  2082. }
  2083. function computeStats() {
  2084. const stat = { "0": 0, "1": 0, "2": 0, "3": 0, "na": 0 };
  2085. if (DATA.matrix) {
  2086. DATA.matrix.forEach(row => row.forEach(cell => {
  2087. const s = cell ? (cell.tier !== undefined ? cell.tier : cell.s) : null;
  2088. if (s === null || s === undefined) stat["na"]++;
  2089. else if (stat[s] !== undefined) stat[s]++;
  2090. }));
  2091. }
  2092. document.getElementById('s3').textContent = stat['3'];
  2093. document.getElementById('s2').textContent = stat['2'];
  2094. document.getElementById('s1').textContent = stat['1'];
  2095. document.getElementById('s0').textContent = stat['0'];
  2096. document.getElementById('sna').textContent = stat['na'];
  2097. }
  2098. function renderFormsChan() {
  2099. const q = st.qi === -1 ? null : DATA.queries[st.qi];
  2100. if (!q) {
  2101. document.getElementById("navC").innerHTML = '';
  2102. return;
  2103. }
  2104. const f = curForm();
  2105. if (!f) {
  2106. document.getElementById("navC").innerHTML = '';
  2107. return;
  2108. }
  2109. const isProcedureView = st.matrixView === 'procedures';
  2110. const resultsFilter = r => {
  2111. if (isProcedureView) {
  2112. return r.procedure_html && r.procedure_html !== "";
  2113. }
  2114. return true;
  2115. };
  2116. const filteredResults = f.results.filter(resultsFilter);
  2117. const chans = ["all", ...f.platforms];
  2118. document.getElementById("navC").innerHTML = chans.map(c => {
  2119. const n = c === "all" ? filteredResults.length : filteredResults.filter(r => r.platformKey === c).length;
  2120. return `<span class="tab ${c === st.channel ? 'on' : ''}" data-c="${c}">${c === "all" ? "全部" : (PLATC[c] || c)} <small>${n}</small></span>`;
  2121. }).join("");
  2122. }
  2123. function renderNav() { renderMatrix(); renderFormsChan(); }
  2124. function renderHead() {
  2125. const f = curForm();
  2126. if (!f) return;
  2127. const q = DATA.queries[st.qi];
  2128. if (q) {
  2129. document.getElementById("lede").innerHTML = `当前选中 Query ID: <span style="font-family: monospace; font-weight: 700; background: var(--soft-amber); color: var(--amber); padding: 2px 8px; border-radius: 4px; font-size: 15px; border: 1px solid rgba(184, 121, 24, 0.2);">${esc(q.key)}</span> · 检索语句: <span style="font-weight: 600; color: var(--ink);">${esc(q.original_q)}</span>`;
  2130. } else {
  2131. document.getElementById("lede").textContent = "";
  2132. }
  2133. let it = f.results;
  2134. if (st.matrixView === 'procedures') {
  2135. it = it.filter(r => r.procedure_html && r.procedure_html !== "");
  2136. }
  2137. if (st.channel !== "all") it = it.filter(r => r.platformKey === st.channel);
  2138. const valid = it.filter(r => !r.anomaly);
  2139. const rep = valid.filter(r => !isItemDiscarded(r)).length;
  2140. const dis = valid.filter(r => isItemDiscarded(r)).length;
  2141. const anom = it.filter(r => r.anomaly).length;
  2142. const avg = (valid.reduce((s, r) => s + r.overall, 0) / (valid.length || 1)).toFixed(1);
  2143. const lab = st.channel === "all" ? "该形式结果数" : (PLATC[st.channel] || st.channel) + " 结果数";
  2144. document.getElementById("stats").innerHTML = [[it.length, lab], [rep, "建议上报"], [avg, "平均综合分 / 5"], [dis, "丢弃"], [anom, "异常"]].map(([n, l]) => `<div class="stat"><strong>${n}</strong><span>${l}</span></div>`).join("");
  2145. }
  2146. // POST /api/reeval —— 后台只对当前 query 的所有 form 文件复评(不重新搜索);
  2147. // server.py 立即返回 {status:'started', pid, log},前端开启轮询自动扫描刷新。
  2148. function reevalCurrentQuery() {
  2149. if (st.qi === -1 || !DATA.queries[st.qi]) { alert('请先选一个 query 再重评'); return; }
  2150. const q = DATA.queries[st.qi].key;
  2151. if (!confirm(`重评 ${q} 的所有帖子(A/B/C 三种 form)?\n约 1-3 分钟(视帖子数),过程中页面可继续浏览。\n完成后会自动重新扫描并更新页面。`)) return;
  2152. const btn = document.getElementById('reevalBtn');
  2153. btn.disabled = true; btn.textContent = '♻️ 提交中…';
  2154. fetch('/api/reeval', {
  2155. method: 'POST', headers: { 'Content-Type': 'application/json' },
  2156. body: JSON.stringify({ q }),
  2157. }).then(r => r.json().then(d => ({ ok: r.ok, d }))).then(({ ok, d }) => {
  2158. if (ok && d.status === 'started') {
  2159. if (!DATA.active_reevals) DATA.active_reevals = {};
  2160. DATA.active_reevals[q] = "running";
  2161. btn.textContent = `♻️ 重评中 ${q}...`;
  2162. startReevalPolling(q);
  2163. } else {
  2164. btn.disabled = false; btn.textContent = '♻️ 重评当前 query';
  2165. alert('启动失败:' + (d.error || JSON.stringify(d)));
  2166. }
  2167. }).catch(e => {
  2168. btn.disabled = false; btn.textContent = '♻️ 重评当前 query';
  2169. alert('请求失败:' + e);
  2170. });
  2171. }
  2172. function sortedItems() {
  2173. const f = curForm();
  2174. if (!f) return [];
  2175. let it = f.results.slice();
  2176. if (st.matrixView === 'procedures') {
  2177. it = it.filter(r => r.procedure_html && r.procedure_html !== "");
  2178. }
  2179. if (st.channel !== "all") it = it.filter(r => r.platformKey === st.channel);
  2180. const s = document.getElementById("sort").value;
  2181. const decWeight = r => (r.anomaly ? 2 : (isItemDiscarded(r) ? 1 : 0));
  2182. it.sort((a, b) => {
  2183. const wA = decWeight(a), wB = decWeight(b);
  2184. if (wA !== wB) return wA - wB;
  2185. if (s === "score") return b.overall - a.overall;
  2186. if (s === "date") return (b.date || "").localeCompare(b.date || "");
  2187. if (s === "platform") return (a.platform || "").localeCompare(b.platform || "", "zh-Hans") || b.overall - a.overall;
  2188. return 0;
  2189. });
  2190. return it;
  2191. }
  2192. function renderGrid() {
  2193. VIEW = sortedItems();
  2194. document.getElementById("grid").innerHTML = VIEW.map((it, idx) => {
  2195. const imgs = it.images.length ? it.images.slice(0, 3).map(s => `<img src="${esc(s)}" referrerpolicy="no-referrer" loading="lazy" onerror="this.src='${NOIMG}'">`).join("") : `<img src="${NOIMG}">`;
  2196. const isNewSchema = it.scores && (it.scores.relevance_production !== undefined || it.scores.relevance_query !== undefined);
  2197. let bars = "";
  2198. if (isNewSchema) {
  2199. const relAvg = groupAverage(it, scoreGroupsNew[0], true) || 0;
  2200. const qualAvg = getQualityAverage(it) || 0;
  2201. const newBars = [
  2202. { label: "相关性评分 (均分)", v: relAvg },
  2203. { label: "质量评分 (均分)", v: qualAvg }
  2204. ];
  2205. bars = newBars.map(b => {
  2206. const w = b.v * 10;
  2207. return `<span title="${esc(b.label)} ${b.v.toFixed(1)}"><span class="fill" style="width:${w}%; background: #2563eb;"></span></span>`;
  2208. }).join("");
  2209. } else {
  2210. const oldKeys = ["relevance", "result_quality", "credibility", "novelty_coverage", "concrete_use_case"];
  2211. bars = oldKeys.map(k => {
  2212. const val = it.scores[k] !== undefined ? parseFloat(it.scores[k]) : 0;
  2213. const w = val * 20;
  2214. return `<span title="${esc(commonLabels[k] || k)} ${val}"><span class="fill" style="width:${w}%;"></span></span>`;
  2215. }).join("");
  2216. }
  2217. const isDiscard = isItemDiscarded(it);
  2218. let discardReason = it.reason || '未提供过滤原因';
  2219. if (it.production_relevance !== null && it.production_relevance !== undefined) {
  2220. const input = document.getElementById("relThreshold");
  2221. const threshold = input ? parseFloat(input.value) : (isNewSchema ? 4.0 : 2.0);
  2222. const relVal = parseFloat(it.production_relevance);
  2223. if (!isNaN(relVal) && relVal < threshold) {
  2224. discardReason = `相关性得分 (${relVal}) 低于过滤阈值 (${threshold})`;
  2225. }
  2226. }
  2227. const discardOverlayHtml = isDiscard ? `
  2228. <div class="discard-overlay">
  2229. <div class="discard-badge">Discarded</div>
  2230. <div class="discard-reason">${esc(discardReason)}</div>
  2231. </div>
  2232. ` : '';
  2233. return `<article class="result ${isDiscard ? 'discard' : ''}">
  2234. ${discardOverlayHtml}
  2235. <div class="thumbs">${imgs}</div>
  2236. <div class="body">
  2237. <div class="meta"><span class="platform p-${esc(it.platformKey)}">${esc(it.platform)}</span><span>${esc(it.date)} · ${esc(it.engagement)}</span></div>
  2238. <h2>${esc(it.title)}</h2>
  2239. <div class="excerpt">${esc(it.text)}</div>
  2240. <div class="tags">${it.tools.slice(0, 4).map(t => `<span class="tag">${esc(t)}</span>`).join("")}</div>
  2241. <div class="scorebar">
  2242. <div class="overall">
  2243. <div>
  2244. <div class="score">${it.anomaly ? '—' : it.overall.toFixed(1)}</div>
  2245. <small>综合分</small>
  2246. </div>
  2247. <div class="decision ${it.anomaly ? '' : it.decision}">${it.anomaly ? '异常' : esc(it.decision)}</div>
  2248. </div>
  2249. <div class="mini-bars ${isNewSchema ? 'new-schema' : ''}">${bars}</div>
  2250. <div class="group-snapshot ${isNewSchema ? 'new-schema' : ''}">${groupSnapshot(it)}</div>
  2251. <div class="actions">
  2252. <button onclick="openDetail(${idx})">查看详情</button>
  2253. <a href="${esc(it.url)}" target="_blank" rel="noreferrer">原链接</a>
  2254. </div>
  2255. </div>
  2256. </div>
  2257. </article>`;
  2258. }).join("") || (st.qi === -1 ? '<p style="color:var(--muted);padding: 20px 0;text-align:center;grid-column: 1 / -1;">该组合暂无数据库扫描结果。</p>' : '<p style="color:var(--muted);grid-column: 1 / -1;">该渠道无结果</p>');
  2259. }
  2260. const ENGINE_MODELS = {
  2261. cyber_runner: [
  2262. { value: "google/gemini-3.1-flash-lite", text: "google/gemini-3.1-flash-lite (默认)" },
  2263. { value: "google/gemini-3.5-flash", text: "google/gemini-3.5-flash" },
  2264. { value: "google/gemini-2.5-flash", text: "google/gemini-2.5-flash" },
  2265. { value: "openai/gpt-4o", text: "openai/gpt-4o" },
  2266. { value: "anthropic/claude-3.5-sonnet", text: "anthropic/claude-3.5-sonnet" }
  2267. ],
  2268. claude_sdk: [
  2269. { value: "claude-sonnet-4-6", text: "claude-sonnet-4-6 (默认)" },
  2270. { value: "claude-haiku-4-6", text: "claude-haiku-4-6" }
  2271. ]
  2272. };
  2273. function onProcEngineChange() {
  2274. const engine = document.getElementById("procEngineSelect").value;
  2275. const modelSelect = document.getElementById("procModelSelect");
  2276. modelSelect.innerHTML = ENGINE_MODELS[engine].map(m => `<option value="${m.value}">${m.text}</option>`).join("");
  2277. }
  2278. function getShortCaseFolder(form, case_id) {
  2279. const match = case_id.match(/^([a-z]+)_([0-9a-f]{8})/i);
  2280. const short = match ? `${match[1]}_${match[2]}` : case_id.substring(0, 20);
  2281. return `${form}_${short}`;
  2282. }
  2283. function checkProcedureState(it) {
  2284. if (procPollInterval) {
  2285. clearInterval(procPollInterval);
  2286. procPollInterval = null;
  2287. }
  2288. currentProcTask = {
  2289. q: it.run,
  2290. form: st.form,
  2291. case_id: it.case_id,
  2292. procedure_html: it.procedure_html
  2293. };
  2294. isLogViewActive = false;
  2295. document.getElementById("procStatusText").textContent = "正在检测工序状态...";
  2296. document.getElementById("procActionBtns").innerHTML = "";
  2297. document.getElementById("procSetupPanel").style.display = "none";
  2298. document.getElementById("procConsolePanel").style.display = "none";
  2299. document.getElementById("procedureIframe").style.display = "none";
  2300. const url = `/api/procedure_status?q=${it.run}&form=${st.form}&case_id=${it.case_id}`;
  2301. fetch(url)
  2302. .then(r => r.json())
  2303. .then(d => {
  2304. if (d.status === "running") {
  2305. showProcConsole("running");
  2306. pollProcLogs();
  2307. } else if (d.status === "success") {
  2308. showProcIframe(it.procedure_html);
  2309. } else if (d.status === "failed") {
  2310. showProcSetup(d.error);
  2311. } else {
  2312. showProcSetup();
  2313. }
  2314. })
  2315. .catch(err => {
  2316. showProcSetup("检查状态失败: " + err);
  2317. });
  2318. }
  2319. function showProcSetup(errorMsg) {
  2320. document.getElementById("procSetupPanel").style.display = "flex";
  2321. document.getElementById("procConsolePanel").style.display = "none";
  2322. document.getElementById("procedureIframe").style.display = "none";
  2323. const statusText = document.getElementById("procStatusText");
  2324. if (errorMsg) {
  2325. statusText.innerHTML = `<span style="color:var(--rose)">提取失败: ${esc(errorMsg)}</span>`;
  2326. } else {
  2327. statusText.textContent = "未生成工序";
  2328. }
  2329. document.getElementById("procActionBtns").innerHTML = "";
  2330. document.getElementById("startProcBtn").disabled = false;
  2331. document.getElementById("startProcBtn").textContent = "开始提取工序";
  2332. onProcEngineChange();
  2333. }
  2334. function showProcConsole(status) {
  2335. document.getElementById("procSetupPanel").style.display = "none";
  2336. document.getElementById("procConsolePanel").style.display = "flex";
  2337. document.getElementById("procedureIframe").style.display = "none";
  2338. const statusText = document.getElementById("procStatusText");
  2339. const consoleStatus = document.getElementById("procConsoleStatus");
  2340. if (status === "running") {
  2341. statusText.innerHTML = `<span>⏳ 正在提取工序中...</span>`;
  2342. consoleStatus.textContent = "running";
  2343. document.getElementById("procActionBtns").innerHTML = `<button class="btn" style="background:#f3f4f6" disabled>正在生成...</button>`;
  2344. } else if (status === "failed") {
  2345. statusText.innerHTML = `<span style="color:var(--rose)">❌ 提取失败</span>`;
  2346. consoleStatus.textContent = "failed";
  2347. document.getElementById("procActionBtns").innerHTML = `
  2348. <button class="btn" onclick="toggleCompletedLogs()">查看日志</button>
  2349. <button class="btn" style="background:var(--rose); color:#fff; border-color:var(--rose)" onclick="resetToSetup()">重试提取</button>
  2350. `;
  2351. }
  2352. }
  2353. function resetToSetup() {
  2354. showProcSetup();
  2355. }
  2356. function showProcIframe(htmlPath) {
  2357. document.getElementById("procSetupPanel").style.display = "none";
  2358. document.getElementById("procConsolePanel").style.display = "none";
  2359. const iframe = document.getElementById("procedureIframe");
  2360. iframe.style.display = "block";
  2361. iframe.src = "/" + htmlPath;
  2362. document.getElementById("procStatusText").innerHTML = `<span style="color:var(--mint)">✓ 工序已生成</span>`;
  2363. document.getElementById("procActionBtns").innerHTML = `
  2364. <button class="btn" id="btnToggleLogs" onclick="toggleCompletedLogs()">📋 查看提取日志</button>
  2365. <button class="btn" style="background:var(--rose); color:#fff; border-color:var(--rose);" onclick="regenerateProcedureConfirm()">♻️ 重新生成</button>
  2366. `;
  2367. }
  2368. function toggleCompletedLogs() {
  2369. const iframe = document.getElementById("procedureIframe");
  2370. const consolePanel = document.getElementById("procConsolePanel");
  2371. const toggleBtn = document.getElementById("btnToggleLogs");
  2372. if (isLogViewActive) {
  2373. consolePanel.style.display = "none";
  2374. iframe.style.display = "block";
  2375. if (toggleBtn) toggleBtn.textContent = "📋 查看提取日志";
  2376. isLogViewActive = false;
  2377. } else {
  2378. iframe.style.display = "none";
  2379. consolePanel.style.display = "flex";
  2380. if (toggleBtn) toggleBtn.textContent = "👁️ 返回工序效果";
  2381. isLogViewActive = true;
  2382. fetchLogsOnce();
  2383. }
  2384. }
  2385. function fetchLogsOnce() {
  2386. const consoleOutput = document.getElementById("procConsoleOutput");
  2387. consoleOutput.textContent = "正在加载日志...";
  2388. const url = `/api/procedure_log?q=${currentProcTask.q}&form=${currentProcTask.form}&case_id=${currentProcTask.case_id}`;
  2389. fetch(url)
  2390. .then(r => r.json())
  2391. .then(d => {
  2392. consoleOutput.textContent = d.log || "没有提取日志。";
  2393. consoleOutput.scrollTop = consoleOutput.scrollHeight;
  2394. })
  2395. .catch(err => {
  2396. consoleOutput.textContent = "加载日志失败: " + err;
  2397. });
  2398. }
  2399. function startProcedureExtraction() {
  2400. const engine = document.getElementById("procEngineSelect").value;
  2401. const model = document.getElementById("procModelSelect").value;
  2402. const startBtn = document.getElementById("startProcBtn");
  2403. startBtn.disabled = true;
  2404. startBtn.textContent = "正在启动...";
  2405. const payload = {
  2406. q: currentProcTask.q,
  2407. form: currentProcTask.form,
  2408. case_id: currentProcTask.case_id,
  2409. engine: engine,
  2410. model: model
  2411. };
  2412. fetch("/api/generate_procedure", {
  2413. method: "POST",
  2414. headers: { "Content-Type": "application/json" },
  2415. body: JSON.stringify(payload)
  2416. })
  2417. .then(r => r.json().then(d => ({ ok: r.ok, d })))
  2418. .then(({ ok, d }) => {
  2419. if (ok && d.status === "started") {
  2420. showProcConsole("running");
  2421. pollProcLogs();
  2422. } else {
  2423. showProcSetup(d.error || "启动失败");
  2424. }
  2425. })
  2426. .catch(err => {
  2427. showProcSetup("网络请求错误: " + err);
  2428. });
  2429. }
  2430. function regenerateProcedureConfirm() {
  2431. if (confirm("确定要重新提取并生成工序吗?这会覆盖原有的工序文件和修改记录。")) {
  2432. showProcSetup();
  2433. }
  2434. }
  2435. function pollProcLogs() {
  2436. if (procPollInterval) {
  2437. clearInterval(procPollInterval);
  2438. }
  2439. const consoleOutput = document.getElementById("procConsoleOutput");
  2440. consoleOutput.textContent = "正在连接后台提取进程...\n";
  2441. procPollInterval = setInterval(() => {
  2442. const statusUrl = `/api/procedure_status?q=${currentProcTask.q}&form=${currentProcTask.form}&case_id=${currentProcTask.case_id}`;
  2443. fetch(statusUrl)
  2444. .then(r => r.json())
  2445. .then(d => {
  2446. if (d.status === "success") {
  2447. clearInterval(procPollInterval);
  2448. procPollInterval = null;
  2449. loadData(true);
  2450. if (d.procedure_html) {
  2451. showProcIframe(d.procedure_html);
  2452. } else {
  2453. const folder = getShortCaseFolder(currentProcTask.form, currentProcTask.case_id);
  2454. showProcIframe(`runs_full/${currentProcTask.q}/procedures/${folder}/case-${currentProcTask.case_id}.html`);
  2455. }
  2456. } else if (d.status === "failed") {
  2457. clearInterval(procPollInterval);
  2458. procPollInterval = null;
  2459. showProcConsole("failed");
  2460. }
  2461. });
  2462. const logUrl = `/api/procedure_log?q=${currentProcTask.q}&form=${currentProcTask.form}&case_id=${currentProcTask.case_id}`;
  2463. fetch(logUrl)
  2464. .then(r => r.json())
  2465. .then(d => {
  2466. if (d.log) {
  2467. const scrollAtBottom = consoleOutput.scrollTop + consoleOutput.clientHeight >= consoleOutput.scrollHeight - 50;
  2468. consoleOutput.textContent = d.log;
  2469. if (scrollAtBottom) {
  2470. consoleOutput.scrollTop = consoleOutput.scrollHeight;
  2471. }
  2472. }
  2473. });
  2474. }, 2000);
  2475. }
  2476. function switchModalTab(tabName) {
  2477. const detailTab = document.getElementById("tabDetailBtn");
  2478. const procTab = document.getElementById("tabProcedureBtn");
  2479. const detailContent = document.getElementById("modalContentDetail");
  2480. const procContent = document.getElementById("modalContentProcedure");
  2481. if (tabName === 'detail') {
  2482. detailTab.classList.add("active");
  2483. procTab.classList.remove("active");
  2484. detailContent.style.display = "grid";
  2485. procContent.style.display = "none";
  2486. } else {
  2487. detailTab.classList.remove("active");
  2488. procTab.classList.add("active");
  2489. detailContent.style.display = "none";
  2490. procContent.style.display = "flex";
  2491. }
  2492. }
  2493. function openDetail(i) {
  2494. const it = VIEW[i];
  2495. detailDialog.dataset.activeIdx = i;
  2496. currentPinnedScoreEl = null;
  2497. document.getElementById("modalMeta").innerHTML = `<span class="platform p-${esc(it.platformKey)}">${esc(it.platform)}</span><span>Query ID: <b style="font-family: monospace; color: var(--amber); background: var(--soft-amber); border: 1px solid rgba(184, 121, 24, 0.2); padding: 1px 6px; border-radius: 3px; font-size: 11px; margin-right: 8px;">${esc(it.run)}</b></span><span>${esc(it.date)} · ${esc(it.engagement)} · 质量 ${esc(it.grade)} ${esc(it.qscore)}</span>`;
  2498. document.getElementById("modalTitle").textContent = it.title;
  2499. document.getElementById("modalReason").textContent = it.reason;
  2500. document.getElementById("modalText").textContent = it.text || "(无正文)";
  2501. document.getElementById("modalImages").innerHTML = it.images.length ? it.images.map(s => `<img src="${esc(s)}" referrerpolicy="no-referrer" loading="lazy" onerror="this.style.opacity=.3">`).join("") : "<p>搜索详情未返回图片。</p>";
  2502. document.getElementById("modalTags").innerHTML = [...(it.knowledge_type || []).map(t => "类型:" + (KTM[t] || t)), ...(it.found_by || []).map(q => "命中:" + q)].map(t => `<span class="tag">${esc(t)}</span>`).join("");
  2503. const isNewSchema = it.scores && (it.scores.relevance_production !== undefined || it.scores.relevance_query !== undefined);
  2504. const maxScore = isNewSchema ? '10' : '5';
  2505. const overallVal = it.anomaly ? '—' : it.overall.toFixed(1);
  2506. const scoreColor = isNewSchema ? '#2563eb' : 'var(--mint)';
  2507. const scoreStrong = document.getElementById("modalOverallScoreVal");
  2508. if (scoreStrong) {
  2509. scoreStrong.style.color = scoreColor;
  2510. scoreStrong.innerHTML = `${overallVal}<span style="font-size: 12px; color: var(--muted); font-weight: 500; margin-left: 2px;">/${maxScore}</span>`;
  2511. }
  2512. if (isNewSchema) {
  2513. document.getElementById("modalScores").innerHTML = renderNewScores(it);
  2514. } else {
  2515. document.getElementById("modalScores").innerHTML = scoreGroupsOld.map(g => renderScoreGroup(it, g)).join("");
  2516. }
  2517. const tabs = document.getElementById("modalTabs");
  2518. tabs.style.display = "flex";
  2519. checkProcedureState(it);
  2520. switchModalTab('detail');
  2521. detailDialog.showModal();
  2522. }
  2523. let currentPinnedScoreEl = null;
  2524. function pinScoreReason(el, label, k) {
  2525. const activeIdx = detailDialog.dataset.activeIdx;
  2526. const it = VIEW[activeIdx];
  2527. if (!it || !it.score_reasons) return;
  2528. const reason = it.score_reasons[k] || '';
  2529. let tip = document.getElementById('scoreTip');
  2530. if (!tip) {
  2531. tip = document.createElement('div');
  2532. tip.id = 'scoreTip';
  2533. tip.style.cssText = 'position: fixed; background: #ffffff; border: 1px solid #ded8ce; border-radius: 8px; box-shadow: 0 10px 25px rgba(41, 35, 28, 0.15); padding: 12px 14px; max-width: 320px; z-index: 99999; font-size: 13px; line-height: 1.5; color: #4b5563; word-break: break-all; border-left: 4px solid var(--amber); transition: opacity 0.15s ease;';
  2534. detailDialog.appendChild(tip);
  2535. }
  2536. if (currentPinnedScoreEl === el && tip.style.display === 'block') {
  2537. tip.style.display = 'none';
  2538. el.style.color = '';
  2539. currentPinnedScoreEl = null;
  2540. } else {
  2541. if (currentPinnedScoreEl) {
  2542. currentPinnedScoreEl.style.color = '';
  2543. }
  2544. tip.innerHTML = `<strong style="display:block;margin-bottom:6px;color:#b87918;">【指标判定 - ${label}】</strong>${esc(reason)}`;
  2545. tip.style.display = 'block';
  2546. el.style.color = 'var(--amber)';
  2547. currentPinnedScoreEl = el;
  2548. const elRect = el.getBoundingClientRect();
  2549. const tipWidth = tip.offsetWidth || 280;
  2550. const tipHeight = tip.offsetHeight || 80;
  2551. let left = elRect.left + elRect.width / 2 - tipWidth / 2;
  2552. let top = elRect.bottom + 8;
  2553. if (left < 10) left = 10;
  2554. if (left + tipWidth > window.innerWidth - 10) {
  2555. left = window.innerWidth - tipWidth - 10;
  2556. }
  2557. if (top + tipHeight > window.innerHeight - 10) {
  2558. top = elRect.top - tipHeight - 8;
  2559. }
  2560. tip.style.left = left + 'px';
  2561. tip.style.top = top + 'px';
  2562. }
  2563. }
  2564. // Automatically close tooltip and clear interval when modal is closed
  2565. document.getElementById('detailDialog').addEventListener('close', () => {
  2566. const tip = document.getElementById('scoreTip');
  2567. if (tip) {
  2568. tip.style.display = 'none';
  2569. }
  2570. if (currentPinnedScoreEl) {
  2571. currentPinnedScoreEl.style.color = '';
  2572. currentPinnedScoreEl = null;
  2573. }
  2574. if (procPollInterval) {
  2575. clearInterval(procPollInterval);
  2576. procPollInterval = null;
  2577. }
  2578. const dialog = document.getElementById('detailDialog');
  2579. dialog.classList.remove('fullscreen');
  2580. const btn = document.getElementById('toggleFullscreenBtn');
  2581. if (btn) btn.textContent = '📺 全屏';
  2582. });
  2583. // Close tooltip when dialog scrolls
  2584. document.getElementById('detailDialog').addEventListener('scroll', () => {
  2585. const tip = document.getElementById('scoreTip');
  2586. if (tip) {
  2587. tip.style.display = 'none';
  2588. }
  2589. if (currentPinnedScoreEl) {
  2590. currentPinnedScoreEl.style.color = '';
  2591. currentPinnedScoreEl = null;
  2592. }
  2593. }, true);
  2594. function toggleModalFullscreen() {
  2595. const dialog = document.getElementById('detailDialog');
  2596. const btn = document.getElementById('toggleFullscreenBtn');
  2597. dialog.classList.toggle('fullscreen');
  2598. if (dialog.classList.contains('fullscreen')) {
  2599. btn.textContent = '📺 退出全屏';
  2600. } else {
  2601. btn.textContent = '📺 全屏';
  2602. }
  2603. }
  2604. const KTM = { procedure: "工序", step: "步骤", tool: "工具" };
  2605. function rerender(mxClick) {
  2606. updateThresholdLimits();
  2607. if (st.qi === -1) {
  2608. document.getElementById("stats").innerHTML = "";
  2609. document.getElementById("lede").textContent = "未找到对应的数据库 Query,请尝试切换筛选组合。";
  2610. renderFormsChan();
  2611. renderGrid();
  2612. if (!mxClick) {
  2613. document.querySelectorAll('td.cell.sel').forEach(x => x.classList.remove('sel'));
  2614. }
  2615. return;
  2616. }
  2617. if (st.qi >= DATA.queries.length) st.qi = 0;
  2618. if (st.fi >= DATA.queries[st.qi].forms.length) st.fi = 0;
  2619. if (!mxClick) {
  2620. renderMatrix();
  2621. }
  2622. renderFormsChan();
  2623. renderHead();
  2624. renderGrid();
  2625. // Sync reevalBtn state
  2626. const reevalBtn = document.getElementById('reevalBtn');
  2627. if (reevalBtn && DATA.queries[st.qi]) {
  2628. const q = DATA.queries[st.qi].key;
  2629. const status = DATA.active_reevals && DATA.active_reevals[q];
  2630. if (status === "running") {
  2631. reevalBtn.disabled = true;
  2632. reevalBtn.textContent = `♻️ 重评中 ${q}...`;
  2633. startReevalPolling(q);
  2634. } else {
  2635. reevalBtn.disabled = false;
  2636. reevalBtn.textContent = '♻️ 重评当前 query';
  2637. }
  2638. }
  2639. }
  2640. function setMatrixView(mode) {
  2641. st.matrixView = mode;
  2642. document.querySelectorAll('.g-mxview .btn').forEach(btn => {
  2643. btn.classList.remove('on');
  2644. });
  2645. if (mode === 'full') document.getElementById('btnMxFull').classList.add('on');
  2646. else if (mode === 'hits') document.getElementById('btnMxHits').classList.add('on');
  2647. else if (mode === 'procedures') document.getElementById('btnMxProcedures').classList.add('on');
  2648. if (st.selectedAction && st.selectedType) {
  2649. selectQueryByActiveCellAndControls(st.selectedAction, st.selectedType);
  2650. }
  2651. renderMatrix();
  2652. if (openCell) {
  2653. const ai = +openCell.dataset.ai, ti = +openCell.dataset.ti;
  2654. const newCell = document.querySelector(`td.cell[data-ai="${ai}"][data-ti="${ti}"]`);
  2655. if (newCell) {
  2656. showPop(newCell, parseInt(pop.style.left), parseInt(pop.style.top));
  2657. }
  2658. }
  2659. rerender(true);
  2660. }
  2661. function loadData(keep) {
  2662. fetch("/api/data").then(r => r.json()).then(d => {
  2663. DATA = d;
  2664. if (!keep) {
  2665. st = { form: 'A', lens: '工序', tools: [], tier: 0, qi: 0, fi: 0, channel: "all", matrixView: 'full', selectedAction: null, selectedType: null };
  2666. if (DATA.queries.length > 0) {
  2667. const firstQ = DATA.queries[0];
  2668. if (firstQ.dims) {
  2669. st.selectedAction = firstQ.dims.action;
  2670. st.selectedType = firstQ.dims.type;
  2671. st.lens = detectLens(firstQ);
  2672. }
  2673. }
  2674. }
  2675. // Dynamically populate tool type buttons
  2676. document.getElementById('toolBtns').innerHTML = TOOL_TYPES.map(t => `<button class="btn" data-k="tool" data-v="${t}">${t}</button>`).join('');
  2677. // Synchronize buttons states to st
  2678. document.querySelectorAll('.ctl .btn').forEach(btn => {
  2679. const k = btn.dataset.k, v = btn.dataset.v;
  2680. if (MULTI[k]) {
  2681. const ak = MULTI[k];
  2682. btn.classList.toggle('on', v === '' ? st[ak].length === 0 : st[ak].includes(v));
  2683. } else {
  2684. btn.classList.toggle('on', st[k] === v);
  2685. }
  2686. });
  2687. document.querySelectorAll('.g-mxview .btn').forEach(btn => {
  2688. btn.classList.remove('on');
  2689. });
  2690. const mv = st.matrixView || 'full';
  2691. if (mv === 'full') document.getElementById('btnMxFull').classList.add('on');
  2692. else if (mv === 'hits') document.getElementById('btnMxHits').classList.add('on');
  2693. else if (mv === 'procedures') document.getElementById('btnMxProcedures').classList.add('on');
  2694. computeStats();
  2695. if (st.selectedAction && st.selectedType) {
  2696. selectQueryByActiveCellAndControls(st.selectedAction, st.selectedType);
  2697. }
  2698. rerender();
  2699. });
  2700. }
  2701. // Matrix click listener (links matrix select to database select + opens pop-up)
  2702. document.getElementById("comboMx").addEventListener("click", e => {
  2703. const td = e.target.closest("td.cell");
  2704. if (!td) return;
  2705. const ai = +td.dataset.ai, ti = +td.dataset.ti, a = ACTIONS[ai], t = TYPES[ti];
  2706. st.selectedAction = a.name;
  2707. st.selectedType = t.name;
  2708. showPop(td, e.clientX, e.clientY);
  2709. // Select the query
  2710. selectQueryByActiveCellAndControls(a.name, t.name);
  2711. document.querySelectorAll('td.cell.sel').forEach(x => x.classList.remove('sel'));
  2712. td.classList.add('sel');
  2713. applyCrosshair();
  2714. rerender(true); // mxClick = true, updates results without redrawing full table
  2715. });
  2716. // Header controls event delegation
  2717. const MULTI = { tool: 'tools' };
  2718. document.querySelector('.ctl').addEventListener('click', e => {
  2719. const b = e.target.closest('.btn');
  2720. if (!b) return;
  2721. const k = b.dataset.k, v = b.dataset.v, grp = document.querySelectorAll(`.ctl .btn[data-k="${k}"]`);
  2722. if (MULTI[k]) {
  2723. const ak = MULTI[k];
  2724. if (v === '') {
  2725. st[ak] = [];
  2726. } else {
  2727. if (st[ak].includes(v)) {
  2728. st[ak] = [];
  2729. } else {
  2730. st[ak] = [v];
  2731. }
  2732. }
  2733. grp.forEach(x => {
  2734. const xv = x.dataset.v;
  2735. x.classList.toggle('on', xv === '' ? st[ak].length === 0 : st[ak].includes(xv));
  2736. });
  2737. } else {
  2738. grp.forEach(x => x.classList.remove('on'));
  2739. b.classList.add('on');
  2740. st[k] = v;
  2741. }
  2742. if (st.selectedAction && st.selectedType) {
  2743. selectQueryByActiveCellAndControls(st.selectedAction, st.selectedType);
  2744. }
  2745. renderMatrix();
  2746. if (openCell) {
  2747. const ai = +openCell.dataset.ai, ti = +openCell.dataset.ti;
  2748. const newCell = document.querySelector(`td.cell[data-ai="${ai}"][data-ti="${ti}"]`);
  2749. if (newCell) {
  2750. showPop(newCell, parseInt(pop.style.left), parseInt(pop.style.top));
  2751. }
  2752. }
  2753. rerender(true);
  2754. });
  2755. // Close popups on clicking outside
  2756. document.addEventListener('click', e => {
  2757. if (!e.target.closest('td.cell') && !e.target.closest('.pop') && !e.target.closest('.btn')) {
  2758. pop.style.display = 'none';
  2759. openCell = null;
  2760. }
  2761. const tip = document.getElementById('scoreTip');
  2762. if (tip && !e.target.closest('.info-icon') && !e.target.closest('#scoreTip')) {
  2763. tip.style.display = 'none';
  2764. if (currentPinnedScoreEl) {
  2765. currentPinnedScoreEl.style.color = '';
  2766. currentPinnedScoreEl = null;
  2767. }
  2768. }
  2769. });
  2770. document.getElementById("navC").addEventListener("click", e => { const t = e.target.closest(".tab"); if (!t) return; st.channel = t.dataset.c; renderNav(); renderHead(); renderGrid(); });
  2771. document.getElementById("sort").addEventListener("change", renderGrid);
  2772. loadData();
  2773. </script>
  2774. </body>
  2775. </html>