index.html 108 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379
  1. <!doctype html>
  2. <html lang="zh">
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta
  6. name="viewport"
  7. content="width=device-width, initial-scale=1"
  8. />
  9. <title>mode_workflow · 解构工作台</title>
  10. <script src="https://cdn.jsdelivr.net/npm/echarts@5/dist/echarts.min.js"></script>
  11. <link
  12. rel="preconnect"
  13. href="https://fonts.googleapis.com"
  14. />
  15. <link
  16. href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@600;900&family=Noto+Sans+SC:wght@400;500;700&family=IBM+Plex+Mono:wght@500;700&display=swap"
  17. rel="stylesheet"
  18. />
  19. <style>
  20. /* ── 主题:净白工作台 + 墨蓝/朱砂点缀 ─────────────────────────────────────── */
  21. :root {
  22. --bg: #f4f4f1;
  23. --card: #ffffff;
  24. --ink: #1c2433;
  25. --ink-soft: #5a6577;
  26. --ink-faint: #9aa3b0;
  27. --line: #e8e6e0;
  28. --line-dark: #d4d1c8;
  29. --navy: #1e3a5f;
  30. --navy-deep: #13243a; /* 需求区 / 品牌 */
  31. --blue: #2563eb;
  32. --blue-bg: #eef3fe; /* 评分/交互强调 */
  33. --amber: #b45309;
  34. --amber-bg: #fff7e8; /* 输入区 */
  35. --teal: #0f6b5c;
  36. --teal-bg: #eef8f3; /* 实现区 */
  37. --green: #15803d;
  38. --green-bg: #effaf1; /* 输出区 / 采纳 */
  39. --seal: #bb3a22; /* 朱砂印 */
  40. --infer: #fdf0d2;
  41. --infer-edge: #d97706;
  42. --shadow: 0 1px 2px rgba(20, 30, 46, 0.04), 0 8px 24px -12px rgba(20, 30, 46, 0.12);
  43. --shadow-lg: 0 4px 10px rgba(20, 30, 46, 0.06), 0 24px 60px -20px rgba(20, 30, 46, 0.25);
  44. }
  45. * {
  46. box-sizing: border-box;
  47. margin: 0;
  48. padding: 0;
  49. }
  50. html {
  51. font-size: 14px;
  52. }
  53. body {
  54. font-family: "Noto Sans SC", sans-serif;
  55. color: var(--ink);
  56. background: var(--bg);
  57. background-image: radial-gradient(900px 360px at 90% -8%, rgba(37, 99, 235, 0.045), transparent 60%);
  58. min-height: 100vh;
  59. }
  60. .num {
  61. font-family: "IBM Plex Mono", monospace;
  62. }
  63. h1,
  64. h2,
  65. .serif {
  66. font-family: "Noto Serif SC", serif;
  67. }
  68. a {
  69. color: var(--blue);
  70. }
  71. button {
  72. font-family: inherit;
  73. cursor: pointer;
  74. }
  75. /* ── 顶部 ── */
  76. header {
  77. display: flex;
  78. align-items: center;
  79. gap: 20px;
  80. padding: 0 30px;
  81. height: 60px;
  82. background: linear-gradient(135deg, #13243a, #1c3552);
  83. color: #eef2f8;
  84. position: sticky;
  85. top: 0;
  86. z-index: 40;
  87. box-shadow: 0 2px 14px rgba(19, 36, 58, 0.28);
  88. }
  89. .logo {
  90. display: flex;
  91. align-items: center;
  92. gap: 12px;
  93. }
  94. .logo .seal {
  95. width: 33px;
  96. height: 33px;
  97. background: var(--seal);
  98. color: #fff;
  99. display: grid;
  100. place-items: center;
  101. font-family: "Noto Serif SC", serif;
  102. font-weight: 900;
  103. font-size: 17px;
  104. border-radius: 7px;
  105. box-shadow:
  106. inset 0 0 0 2px rgba(255, 255, 255, 0.22),
  107. 0 3px 8px rgba(187, 58, 34, 0.35);
  108. transform: rotate(-4deg);
  109. }
  110. .logo b {
  111. font-family: "Noto Serif SC", serif;
  112. font-weight: 900;
  113. font-size: 16px;
  114. letter-spacing: 1px;
  115. }
  116. .logo small {
  117. display: block;
  118. font-size: 10px;
  119. color: #93a7c0;
  120. letter-spacing: 3px;
  121. }
  122. nav {
  123. display: flex;
  124. gap: 6px;
  125. margin-left: 26px;
  126. }
  127. nav a {
  128. display: flex;
  129. align-items: center;
  130. padding: 7px 18px;
  131. color: #a8b9cd;
  132. text-decoration: none;
  133. font-weight: 500;
  134. letter-spacing: 0.5px;
  135. border-radius: 99px;
  136. transition: 0.15s;
  137. font-size: 13px;
  138. }
  139. nav a:hover {
  140. color: #fff;
  141. background: rgba(255, 255, 255, 0.07);
  142. }
  143. nav a.on {
  144. color: #fff;
  145. background: rgba(255, 255, 255, 0.13);
  146. box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
  147. }
  148. header .spacer {
  149. flex: 1;
  150. }
  151. header .hint {
  152. font-size: 11px;
  153. color: #6e83a0;
  154. letter-spacing: 2px;
  155. }
  156. main {
  157. display: none;
  158. padding: 24px 30px 80px;
  159. max-width: 1920px;
  160. margin: 0 auto;
  161. }
  162. main.on {
  163. display: block;
  164. }
  165. /* 数据集视图:整体定高占满视口,左侧列表与右侧解构各自独立滚动 */
  166. #view-dataset {
  167. padding-bottom: 20px;
  168. }
  169. #view-dataset.on {
  170. display: flex;
  171. flex-direction: column;
  172. height: calc(100vh - 60px);
  173. overflow: hidden;
  174. }
  175. /* 聚类库:内嵌知识检索页,占满视口、无内边距 */
  176. #view-cluster {
  177. padding: 0;
  178. max-width: none;
  179. }
  180. #view-cluster.on {
  181. display: flex;
  182. }
  183. #cluster-frame {
  184. border: 0;
  185. width: 100%;
  186. height: calc(100vh - 60px);
  187. display: block;
  188. }
  189. /* ── 通用卡片/标签/按钮 ── */
  190. .card {
  191. background: var(--card);
  192. border: 1px solid var(--line);
  193. border-radius: 12px;
  194. box-shadow: var(--shadow);
  195. }
  196. .pill {
  197. display: inline-block;
  198. padding: 1px 9px;
  199. border-radius: 99px;
  200. font-size: 11px;
  201. font-weight: 500;
  202. border: 1px solid var(--line-dark);
  203. background: #f7f6f2;
  204. color: var(--ink-soft);
  205. white-space: nowrap;
  206. }
  207. .pill.navy {
  208. background: #e8eef6;
  209. border-color: #bccbde;
  210. color: var(--navy);
  211. }
  212. .pill.amber {
  213. background: var(--amber-bg);
  214. border-color: #ecc88a;
  215. color: var(--amber);
  216. }
  217. .pill.teal {
  218. background: var(--teal-bg);
  219. border-color: #a9d6c8;
  220. color: var(--teal);
  221. }
  222. .pill.red {
  223. background: #fbeae5;
  224. border-color: #e4ab9c;
  225. color: var(--seal);
  226. }
  227. .pill.green {
  228. background: var(--green-bg);
  229. border-color: #a7d9b4;
  230. color: var(--green);
  231. }
  232. .btn {
  233. border: 1px solid var(--line-dark);
  234. background: var(--card);
  235. color: var(--ink);
  236. padding: 6px 14px;
  237. border-radius: 8px;
  238. font-size: 13px;
  239. font-weight: 500;
  240. transition: 0.15s;
  241. }
  242. .btn:hover {
  243. border-color: var(--blue);
  244. color: var(--blue);
  245. box-shadow: 0 2px 8px rgba(37, 99, 235, 0.12);
  246. }
  247. .btn.primary {
  248. background: var(--blue);
  249. border-color: var(--blue);
  250. color: #fff;
  251. }
  252. .btn.primary:hover {
  253. background: #1d4fc4;
  254. color: #fff;
  255. box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
  256. }
  257. .btn.seal {
  258. background: var(--seal);
  259. border-color: var(--seal);
  260. color: #fff;
  261. }
  262. .btn.seal:hover {
  263. background: #a02f1a;
  264. color: #fff;
  265. box-shadow: 0 4px 12px rgba(187, 58, 34, 0.3);
  266. }
  267. .btn.sm {
  268. padding: 3px 11px;
  269. font-size: 12px;
  270. }
  271. .btn:disabled {
  272. opacity: 0.45;
  273. cursor: not-allowed;
  274. box-shadow: none;
  275. }
  276. select,
  277. input[type="text"],
  278. input[type="number"] {
  279. font-family: inherit;
  280. font-size: 13px;
  281. padding: 6px 10px;
  282. border: 1px solid var(--line-dark);
  283. border-radius: 8px;
  284. background: #fff;
  285. color: var(--ink);
  286. outline: none;
  287. transition: 0.15s;
  288. }
  289. select:focus,
  290. input:focus {
  291. border-color: var(--blue);
  292. box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
  293. }
  294. .empty {
  295. text-align: center;
  296. color: var(--ink-faint);
  297. padding: 48px 20px;
  298. font-size: 13px;
  299. line-height: 2;
  300. }
  301. .empty .glyph {
  302. font-family: "Noto Serif SC", serif;
  303. font-size: 42px;
  304. color: var(--line-dark);
  305. display: block;
  306. }
  307. /* ── Dashboard ── */
  308. .dash-section {
  309. margin-bottom: 14px;
  310. display: flex;
  311. align-items: baseline;
  312. gap: 10px;
  313. }
  314. .dash-section h2 {
  315. font-size: 16px;
  316. font-weight: 900;
  317. letter-spacing: 2px;
  318. }
  319. .dash-section .rule {
  320. flex: 1;
  321. border-top: 1px dashed var(--line-dark);
  322. }
  323. .dash-section .tag {
  324. font-size: 10px;
  325. letter-spacing: 2px;
  326. color: var(--ink-faint);
  327. }
  328. .cards {
  329. display: grid;
  330. grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  331. gap: 14px;
  332. margin-bottom: 26px;
  333. }
  334. .stat {
  335. padding: 16px 18px 14px;
  336. position: relative;
  337. overflow: hidden;
  338. }
  339. .stat::after {
  340. content: "";
  341. position: absolute;
  342. left: 0;
  343. top: 0;
  344. bottom: 0;
  345. width: 3px;
  346. background: var(--navy);
  347. }
  348. .stat.a::after {
  349. background: var(--amber);
  350. }
  351. .stat.t::after {
  352. background: var(--teal);
  353. }
  354. .stat.r::after {
  355. background: var(--seal);
  356. }
  357. .stat .lbl {
  358. font-size: 11px;
  359. letter-spacing: 2px;
  360. color: var(--ink-soft);
  361. margin-bottom: 8px;
  362. }
  363. .stat .val {
  364. font-size: 30px;
  365. font-weight: 700;
  366. line-height: 1;
  367. }
  368. .stat .sub {
  369. font-size: 11px;
  370. color: var(--ink-faint);
  371. margin-top: 7px;
  372. }
  373. .stat .sub.plat-break {
  374. margin-top: 3px;
  375. color: var(--ink-soft);
  376. font-weight: 600;
  377. }
  378. .ring-row {
  379. display: flex;
  380. align-items: center;
  381. gap: 14px;
  382. }
  383. .ring {
  384. width: 64px;
  385. height: 64px;
  386. border-radius: 50%;
  387. display: grid;
  388. place-items: center;
  389. flex: none;
  390. background: conic-gradient(var(--teal) calc(var(--p) * 1%), #e9e7e0 0);
  391. }
  392. .ring > div {
  393. width: 48px;
  394. height: 48px;
  395. border-radius: 50%;
  396. background: var(--card);
  397. display: grid;
  398. place-items: center;
  399. font-size: 12px;
  400. font-weight: 700;
  401. }
  402. .charts {
  403. display: grid;
  404. grid-template-columns: repeat(12, 1fr);
  405. gap: 16px;
  406. }
  407. .chart-card {
  408. padding: 14px 16px 8px;
  409. }
  410. .chart-card h3 {
  411. font-size: 13px;
  412. font-weight: 700;
  413. letter-spacing: 1px;
  414. color: var(--ink-soft);
  415. margin-bottom: 4px;
  416. display: flex;
  417. align-items: baseline;
  418. gap: 8px;
  419. }
  420. .chart-card h3 .num {
  421. color: var(--seal);
  422. font-size: 12px;
  423. }
  424. .chart {
  425. width: 100%;
  426. }
  427. .span12 {
  428. grid-column: span 12;
  429. }
  430. .span6 {
  431. grid-column: span 6;
  432. }
  433. .span4 {
  434. grid-column: span 4;
  435. }
  436. @media (max-width: 1100px) {
  437. .span6,
  438. .span4 {
  439. grid-column: span 12;
  440. }
  441. }
  442. /* ── Dataset 三栏 ── */
  443. .ds-top {
  444. display: flex;
  445. align-items: center;
  446. gap: 12px;
  447. margin-bottom: 16px;
  448. }
  449. .mode-switch {
  450. display: flex;
  451. border: 1px solid var(--line-dark);
  452. border-radius: 10px;
  453. overflow: hidden;
  454. background: #fff;
  455. }
  456. .mode-switch button {
  457. border: 0;
  458. background: transparent;
  459. padding: 7px 24px;
  460. font-size: 13px;
  461. font-weight: 700;
  462. color: var(--ink-soft);
  463. transition: 0.15s;
  464. }
  465. .mode-switch button.on {
  466. background: var(--navy);
  467. color: #fff;
  468. }
  469. .ds-grid {
  470. display: grid;
  471. grid-template-columns: 235px 350px minmax(0, 1fr);
  472. gap: 16px;
  473. align-items: stretch;
  474. flex: 1;
  475. min-height: 0;
  476. }
  477. @media (max-width: 1280px) {
  478. .ds-grid {
  479. grid-template-columns: 200px 320px minmax(0, 1fr);
  480. }
  481. }
  482. /* 每一列卡片纵向铺满网格高度,内部滚动区独立滚动 */
  483. .ds-grid > .card {
  484. display: flex;
  485. flex-direction: column;
  486. min-height: 0;
  487. overflow: hidden;
  488. }
  489. .col-head {
  490. display: flex;
  491. align-items: center;
  492. justify-content: space-between;
  493. padding: 11px 14px;
  494. border-bottom: 1px solid var(--line);
  495. font-weight: 700;
  496. font-size: 13px;
  497. letter-spacing: 1px;
  498. }
  499. .col-head .n {
  500. font-size: 11px;
  501. color: var(--ink-faint);
  502. font-weight: 500;
  503. }
  504. .qlist {
  505. flex: 1;
  506. min-height: 0;
  507. overflow: auto;
  508. }
  509. .qitem {
  510. padding: 12px 14px;
  511. border-bottom: 1px solid var(--line);
  512. cursor: pointer;
  513. transition: 0.12s;
  514. }
  515. .qitem:hover {
  516. background: #f8f8f4;
  517. }
  518. .qitem.on {
  519. background: var(--blue-bg);
  520. box-shadow: inset 3px 0 0 var(--blue);
  521. }
  522. .qitem .qid {
  523. font-size: 10px;
  524. letter-spacing: 1px;
  525. color: var(--ink-faint);
  526. display: flex;
  527. gap: 6px;
  528. align-items: center;
  529. }
  530. .qitem .qt {
  531. font-weight: 500;
  532. margin: 4px 0 7px;
  533. line-height: 1.45;
  534. }
  535. .qitem .qm {
  536. font-size: 11px;
  537. color: var(--ink-soft);
  538. display: flex;
  539. gap: 10px;
  540. flex-wrap: wrap;
  541. align-items: center;
  542. }
  543. .qitem .qm b.hit {
  544. color: var(--blue);
  545. font-size: 13px;
  546. }
  547. /* 渠道 tab */
  548. .plat-tabs {
  549. display: flex;
  550. gap: 4px;
  551. padding: 8px 10px;
  552. border-bottom: 1px solid var(--line);
  553. overflow-x: auto;
  554. background: #fbfbf8;
  555. border-radius: 0;
  556. }
  557. .plat-tabs button {
  558. border: 1px solid transparent;
  559. background: transparent;
  560. color: var(--ink-soft);
  561. padding: 3px 11px;
  562. border-radius: 99px;
  563. font-size: 12px;
  564. font-weight: 500;
  565. white-space: nowrap;
  566. transition: 0.15s;
  567. }
  568. .plat-tabs button:hover {
  569. background: #efeee8;
  570. color: var(--ink);
  571. }
  572. .plat-tabs button.on {
  573. background: var(--navy);
  574. color: #fff;
  575. font-weight: 700;
  576. }
  577. .plat-tabs button .c {
  578. font-size: 10px;
  579. opacity: 0.75;
  580. margin-left: 3px;
  581. }
  582. /* 已解构筛选按钮:靠右,激活态用 teal 呼应「已解构」 */
  583. .plat-tabs .done-filter {
  584. margin-left: auto;
  585. flex: none;
  586. border: 1px solid var(--line);
  587. display: inline-flex;
  588. align-items: center;
  589. gap: 4px;
  590. color: var(--ink-soft);
  591. }
  592. .plat-tabs .done-filter:hover {
  593. background: #efeee8;
  594. color: var(--ink);
  595. }
  596. .plat-tabs .done-filter.on {
  597. background: var(--teal-bg, #e3f1ec);
  598. border-color: #a9d6c8;
  599. color: var(--teal);
  600. font-weight: 700;
  601. }
  602. .plat-tabs .done-filter .dot {
  603. font-size: 8px;
  604. }
  605. .plist {
  606. flex: 1;
  607. min-height: 0;
  608. overflow: auto;
  609. }
  610. .post {
  611. padding: 12px 13px;
  612. border-bottom: 1px solid var(--line);
  613. cursor: pointer;
  614. display: flex;
  615. gap: 10px;
  616. transition: 0.12s;
  617. align-items: flex-start;
  618. }
  619. .post:hover {
  620. background: #f8f8f4;
  621. }
  622. .post.on {
  623. background: var(--blue-bg);
  624. box-shadow: inset 3px 0 0 var(--blue);
  625. }
  626. .post input {
  627. margin-top: 4px;
  628. accent-color: var(--blue);
  629. }
  630. .post .pt {
  631. font-weight: 500;
  632. line-height: 1.45;
  633. font-size: 13px;
  634. }
  635. .post .pm {
  636. display: flex;
  637. flex-wrap: wrap;
  638. gap: 5px;
  639. margin-top: 7px;
  640. align-items: center;
  641. }
  642. .plat {
  643. display: inline-block;
  644. padding: 1px 7px;
  645. border-radius: 4px;
  646. font-size: 10px;
  647. font-weight: 700;
  648. color: #fff;
  649. }
  650. .plat.xhs {
  651. background: #d63a2f;
  652. }
  653. .plat.gzh {
  654. background: #2e9939;
  655. }
  656. .plat.zhihu {
  657. background: #1772f6;
  658. }
  659. .plat.douyin {
  660. background: #170b1a;
  661. }
  662. .plat.sph {
  663. background: #fa6d20;
  664. }
  665. .plat.youtube {
  666. background: #c00;
  667. }
  668. .plat.x {
  669. background: #15202b;
  670. }
  671. .plat.other {
  672. background: #777;
  673. }
  674. .plat-logo {
  675. display: inline-flex;
  676. line-height: 0;
  677. flex: none;
  678. }
  679. .plat-logo svg {
  680. display: block;
  681. }
  682. .done-dot {
  683. font-size: 10px;
  684. color: var(--teal);
  685. font-weight: 700;
  686. }
  687. /* 评分徽章:大、亮、可点 */
  688. .score-badge {
  689. flex: none;
  690. position: relative;
  691. font-family: "IBM Plex Mono", monospace;
  692. font-weight: 700;
  693. font-size: 16.5px;
  694. line-height: 1;
  695. padding: 8px 10px;
  696. border-radius: 9px;
  697. cursor: pointer;
  698. transition: 0.15s;
  699. align-self: center;
  700. border: 1px solid transparent;
  701. }
  702. .score-badge.s9 {
  703. color: #fff;
  704. background: linear-gradient(135deg, #16a34a, #15803d);
  705. box-shadow: 0 3px 10px rgba(22, 163, 74, 0.35);
  706. }
  707. .score-badge.s8 {
  708. color: #fff;
  709. background: linear-gradient(135deg, #3b82f6, #2563eb);
  710. box-shadow: 0 3px 10px rgba(37, 99, 235, 0.35);
  711. }
  712. .score-badge.s6 {
  713. color: #fff;
  714. background: linear-gradient(135deg, #f59e0b, #d97706);
  715. box-shadow: 0 3px 10px rgba(217, 119, 6, 0.32);
  716. }
  717. .score-badge.s0 {
  718. color: var(--ink-soft);
  719. background: #eceae4;
  720. border-color: var(--line-dark);
  721. }
  722. .score-badge:hover {
  723. transform: translateY(-2px) scale(1.06);
  724. }
  725. .score-badge::after {
  726. content: "查看详情";
  727. position: absolute;
  728. left: 50%;
  729. bottom: calc(100% + 6px);
  730. transform: translateX(-50%) scale(0.92);
  731. background: var(--ink);
  732. color: #fff;
  733. font-family: "Noto Sans SC", sans-serif;
  734. font-size: 10px;
  735. font-weight: 500;
  736. padding: 3px 8px;
  737. border-radius: 5px;
  738. white-space: nowrap;
  739. opacity: 0;
  740. pointer-events: none;
  741. transition: 0.15s;
  742. z-index: 5;
  743. }
  744. .score-badge:hover::after {
  745. opacity: 1;
  746. transform: translateX(-50%) scale(1);
  747. }
  748. .xp {
  749. min-height: 60vh;
  750. }
  751. .xp-head {
  752. display: flex;
  753. align-items: center;
  754. gap: 10px;
  755. padding: 12px 16px;
  756. border-bottom: 1px solid var(--line);
  757. flex-wrap: wrap;
  758. }
  759. .xp-head .st {
  760. font-family: "Noto Serif SC", serif;
  761. font-weight: 900;
  762. font-size: 15px;
  763. }
  764. .xp-head .st em {
  765. color: var(--seal);
  766. font-style: normal;
  767. }
  768. .xp-head .spacer {
  769. flex: 1;
  770. }
  771. .xp-body {
  772. padding: 16px;
  773. flex: 1;
  774. min-height: 0;
  775. overflow: auto;
  776. }
  777. /* 工序卡 */
  778. .proc {
  779. border: 1px solid var(--line);
  780. border-radius: 10px;
  781. margin-bottom: 22px;
  782. overflow: hidden;
  783. background: #fff;
  784. box-shadow: var(--shadow);
  785. }
  786. .proc-head {
  787. padding: 14px 16px;
  788. border-bottom: 1px solid var(--line);
  789. background: #fafaf6;
  790. }
  791. .proc-head .nm {
  792. font-family: "Noto Serif SC", serif;
  793. font-weight: 900;
  794. font-size: 15px;
  795. }
  796. .proc-head .nm .pid {
  797. color: var(--seal);
  798. margin-right: 6px;
  799. font-size: 13px;
  800. }
  801. .proc-head .pp {
  802. font-size: 12px;
  803. color: var(--ink-soft);
  804. margin-top: 5px;
  805. line-height: 1.6;
  806. }
  807. .proc-head .meta {
  808. display: flex;
  809. gap: 6px;
  810. flex-wrap: wrap;
  811. margin-top: 8px;
  812. }
  813. .decl {
  814. display: grid;
  815. grid-template-columns: 1fr 1fr;
  816. gap: 0;
  817. border-bottom: 1px solid var(--line);
  818. }
  819. .decl > div {
  820. padding: 10px 16px;
  821. }
  822. .decl > div + div {
  823. border-left: 1px solid var(--line);
  824. }
  825. .decl .dl {
  826. font-size: 10px;
  827. letter-spacing: 2px;
  828. color: var(--ink-faint);
  829. margin-bottom: 6px;
  830. }
  831. .decl .di {
  832. font-size: 12px;
  833. line-height: 1.7;
  834. }
  835. .decl .di b {
  836. font-weight: 700;
  837. }
  838. /* 步骤表:固定列宽撑开,宿主容器 overflow-x 滚动 */
  839. .steps {
  840. width: 100%;
  841. min-width: 1760px;
  842. table-layout: fixed;
  843. border-collapse: collapse;
  844. font-size: 12px;
  845. }
  846. .steps th {
  847. padding: 6px 8px;
  848. font-size: 11px;
  849. font-weight: 700;
  850. letter-spacing: 1px;
  851. color: #fff;
  852. text-align: left;
  853. }
  854. .steps thead tr:first-child th {
  855. text-align: center;
  856. font-size: 12px;
  857. letter-spacing: 4px;
  858. padding: 7px 4px;
  859. }
  860. .steps .h-req {
  861. background: var(--navy);
  862. }
  863. .steps .h-req2 {
  864. background: #33547a;
  865. }
  866. .steps .h-in {
  867. background: var(--amber);
  868. }
  869. .steps .h-in2 {
  870. background: #cd7522;
  871. }
  872. .steps .h-im {
  873. background: var(--teal);
  874. }
  875. .steps .h-im2 {
  876. background: #2d8273;
  877. }
  878. .steps .h-out {
  879. background: var(--green);
  880. }
  881. .steps .h-out2 {
  882. background: #2e6b45;
  883. }
  884. .steps td {
  885. padding: 8px 9px;
  886. border: 1px solid var(--line);
  887. vertical-align: top;
  888. line-height: 1.6;
  889. }
  890. .steps tbody tr:nth-child(odd) td {
  891. background: #fdfdf9;
  892. }
  893. .steps td.c-in {
  894. background: var(--amber-bg) !important;
  895. }
  896. .steps td.c-out {
  897. background: var(--green-bg) !important;
  898. }
  899. .steps .sid {
  900. font-family: "IBM Plex Mono", monospace;
  901. font-weight: 700;
  902. color: var(--navy);
  903. white-space: nowrap;
  904. }
  905. .steps .vtxt {
  906. color: var(--ink-soft);
  907. font-size: 11.5px;
  908. word-break: break-all;
  909. }
  910. .inf {
  911. background: var(--infer) !important;
  912. position: relative;
  913. outline: 1px dashed var(--infer-edge);
  914. outline-offset: -2px;
  915. }
  916. .inf .ib {
  917. position: absolute;
  918. top: -1px;
  919. right: -1px;
  920. background: var(--infer-edge);
  921. color: #fff;
  922. font-size: 9px;
  923. padding: 0 4px;
  924. border-radius: 0 0 0 4px;
  925. font-weight: 700;
  926. }
  927. .anchor {
  928. font-family: "IBM Plex Mono", monospace;
  929. font-size: 10.5px;
  930. color: var(--ink-faint);
  931. word-break: break-all;
  932. }
  933. /* 输入/输出「值」单元格:超过 4 行加蒙版,点击展开/收起 */
  934. .clamp-val {
  935. position: relative;
  936. }
  937. .clamp-val.clampable {
  938. max-height: 6.6em;
  939. overflow: hidden;
  940. cursor: zoom-in;
  941. }
  942. .clamp-val.clampable::after {
  943. content: "";
  944. position: absolute;
  945. left: 0;
  946. right: 0;
  947. bottom: 0;
  948. height: 2.4em;
  949. pointer-events: none;
  950. }
  951. .steps td.c-in .clamp-val.clampable::after {
  952. background: linear-gradient(180deg, rgba(255, 247, 232, 0), rgba(255, 247, 232, 1));
  953. }
  954. .steps td.c-out .clamp-val.clampable::after {
  955. background: linear-gradient(180deg, rgba(239, 250, 241, 0), rgba(239, 250, 241, 1));
  956. }
  957. .clamp-val.open {
  958. max-height: none;
  959. overflow: visible;
  960. cursor: zoom-out;
  961. }
  962. .clamp-val.open::after {
  963. display: none;
  964. }
  965. /* 工具表格(移植自 fixed_query_eval:案例逐行 rowspan + 限高展开) */
  966. .mw-ttwrap {
  967. overflow-x: auto;
  968. border: 1px solid var(--line);
  969. border-radius: 10px;
  970. box-shadow: var(--shadow);
  971. }
  972. .mw-tt {
  973. border-collapse: separate;
  974. border-spacing: 0;
  975. width: 100%;
  976. min-width: 1180px;
  977. background: #fff;
  978. font-size: 12.5px;
  979. }
  980. .mw-tt thead th {
  981. position: sticky;
  982. top: 0;
  983. z-index: 2;
  984. text-align: left;
  985. white-space: nowrap;
  986. background: linear-gradient(180deg, #2aa79b, #1c8076);
  987. color: #fff;
  988. font-weight: 700;
  989. padding: 10px 12px;
  990. letter-spacing: 0.3px;
  991. border-right: 1px solid rgba(255, 255, 255, 0.18);
  992. }
  993. .mw-tt thead th:last-child {
  994. border-right: none;
  995. }
  996. .mw-tt thead tr:first-child th {
  997. top: 0;
  998. }
  999. .mw-tt thead tr:nth-child(2) th {
  1000. top: 38px;
  1001. }
  1002. .mw-tt .th-group {
  1003. text-align: center;
  1004. }
  1005. .mw-tt .th-sub {
  1006. background: linear-gradient(180deg, #36bdb0, #23897f);
  1007. font-weight: 600;
  1008. }
  1009. .mw-tt tbody td {
  1010. padding: 9px 12px;
  1011. vertical-align: top;
  1012. line-height: 1.6;
  1013. border-bottom: 1px solid #f0eee8;
  1014. border-right: 1px solid #f5f3ee;
  1015. color: #3a3a3a;
  1016. }
  1017. .mw-tt tbody td:last-child {
  1018. border-right: none;
  1019. }
  1020. .mw-tt td.col-case {
  1021. background: #fafdfc;
  1022. }
  1023. .mw-tt tbody tr.tr-b td {
  1024. background: #fbfaf6;
  1025. }
  1026. .mw-tt tbody tr.tr-b td.col-case {
  1027. background: #f6fbfa;
  1028. }
  1029. .mw-tt tbody td.col-tool {
  1030. font-weight: 700;
  1031. color: #176d64;
  1032. white-space: nowrap;
  1033. border-left: 3px solid #2aa79b;
  1034. background: #f3faf8;
  1035. }
  1036. .mw-tt tbody tr:hover td.col-tool {
  1037. background: #e3f4f0;
  1038. }
  1039. .mw-tt ul {
  1040. margin: 0;
  1041. padding-left: 17px;
  1042. }
  1043. .mw-tt ul li {
  1044. margin: 3px 0;
  1045. }
  1046. .mw-tt ul li::marker {
  1047. color: #2aa79b;
  1048. }
  1049. .mw-tt .layer-badge {
  1050. display: inline-block;
  1051. font-weight: 700;
  1052. font-size: 11px;
  1053. padding: 2px 10px;
  1054. border-radius: 20px;
  1055. white-space: nowrap;
  1056. }
  1057. .mw-tt .layer-badge.make {
  1058. color: #0e7490;
  1059. background: #d6f0ee;
  1060. }
  1061. .mw-tt .layer-badge.create {
  1062. color: #b8731a;
  1063. background: #fef0db;
  1064. }
  1065. .mw-tt .dash {
  1066. color: #c9c2b6;
  1067. }
  1068. .mw-tt .tcell {
  1069. position: relative;
  1070. max-height: 7.8em;
  1071. overflow: hidden;
  1072. transition: max-height 0.15s;
  1073. }
  1074. .mw-tt .tcell.clamped {
  1075. cursor: zoom-in;
  1076. }
  1077. .mw-tt .tcell.clamped::after {
  1078. content: "▾ 展开";
  1079. position: absolute;
  1080. left: 0;
  1081. right: 0;
  1082. bottom: 0;
  1083. height: 2.6em;
  1084. display: flex;
  1085. align-items: flex-end;
  1086. justify-content: center;
  1087. padding-bottom: 2px;
  1088. font-size: 11px;
  1089. font-weight: 700;
  1090. color: #176d64;
  1091. background: linear-gradient(rgba(255, 255, 255, 0), #fff 72%);
  1092. pointer-events: none;
  1093. }
  1094. .mw-tt tbody tr.tr-b .tcell.clamped::after {
  1095. background: linear-gradient(rgba(251, 250, 246, 0), #fbfaf6 72%);
  1096. }
  1097. .mw-tt td.col-case .tcell.clamped::after {
  1098. background: linear-gradient(rgba(250, 253, 252, 0), #fafdfc 72%);
  1099. }
  1100. .mw-tt tbody tr.tr-b td.col-case .tcell.clamped::after {
  1101. background: linear-gradient(rgba(246, 251, 250, 0), #f6fbfa 72%);
  1102. }
  1103. .mw-tt .tcell.open {
  1104. max-height: none;
  1105. cursor: zoom-out;
  1106. }
  1107. .mw-tt .tcell.open::after {
  1108. content: "";
  1109. height: 0;
  1110. }
  1111. /* ── 帖子详情弹层 ── */
  1112. dialog#post-dialog {
  1113. width: min(1100px, 94vw);
  1114. max-height: calc(100vh - 40px);
  1115. border: none;
  1116. border-radius: 14px;
  1117. padding: 0;
  1118. box-shadow: var(--shadow-lg);
  1119. overflow: hidden;
  1120. margin: auto; /* 全局 reset 清掉了 dialog 默认 margin:auto,这里补回才能居中 */
  1121. }
  1122. dialog#post-dialog::backdrop {
  1123. background: rgba(19, 30, 46, 0.5);
  1124. backdrop-filter: blur(2px);
  1125. }
  1126. .pd-wrap {
  1127. display: flex;
  1128. flex-direction: column;
  1129. max-height: calc(100vh - 40px);
  1130. }
  1131. .pd-head {
  1132. display: flex;
  1133. justify-content: space-between;
  1134. gap: 14px;
  1135. align-items: flex-start;
  1136. padding: 16px 20px;
  1137. border-bottom: 1px solid var(--line);
  1138. background: #fff;
  1139. flex: none;
  1140. }
  1141. .pd-head h3 {
  1142. font-family: "Noto Serif SC", serif;
  1143. font-size: 18px;
  1144. line-height: 1.35;
  1145. margin-top: 6px;
  1146. }
  1147. .pd-meta {
  1148. display: flex;
  1149. gap: 8px;
  1150. flex-wrap: wrap;
  1151. align-items: center;
  1152. font-size: 12px;
  1153. color: var(--ink-soft);
  1154. }
  1155. .pd-close {
  1156. border: none;
  1157. background: #f1f0ea;
  1158. width: 30px;
  1159. height: 30px;
  1160. border-radius: 8px;
  1161. font-size: 14px;
  1162. color: var(--ink-soft);
  1163. flex: none;
  1164. transition: 0.15s;
  1165. }
  1166. .pd-close:hover {
  1167. background: var(--seal);
  1168. color: #fff;
  1169. }
  1170. .pd-body {
  1171. display: grid;
  1172. grid-template-columns: 1.05fr 0.95fr;
  1173. gap: 20px;
  1174. padding: 18px 20px;
  1175. overflow: auto;
  1176. }
  1177. @media (max-width: 920px) {
  1178. .pd-body {
  1179. grid-template-columns: 1fr;
  1180. }
  1181. }
  1182. .pd-body > section,
  1183. .pd-body > aside {
  1184. min-width: 0;
  1185. }
  1186. .pd-sec-title {
  1187. font-weight: 800;
  1188. margin: 16px 0 8px;
  1189. font-size: 13px;
  1190. }
  1191. .pd-sec-title:first-child {
  1192. margin-top: 0;
  1193. }
  1194. .pd-verdict {
  1195. background: #eaf6fb;
  1196. border-left: 4px solid #2c9ec7;
  1197. padding: 10px 12px;
  1198. color: #22566b;
  1199. border-radius: 6px;
  1200. font-size: 13px;
  1201. line-height: 1.6;
  1202. }
  1203. .pd-raw {
  1204. white-space: pre-wrap;
  1205. background: #faf9f5;
  1206. border: 1px solid var(--line);
  1207. border-radius: 10px;
  1208. padding: 12px;
  1209. max-height: 320px;
  1210. overflow: auto;
  1211. color: #3d3f44;
  1212. font-size: 13px;
  1213. line-height: 1.7;
  1214. }
  1215. .pd-images {
  1216. display: grid;
  1217. grid-template-columns: repeat(2, minmax(0, 1fr));
  1218. gap: 8px;
  1219. }
  1220. .pd-images img {
  1221. width: 100%;
  1222. max-height: 250px;
  1223. object-fit: contain;
  1224. border: 1px solid var(--line);
  1225. border-radius: 10px;
  1226. background: #f3f2ed;
  1227. cursor: zoom-in;
  1228. }
  1229. /* ── 图片预览灯箱 ── */
  1230. dialog.lightbox {
  1231. position: fixed;
  1232. inset: 0;
  1233. width: 100%;
  1234. height: 100%;
  1235. max-width: 100%;
  1236. max-height: 100%;
  1237. margin: 0;
  1238. padding: 40px 72px;
  1239. border: none;
  1240. gap: 18px;
  1241. align-items: center;
  1242. justify-content: center;
  1243. background: rgba(20, 20, 22, 0.86);
  1244. backdrop-filter: blur(2px);
  1245. overflow: hidden;
  1246. }
  1247. dialog.lightbox[open] {
  1248. display: flex;
  1249. }
  1250. dialog.lightbox::backdrop {
  1251. background: rgba(20, 20, 22, 0.5);
  1252. }
  1253. .lb-stage {
  1254. margin: 0;
  1255. max-width: 100%;
  1256. max-height: 100%;
  1257. display: flex;
  1258. flex-direction: column;
  1259. align-items: center;
  1260. gap: 12px;
  1261. }
  1262. .lb-stage img {
  1263. max-width: min(1100px, 86vw);
  1264. max-height: 82vh;
  1265. object-fit: contain;
  1266. border-radius: 8px;
  1267. box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
  1268. background: #2a2a2c;
  1269. }
  1270. .lb-stage figcaption {
  1271. color: rgba(255, 255, 255, 0.78);
  1272. font-size: 13px;
  1273. letter-spacing: 0.5px;
  1274. }
  1275. .lb-nav {
  1276. flex: 0 0 auto;
  1277. width: 46px;
  1278. height: 46px;
  1279. border-radius: 50%;
  1280. border: none;
  1281. background: rgba(255, 255, 255, 0.12);
  1282. color: #fff;
  1283. font-size: 28px;
  1284. line-height: 1;
  1285. cursor: pointer;
  1286. transition: 0.15s;
  1287. }
  1288. .lb-nav:hover {
  1289. background: rgba(255, 255, 255, 0.26);
  1290. }
  1291. .lb-close {
  1292. position: absolute;
  1293. top: 20px;
  1294. right: 24px;
  1295. width: 38px;
  1296. height: 38px;
  1297. border-radius: 50%;
  1298. border: none;
  1299. background: rgba(255, 255, 255, 0.12);
  1300. color: #fff;
  1301. font-size: 18px;
  1302. cursor: pointer;
  1303. transition: 0.15s;
  1304. }
  1305. .lb-close:hover {
  1306. background: rgba(255, 255, 255, 0.26);
  1307. }
  1308. /* ── 帖子列表缩略图 ── */
  1309. .post .thumb {
  1310. flex: 0 0 auto;
  1311. width: 44px;
  1312. height: 44px;
  1313. border-radius: 7px;
  1314. object-fit: cover;
  1315. background: #f0efe9;
  1316. border: 1px solid var(--line);
  1317. }
  1318. .post .thumb-ph {
  1319. flex: 0 0 auto;
  1320. width: 44px;
  1321. height: 44px;
  1322. border-radius: 7px;
  1323. background: #f0efe9;
  1324. border: 1px solid var(--line);
  1325. display: flex;
  1326. align-items: center;
  1327. justify-content: center;
  1328. color: var(--ink-faint);
  1329. font-size: 16px;
  1330. }
  1331. /* ── 原文卡片(可整体展开/收起;含标题、图片缩略图、正文) ── */
  1332. .src-block {
  1333. border: 1px solid var(--line);
  1334. border-radius: 10px;
  1335. margin-bottom: 14px;
  1336. background: #faf9f5;
  1337. overflow: hidden;
  1338. }
  1339. .src-head {
  1340. display: flex;
  1341. align-items: center;
  1342. gap: 8px;
  1343. padding: 9px 12px;
  1344. cursor: pointer;
  1345. user-select: none;
  1346. }
  1347. .src-head:hover {
  1348. background: #f3f2ed;
  1349. }
  1350. .src-caret {
  1351. flex: 0 0 auto;
  1352. color: var(--ink-faint);
  1353. font-size: 11px;
  1354. transition: transform 0.15s;
  1355. }
  1356. .src-block.open .src-caret {
  1357. transform: rotate(90deg);
  1358. }
  1359. .src-label {
  1360. flex: 0 0 auto;
  1361. font-size: 11px;
  1362. font-weight: 700;
  1363. color: var(--blue);
  1364. background: var(--blue-bg);
  1365. padding: 1px 7px;
  1366. border-radius: 4px;
  1367. }
  1368. .src-title {
  1369. flex: 1;
  1370. min-width: 0;
  1371. font-weight: 600;
  1372. font-size: 13px;
  1373. white-space: nowrap;
  1374. overflow: hidden;
  1375. text-overflow: ellipsis;
  1376. }
  1377. .src-link {
  1378. flex: 0 0 auto;
  1379. font-size: 12px;
  1380. color: var(--blue);
  1381. text-decoration: none;
  1382. }
  1383. .src-body {
  1384. padding: 0 12px 12px;
  1385. }
  1386. .src-block:not(.open) .src-body {
  1387. display: none;
  1388. }
  1389. .src-thumbs {
  1390. display: flex;
  1391. gap: 8px;
  1392. overflow-x: auto;
  1393. padding: 4px 2px 10px;
  1394. scrollbar-width: thin;
  1395. }
  1396. .src-thumbs img {
  1397. flex: 0 0 auto;
  1398. height: 96px;
  1399. width: auto;
  1400. max-width: 150px;
  1401. border-radius: 8px;
  1402. border: 1px solid var(--line);
  1403. object-fit: cover;
  1404. background: #f0efe9;
  1405. cursor: zoom-in;
  1406. }
  1407. .src-text {
  1408. font-size: 13px;
  1409. line-height: 1.7;
  1410. color: #3d3f44;
  1411. white-space: pre-wrap;
  1412. }
  1413. .src-text.clamp {
  1414. max-height: 88px;
  1415. overflow: hidden;
  1416. -webkit-mask-image: linear-gradient(180deg, #000 62%, transparent);
  1417. mask-image: linear-gradient(180deg, #000 62%, transparent);
  1418. }
  1419. .src-text-toggle {
  1420. margin-top: 4px;
  1421. background: none;
  1422. border: none;
  1423. color: var(--blue);
  1424. cursor: pointer;
  1425. font-size: 12px;
  1426. padding: 2px 0;
  1427. }
  1428. .pd-tags {
  1429. display: flex;
  1430. gap: 6px;
  1431. flex-wrap: wrap;
  1432. margin-top: 12px;
  1433. }
  1434. .pd-score-head {
  1435. display: flex;
  1436. justify-content: space-between;
  1437. align-items: center;
  1438. margin-bottom: 10px;
  1439. }
  1440. .pd-score-head .t {
  1441. font-weight: 800;
  1442. font-size: 14px;
  1443. }
  1444. .pd-overall {
  1445. display: flex;
  1446. align-items: center;
  1447. gap: 6px;
  1448. font-size: 12.5px;
  1449. font-weight: 700;
  1450. color: var(--ink-soft);
  1451. background: #faf9f5;
  1452. border: 1px solid var(--line);
  1453. padding: 4px 12px;
  1454. border-radius: 8px;
  1455. }
  1456. .pd-overall b {
  1457. font-size: 20px;
  1458. color: var(--blue);
  1459. font-weight: 900;
  1460. line-height: 1;
  1461. }
  1462. .sc-card {
  1463. border: 1px solid var(--line);
  1464. border-radius: 10px;
  1465. background: #fff;
  1466. overflow: hidden;
  1467. margin-bottom: 12px;
  1468. }
  1469. .sc-card-head {
  1470. display: flex;
  1471. justify-content: space-between;
  1472. align-items: center;
  1473. gap: 10px;
  1474. padding: 10px 12px;
  1475. background: #faf9f5;
  1476. border-bottom: 1px solid var(--line);
  1477. font-size: 13px;
  1478. font-weight: 800;
  1479. }
  1480. .sc-card-head .badge {
  1481. display: inline-grid;
  1482. place-items: center;
  1483. width: 20px;
  1484. height: 20px;
  1485. border-radius: 5px;
  1486. background: var(--navy);
  1487. color: #fff;
  1488. font-size: 10px;
  1489. font-weight: 700;
  1490. margin-right: 7px;
  1491. }
  1492. .sc-card-head .avg {
  1493. font-size: 12px;
  1494. color: var(--ink-faint);
  1495. font-weight: 600;
  1496. }
  1497. .sc-card-head .avg b {
  1498. font-size: 17px;
  1499. color: var(--blue);
  1500. font-weight: 900;
  1501. }
  1502. .sc-card-body {
  1503. display: grid;
  1504. gap: 8px;
  1505. padding: 11px 12px;
  1506. }
  1507. /* 维度分组小标题:参考 mode_procedure —— 一级虚线大写,二级点线常规 */
  1508. .sc-sub {
  1509. font-size: 11px;
  1510. font-weight: 800;
  1511. letter-spacing: 0.8px;
  1512. color: var(--ink-faint);
  1513. text-transform: uppercase;
  1514. margin: 14px 0 8px;
  1515. padding-bottom: 5px;
  1516. border-bottom: 1px dashed var(--line-dark);
  1517. }
  1518. .sc-card-body > .sc-sub:first-child {
  1519. margin-top: 2px;
  1520. }
  1521. .sc-sub.lv2 {
  1522. font-size: 11px;
  1523. font-weight: 700;
  1524. letter-spacing: 0.3px;
  1525. text-transform: none;
  1526. color: var(--ink-soft);
  1527. margin: 11px 0 6px;
  1528. padding-bottom: 4px;
  1529. border-bottom: 1px dotted var(--line);
  1530. }
  1531. .sc-row {
  1532. display: grid;
  1533. grid-template-columns: 118px 1fr 30px 16px;
  1534. gap: 9px;
  1535. align-items: center;
  1536. font-size: 12.5px;
  1537. }
  1538. .sc-row .meter {
  1539. height: 8px;
  1540. border-radius: 99px;
  1541. background: #edebe4;
  1542. overflow: hidden;
  1543. }
  1544. .sc-row .meter span {
  1545. display: block;
  1546. height: 100%;
  1547. border-radius: 99px;
  1548. background: linear-gradient(90deg, #60a5fa, #2563eb);
  1549. }
  1550. .sc-row b {
  1551. font-weight: 700;
  1552. text-align: right;
  1553. }
  1554. .sc-row .info {
  1555. color: var(--ink-faint);
  1556. cursor: pointer;
  1557. font-size: 12px;
  1558. opacity: 0.75;
  1559. user-select: none;
  1560. }
  1561. .sc-row .info:hover {
  1562. color: var(--blue);
  1563. opacity: 1;
  1564. }
  1565. /* 判定理由弹层:点击 ⓘ 时浮现,挂在 dialog 顶层 */
  1566. .score-pop {
  1567. position: fixed;
  1568. z-index: 90;
  1569. width: 288px;
  1570. max-width: calc(100vw - 24px);
  1571. background: var(--card);
  1572. border: 1px solid var(--line-dark);
  1573. border-radius: 10px;
  1574. box-shadow: var(--shadow-lg);
  1575. padding: 12px 14px;
  1576. font-size: 12.5px;
  1577. line-height: 1.65;
  1578. color: var(--ink-soft);
  1579. animation: popIn 0.12s ease;
  1580. }
  1581. .score-pop .sp-head {
  1582. display: flex;
  1583. align-items: center;
  1584. gap: 8px;
  1585. margin-bottom: 8px;
  1586. padding-bottom: 8px;
  1587. border-bottom: 1px solid var(--line);
  1588. }
  1589. .score-pop .sp-tag {
  1590. font-size: 9px;
  1591. letter-spacing: 1.5px;
  1592. color: var(--ink-faint);
  1593. font-weight: 700;
  1594. border: 1px solid var(--line-dark);
  1595. border-radius: 5px;
  1596. padding: 2px 6px;
  1597. white-space: nowrap;
  1598. }
  1599. .score-pop .sp-name {
  1600. font-weight: 800;
  1601. font-size: 13px;
  1602. color: var(--ink);
  1603. }
  1604. .score-pop .sp-score {
  1605. margin-left: auto;
  1606. font-size: 16px;
  1607. font-weight: 900;
  1608. color: var(--blue);
  1609. }
  1610. .score-pop .sp-body {
  1611. white-space: pre-wrap;
  1612. }
  1613. @keyframes popIn {
  1614. from {
  1615. opacity: 0;
  1616. transform: translateY(-4px);
  1617. }
  1618. to {
  1619. opacity: 1;
  1620. transform: none;
  1621. }
  1622. }
  1623. /* 任务面板 */
  1624. #task-panel {
  1625. position: fixed;
  1626. right: 22px;
  1627. bottom: 22px;
  1628. width: 440px;
  1629. max-height: 55vh;
  1630. z-index: 60;
  1631. display: flex;
  1632. flex-direction: column;
  1633. border: 1px solid var(--line-dark);
  1634. border-radius: 12px;
  1635. background: var(--card);
  1636. box-shadow: var(--shadow-lg);
  1637. overflow: hidden;
  1638. }
  1639. #task-panel header {
  1640. all: unset;
  1641. display: flex;
  1642. align-items: center;
  1643. gap: 9px;
  1644. padding: 11px 14px;
  1645. background: var(--navy-deep);
  1646. color: #fff;
  1647. font-size: 13px;
  1648. font-weight: 700;
  1649. }
  1650. #task-panel header .dot {
  1651. width: 8px;
  1652. height: 8px;
  1653. border-radius: 50%;
  1654. background: #f5b942;
  1655. animation: blink 1s infinite;
  1656. }
  1657. #task-panel header .dot.done {
  1658. background: #3fb27f;
  1659. animation: none;
  1660. }
  1661. #task-panel header .dot.failed {
  1662. background: #e0492f;
  1663. animation: none;
  1664. }
  1665. @keyframes blink {
  1666. 50% {
  1667. opacity: 0.3;
  1668. }
  1669. }
  1670. #task-panel header button {
  1671. margin-left: auto;
  1672. background: none;
  1673. border: 0;
  1674. color: #9eb0c5;
  1675. font-size: 15px;
  1676. }
  1677. #task-panel header button:hover {
  1678. color: #fff;
  1679. }
  1680. #task-log {
  1681. font-family: "IBM Plex Mono", monospace;
  1682. font-size: 11px;
  1683. line-height: 1.65;
  1684. color: var(--ink-soft);
  1685. white-space: pre-wrap;
  1686. overflow: auto;
  1687. padding: 12px 14px;
  1688. background: #fafaf6;
  1689. flex: 1;
  1690. }
  1691. /* 弹窗(新建搜索) */
  1692. .modal-bg {
  1693. position: fixed;
  1694. inset: 0;
  1695. background: rgba(19, 30, 46, 0.5);
  1696. z-index: 70;
  1697. display: grid;
  1698. place-items: center;
  1699. backdrop-filter: blur(2px);
  1700. }
  1701. /* 不能 overflow:hidden,否则渠道下拉面板会被裁掉 */
  1702. .modal {
  1703. width: 460px;
  1704. background: var(--card);
  1705. border-radius: 14px;
  1706. box-shadow: var(--shadow-lg);
  1707. }
  1708. .modal h2 {
  1709. padding: 14px 18px;
  1710. background: var(--navy-deep);
  1711. color: #fff;
  1712. font-size: 15px;
  1713. letter-spacing: 2px;
  1714. border-radius: 14px 14px 0 0;
  1715. }
  1716. .modal .mb {
  1717. padding: 18px;
  1718. display: grid;
  1719. gap: 12px;
  1720. }
  1721. .modal label {
  1722. font-size: 12px;
  1723. color: var(--ink-soft);
  1724. display: grid;
  1725. gap: 5px;
  1726. }
  1727. .modal .mf {
  1728. display: flex;
  1729. justify-content: flex-end;
  1730. gap: 10px;
  1731. padding: 0 18px 18px;
  1732. }
  1733. /* 渠道下拉多选 */
  1734. .dd {
  1735. position: relative;
  1736. }
  1737. .dd-btn {
  1738. width: 100%;
  1739. display: flex;
  1740. justify-content: space-between;
  1741. align-items: center;
  1742. gap: 8px;
  1743. text-align: left;
  1744. padding: 7px 10px;
  1745. border: 1px solid var(--line-dark);
  1746. border-radius: 8px;
  1747. background: #fff;
  1748. font-size: 13px;
  1749. color: var(--ink);
  1750. }
  1751. .dd-btn .dd-arrow {
  1752. color: var(--ink-faint);
  1753. flex: none;
  1754. }
  1755. .dd-btn:focus {
  1756. border-color: var(--blue);
  1757. }
  1758. .dd-panel {
  1759. position: absolute;
  1760. left: 0;
  1761. right: 0;
  1762. top: calc(100% + 4px);
  1763. z-index: 10;
  1764. background: #fff;
  1765. border: 1px solid var(--line-dark);
  1766. border-radius: 10px;
  1767. box-shadow: var(--shadow-lg);
  1768. padding: 6px;
  1769. max-height: 220px;
  1770. overflow: auto;
  1771. }
  1772. .modal label.dd-opt {
  1773. display: flex;
  1774. flex-direction: row;
  1775. align-items: center;
  1776. gap: 8px;
  1777. padding: 7px 9px;
  1778. border-radius: 6px;
  1779. font-size: 13px;
  1780. color: var(--ink);
  1781. cursor: pointer;
  1782. }
  1783. .dd-opt:hover {
  1784. background: #f4f3ee;
  1785. }
  1786. .dd-opt input {
  1787. accent-color: var(--blue);
  1788. margin: 0;
  1789. cursor: pointer;
  1790. }
  1791. .dd-opt.sel {
  1792. background: var(--blue-bg);
  1793. font-weight: 500;
  1794. }
  1795. /* 聚类库占位 */
  1796. .cluster-empty {
  1797. display: grid;
  1798. place-items: center;
  1799. min-height: 60vh;
  1800. }
  1801. .cluster-empty .inner {
  1802. text-align: center;
  1803. color: var(--ink-faint);
  1804. }
  1805. .cluster-empty .stamp {
  1806. width: 120px;
  1807. height: 120px;
  1808. margin: 0 auto 18px;
  1809. border: 3px solid var(--line-dark);
  1810. border-radius: 50%;
  1811. display: grid;
  1812. place-items: center;
  1813. font-family: "Noto Serif SC", serif;
  1814. font-size: 30px;
  1815. font-weight: 900;
  1816. color: var(--line-dark);
  1817. transform: rotate(-8deg);
  1818. letter-spacing: 4px;
  1819. }
  1820. [hidden] {
  1821. display: none !important;
  1822. }
  1823. /* ── 页内提示(替代浏览器原生 alert) ── */
  1824. #toast-wrap {
  1825. position: fixed;
  1826. top: 18px;
  1827. left: 50%;
  1828. transform: translateX(-50%);
  1829. z-index: 120;
  1830. display: flex;
  1831. flex-direction: column;
  1832. align-items: center;
  1833. gap: 10px;
  1834. pointer-events: none;
  1835. }
  1836. .toast {
  1837. pointer-events: auto;
  1838. display: flex;
  1839. align-items: flex-start;
  1840. gap: 10px;
  1841. min-width: 240px;
  1842. max-width: min(440px, calc(100vw - 32px));
  1843. padding: 12px 14px 12px 13px;
  1844. background: var(--card);
  1845. color: var(--ink);
  1846. border: 1px solid var(--line-dark);
  1847. border-left: 4px solid var(--navy);
  1848. border-radius: 10px;
  1849. box-shadow: var(--shadow-lg);
  1850. font-size: 13px;
  1851. line-height: 1.55;
  1852. animation: toastIn 0.18s ease;
  1853. }
  1854. .toast.out {
  1855. animation: toastOut 0.16s ease forwards;
  1856. }
  1857. .toast .ic {
  1858. flex: none;
  1859. width: 18px;
  1860. height: 18px;
  1861. margin-top: 1px;
  1862. display: grid;
  1863. place-items: center;
  1864. border-radius: 50%;
  1865. font-size: 12px;
  1866. font-weight: 900;
  1867. color: #fff;
  1868. background: var(--navy);
  1869. }
  1870. .toast .msg {
  1871. flex: 1;
  1872. word-break: break-word;
  1873. }
  1874. .toast.error {
  1875. border-left-color: var(--seal);
  1876. }
  1877. .toast.error .ic {
  1878. background: var(--seal);
  1879. }
  1880. .toast.success {
  1881. border-left-color: var(--green);
  1882. }
  1883. .toast.success .ic {
  1884. background: var(--green);
  1885. }
  1886. .toast.warn {
  1887. border-left-color: var(--amber);
  1888. }
  1889. .toast.warn .ic {
  1890. background: var(--amber);
  1891. }
  1892. @keyframes toastIn {
  1893. from {
  1894. opacity: 0;
  1895. transform: translateY(-10px);
  1896. }
  1897. to {
  1898. opacity: 1;
  1899. transform: none;
  1900. }
  1901. }
  1902. @keyframes toastOut {
  1903. to {
  1904. opacity: 0;
  1905. transform: translateY(-8px);
  1906. }
  1907. }
  1908. </style>
  1909. </head>
  1910. <body>
  1911. <div id="toast-wrap" aria-live="polite"></div>
  1912. <header>
  1913. <div class="logo">
  1914. <div class="seal">解</div>
  1915. <div><b>mode_workflow</b><small>解构工作台 · MODE WORKBENCH</small></div>
  1916. </div>
  1917. <nav id="nav">
  1918. <a
  1919. href="#dashboard"
  1920. data-tab="dashboard"
  1921. >Dashboard</a
  1922. >
  1923. <a
  1924. href="#dataset"
  1925. data-tab="dataset"
  1926. >Dataset</a
  1927. >
  1928. <a
  1929. href="#cluster"
  1930. data-tab="cluster"
  1931. >知识库</a
  1932. >
  1933. </nav>
  1934. <div class="spacer"></div>
  1935. <div class="hint">SEARCH · EXTRACT · ARCHIVE</div>
  1936. </header>
  1937. <main id="view-dashboard"></main>
  1938. <main id="view-dataset">
  1939. <div class="ds-top">
  1940. <div class="mode-switch">
  1941. <button
  1942. id="m-process"
  1943. class="on"
  1944. >
  1945. 工序
  1946. </button>
  1947. <button id="m-tools">工具</button>
  1948. </div>
  1949. <div style="flex: 1"></div>
  1950. <button
  1951. class="btn seal"
  1952. id="btn-new-search"
  1953. >
  1954. + 新建搜索
  1955. </button>
  1956. </div>
  1957. <div class="ds-grid">
  1958. <div class="card">
  1959. <div class="col-head">
  1960. QUERY
  1961. <span
  1962. class="n"
  1963. id="q-count"
  1964. ></span>
  1965. </div>
  1966. <div
  1967. class="qlist"
  1968. id="query-list"
  1969. >
  1970. <div class="empty">暂无 query</div>
  1971. </div>
  1972. </div>
  1973. <div class="card">
  1974. <div class="col-head">
  1975. 帖子
  1976. <span style="display: flex; gap: 8px; align-items: center">
  1977. <span
  1978. class="n"
  1979. id="p-count"
  1980. ></span>
  1981. <button
  1982. class="btn sm"
  1983. id="btn-batch"
  1984. disabled
  1985. hidden
  1986. >
  1987. 批量解构
  1988. </button>
  1989. </span>
  1990. </div>
  1991. <div
  1992. class="plat-tabs"
  1993. id="plat-tabs"
  1994. hidden
  1995. ></div>
  1996. <div
  1997. class="plist"
  1998. id="post-list"
  1999. >
  2000. <div class="empty"><span class="glyph">←</span>先选择左侧 query</div>
  2001. </div>
  2002. </div>
  2003. <div class="card xp">
  2004. <div
  2005. class="xp-head"
  2006. id="xp-head"
  2007. >
  2008. <span class="st">解构结果</span>
  2009. </div>
  2010. <div
  2011. class="xp-body"
  2012. id="xp-body"
  2013. >
  2014. <div class="empty"><span class="glyph">←</span>选择一个帖子查看解构结果</div>
  2015. </div>
  2016. </div>
  2017. </div>
  2018. </main>
  2019. <main id="view-cluster">
  2020. <iframe
  2021. id="cluster-frame"
  2022. title="知识检索"
  2023. loading="lazy"
  2024. ></iframe>
  2025. </main>
  2026. <div
  2027. id="task-panel"
  2028. hidden
  2029. >
  2030. <header>
  2031. <span
  2032. class="dot"
  2033. id="task-dot"
  2034. ></span
  2035. ><span id="task-title">任务</span> <button onclick="hideTask()">✕</button>
  2036. </header>
  2037. <div id="task-log"></div>
  2038. </div>
  2039. <!-- 帖子详情弹层(评分详情参考 fixed_query_eval) -->
  2040. <dialog id="post-dialog">
  2041. <div class="pd-wrap">
  2042. <div class="pd-head">
  2043. <div style="min-width: 0">
  2044. <div
  2045. class="pd-meta"
  2046. id="pd-meta"
  2047. ></div>
  2048. <h3 id="pd-title"></h3>
  2049. </div>
  2050. <button
  2051. class="pd-close"
  2052. onclick="document.getElementById('post-dialog').close()"
  2053. >
  2054. </button>
  2055. </div>
  2056. <div class="pd-body">
  2057. <section>
  2058. <div id="pd-verdict"></div>
  2059. <div class="pd-sec-title">抓取文本节选</div>
  2060. <div
  2061. class="pd-raw"
  2062. id="pd-text"
  2063. ></div>
  2064. <div class="pd-sec-title">图片预览</div>
  2065. <div
  2066. class="pd-images"
  2067. id="pd-images"
  2068. ></div>
  2069. <div
  2070. class="pd-tags"
  2071. id="pd-tags"
  2072. ></div>
  2073. </section>
  2074. <aside>
  2075. <div class="pd-score-head">
  2076. <span class="t">评分详情</span>
  2077. <span class="pd-overall">综合评分 <b id="pd-overall">—</b></span>
  2078. </div>
  2079. <div id="pd-scores"></div>
  2080. </aside>
  2081. </div>
  2082. </div>
  2083. </dialog>
  2084. <!-- 图片预览灯箱(支持左右切换) -->
  2085. <dialog
  2086. class="lightbox"
  2087. id="lightbox"
  2088. onclick="if (event.target === this) closeLightbox();"
  2089. >
  2090. <button
  2091. class="lb-close"
  2092. onclick="closeLightbox()"
  2093. title="关闭 (Esc)"
  2094. >
  2095. </button>
  2096. <button
  2097. class="lb-nav lb-prev"
  2098. onclick="lbStep(-1)"
  2099. title="上一张 (←)"
  2100. >
  2101. </button>
  2102. <figure class="lb-stage">
  2103. <img
  2104. id="lb-img"
  2105. src=""
  2106. alt=""
  2107. />
  2108. <figcaption id="lb-count"></figcaption>
  2109. </figure>
  2110. <button
  2111. class="lb-nav lb-next"
  2112. onclick="lbStep(1)"
  2113. title="下一张 (→)"
  2114. >
  2115. </button>
  2116. </dialog>
  2117. <div
  2118. class="modal-bg"
  2119. id="search-modal"
  2120. hidden
  2121. >
  2122. <div class="modal">
  2123. <h2>新建搜索</h2>
  2124. <div class="mb">
  2125. <label
  2126. >Query(评估锚点,必填)<input
  2127. type="text"
  2128. id="s-query"
  2129. placeholder="如:AI 人像 图片 生成 怎么做"
  2130. /></label>
  2131. <label
  2132. >解构方向<select id="s-mode">
  2133. <option value="工序">工序</option>
  2134. <option value="工具">工具</option>
  2135. </select></label
  2136. >
  2137. <label
  2138. >同义措辞(可选,逗号分隔)<input
  2139. type="text"
  2140. id="s-syn"
  2141. placeholder="如:AI 人像生成 教程,AI 写真 怎么做"
  2142. /></label>
  2143. <label
  2144. >检索渠道(下拉多选)
  2145. <div
  2146. class="dd"
  2147. id="s-plat-dd"
  2148. >
  2149. <button
  2150. type="button"
  2151. class="dd-btn"
  2152. id="s-plat-btn"
  2153. >
  2154. 选择渠道 ▾
  2155. </button>
  2156. <div
  2157. class="dd-panel"
  2158. id="s-plat-panel"
  2159. hidden
  2160. ></div>
  2161. </div>
  2162. </label>
  2163. <label
  2164. >每措辞每渠道上限<input
  2165. type="number"
  2166. id="s-max"
  2167. value="10"
  2168. min="1"
  2169. max="50"
  2170. /></label>
  2171. </div>
  2172. <div class="mf">
  2173. <button
  2174. class="btn"
  2175. onclick="document.getElementById('search-modal').hidden = true"
  2176. >
  2177. 取消
  2178. </button>
  2179. <button
  2180. class="btn primary"
  2181. id="s-go"
  2182. >
  2183. 开始搜索
  2184. </button>
  2185. </div>
  2186. </div>
  2187. </div>
  2188. <script>
  2189. /* ════ 基础 ════ */
  2190. const $ = (s) => document.querySelector(s);
  2191. /* 页内提示,替代浏览器原生 alert();type: info|error|success|warn */
  2192. function toast(msg, type = "info", ms = 3200) {
  2193. const wrap = $("#toast-wrap");
  2194. if (!wrap) return;
  2195. const ic = { info: "i", error: "!", success: "✓", warn: "!" }[type] || "i";
  2196. const el = document.createElement("div");
  2197. el.className = "toast " + type;
  2198. el.innerHTML = `<span class="ic">${ic}</span><span class="msg">${esc(msg)}</span>`;
  2199. const dismiss = () => {
  2200. el.classList.add("out");
  2201. el.addEventListener("animationend", () => el.remove(), { once: true });
  2202. };
  2203. el.addEventListener("click", dismiss);
  2204. wrap.appendChild(el);
  2205. setTimeout(dismiss, ms);
  2206. }
  2207. const api = (p, opt) =>
  2208. fetch(p, opt).then(async (r) => {
  2209. if (!r.ok)
  2210. throw Object.assign(new Error("api"), { status: r.status, body: await r.json().catch(() => ({})) });
  2211. return r.json();
  2212. });
  2213. const esc = (s) =>
  2214. String(s ?? "").replace(
  2215. /[&<>"']/g,
  2216. (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[c],
  2217. );
  2218. /* 外链图片走本服务同源反代,绕过公众号(mmbiz.qpic.cn)等防盗链 */
  2219. const imgProxy = (u) => (/^https?:\/\//.test(u || "") ? "/api/img?u=" + encodeURIComponent(u) : u || "");
  2220. const state = {
  2221. tab: "dashboard",
  2222. mode: "process",
  2223. queryId: null,
  2224. caseId: null,
  2225. post: null,
  2226. version: null,
  2227. platFilter: "all",
  2228. doneFilter: true,
  2229. selected: new Set(),
  2230. queries: [],
  2231. posts: [],
  2232. };
  2233. const PLAT_CLS = (p) =>
  2234. ({ xhs: "xhs", gzh: "gzh", zhihu: "zhihu", douyin: "douyin", sph: "sph", youtube: "youtube", x: "x" })[p] ||
  2235. "other";
  2236. const PLAT_NAME = (p) =>
  2237. ({ xhs: "小红书", gzh: "公众号", zhihu: "知乎", douyin: "抖音", sph: "视频号", youtube: "YouTube", x: "X" })[
  2238. p
  2239. ] ||
  2240. p ||
  2241. "?";
  2242. /* 渠道 logo 徽标(品牌色圆角方块,hover 显示渠道名) */
  2243. const PLAT_LOGO = (p, size = 18) => {
  2244. const glyph = (bg, ch) => `<svg width="${size}" height="${size}" viewBox="0 0 24 24">
  2245. <rect width="24" height="24" rx="5.5" fill="${bg}"/>
  2246. <text x="12" y="16.6" font-size="12" font-weight="700" fill="#fff" text-anchor="middle"
  2247. font-family="'Noto Sans SC',sans-serif">${ch}</text></svg>`;
  2248. const svgs = {
  2249. xhs: glyph("#ff2442", "红"),
  2250. zhihu: glyph("#0084ff", "知"),
  2251. gzh: glyph("#07c160", "公"),
  2252. douyin: glyph("#161823", "抖"),
  2253. sph: glyph("#fa6d20", "视"),
  2254. x: glyph("#15202b", "X"),
  2255. youtube: `<svg width="${size}" height="${size}" viewBox="0 0 24 24">
  2256. <rect width="24" height="24" rx="5.5" fill="#f00"/>
  2257. <polygon points="9.8,7.8 17,12 9.8,16.2" fill="#fff"/></svg>`,
  2258. };
  2259. return svgs[p]
  2260. ? `<span class="plat-logo" title="${PLAT_NAME(p)}">${svgs[p]}</span>`
  2261. : `<span class="plat other">${esc(PLAT_NAME(p))}</span>`;
  2262. };
  2263. const MODELS_PROC = ["anthropic/claude-sonnet-4-6", "google/gemini-3.1-flash-lite"];
  2264. const MODELS_TOOL = ["google/gemini-3.1-flash-lite", "anthropic/claude-sonnet-4-6"];
  2265. const scoreCls = (v) => (v == null ? "s0" : v >= 9 ? "s9" : v >= 8 ? "s8" : v >= 6 ? "s6" : "s0");
  2266. /* ════ 路由 ════ */
  2267. function route() {
  2268. state.tab = (location.hash || "#dashboard").slice(1);
  2269. if (!["dashboard", "dataset", "cluster"].includes(state.tab)) state.tab = "dashboard";
  2270. document.querySelectorAll("nav a").forEach((a) => a.classList.toggle("on", a.dataset.tab === state.tab));
  2271. document.querySelectorAll("main").forEach((m) => m.classList.toggle("on", m.id === "view-" + state.tab));
  2272. if (state.tab === "dashboard") renderDashboard();
  2273. if (state.tab === "dataset" && !state.queries.length) loadQueries();
  2274. if (state.tab === "cluster") {
  2275. // 首次打开聚类库才加载内嵌检索页
  2276. const f = $("#cluster-frame");
  2277. if (f && !f.src) f.src = "/search.html";
  2278. }
  2279. }
  2280. window.addEventListener("hashchange", route);
  2281. /* ════ Dashboard ════ */
  2282. let chartRefs = [];
  2283. async function renderDashboard() {
  2284. const v = $("#view-dashboard");
  2285. let d;
  2286. try {
  2287. d = await api("/api/dashboard");
  2288. } catch (e) {
  2289. v.innerHTML = `<div class="card empty"><span class="glyph">!</span>Dashboard 加载失败:${esc(e.body?.error || e.status)}</div>`;
  2290. return;
  2291. }
  2292. const r = d.result,
  2293. p = d.process_data;
  2294. // 进度百分比向下取整:200/201=99.5% 显示 99%,未真正做完不会显示 100%
  2295. const pct = (a, b) => (b ? Math.floor((a / b) * 100) : 0);
  2296. const platBreak = (arr) => (arr || []).map(([k, n]) => `${PLAT_NAME(k)} ${n}`).join(" · ") || "—";
  2297. v.innerHTML = `
  2298. <div class="dash-section"><h2>结果数据</h2><div class="rule"></div><span class="tag">RESULTS</span></div>
  2299. <div class="cards">
  2300. <div class="card stat"><div class="lbl">采集帖子数量</div><div class="val num">${r.post_count}</div><div class="sub">${platBreak(r.collected_by_platform)}</div></div>
  2301. <div class="card stat t"><div class="lbl">解构帖子数量</div><div class="val num">${r.extracted_post_count}</div><div class="sub">${platBreak(r.extracted_by_platform)}</div></div>
  2302. <div class="card stat a"><div class="lbl">工具数量</div><div class="val num">${r.tool_count}</div><div class="sub">mode_tools 去重工具名</div></div>
  2303. <div class="card stat r"><div class="lbl">内容树覆盖节点</div><div class="val num">0</div>
  2304. <div class="sub">0%</div></div>
  2305. <div class="card stat"><div class="lbl">实质数量</div><div class="val num">${r.substance_count}</div><div class="sub">去重实质条目数</div></div>
  2306. <div class="card stat"><div class="lbl">形式数量</div><div class="val num">${r.form_count}</div><div class="sub">去重形式条目数</div></div>
  2307. </div>
  2308. <div class="dash-section"><h2>过程数据</h2><div class="rule"></div><span class="tag">PROCESS</span></div>
  2309. <div class="cards">
  2310. <div class="card stat a"><div class="lbl">解构成本</div><div class="val num">$${p.total_cost}</div><div class="sub">单条均值 $${p.avg_cost} · 共 ${p.run_count} 次</div></div>
  2311. <div class="card stat a"><div class="lbl">解构耗时</div><div class="val num">${(p.total_duration / 3600).toFixed(1)}<span style="font-size:14px">h</span></div><div class="sub">平均 ${p.avg_duration}s / 次</div></div>
  2312. <div class="card stat t"><div class="ring-row"><div class="ring" style="--p:${pct(p.process_progress.done, p.process_progress.total)}"><div>${pct(p.process_progress.done, p.process_progress.total)}%</div></div>
  2313. <div><div class="lbl">工序进度</div><div class="num" style="font-weight:700">${p.process_progress.done} / ${p.process_progress.total}</div><div class="sub">已解构 / 需解构</div></div></div></div>
  2314. <div class="card stat t"><div class="ring-row"><div class="ring" style="--p:${pct(p.tools_progress.done, p.tools_progress.total)}"><div>${pct(p.tools_progress.done, p.tools_progress.total)}%</div></div>
  2315. <div><div class="lbl">工具进度</div><div class="num" style="font-weight:700">${p.tools_progress.done} / ${p.tools_progress.total}</div><div class="sub">已解构 / 需解构</div></div></div></div>
  2316. </div>
  2317. <div class="charts">
  2318. <div class="card chart-card span6"><h3>工序提及工具 TOP10</h3><div class="chart" id="ch-via" style="height:300px"></div></div>
  2319. <div class="card chart-card span6"><h3>解构成本趋势</h3><div class="chart" id="ch-cost" style="height:300px"></div></div>
  2320. <div class="card chart-card span6"><h3>实质覆盖分布 <span class="num">${r.substance_count}</span></h3><div class="chart" id="ch-sub" style="height:320px"></div></div>
  2321. <div class="card chart-card span6"><h3>形式覆盖分布 <span class="num">${r.form_count}</span></h3><div class="chart" id="ch-form" style="height:320px"></div></div>
  2322. <div class="card chart-card span12"><h3>内容树覆盖热力图 <span class="num">${r.matrix_covered}/${r.matrix_valid}</span><span style="font-weight:400;color:var(--ink-faint)">· 27 动作 × 50 类型</span></h3><div class="chart" id="ch-matrix" style="height:560px"></div></div>
  2323. </div>`;
  2324. chartRefs.forEach((c) => c.dispose());
  2325. chartRefs = [];
  2326. const mk = (id, opt) => {
  2327. const c = echarts.init($(id));
  2328. c.setOption(opt);
  2329. chartRefs.push(c);
  2330. return c;
  2331. };
  2332. const ink = "#1c2433",
  2333. faint = "#9aa3b0",
  2334. grid = { left: 8, right: 16, top: 8, bottom: 8, containLabel: true };
  2335. /* 热力图 */
  2336. mk("#ch-matrix", {
  2337. tooltip: { formatter: (pr) => `${r.matrix_actions[pr.value[1]]} × ${r.matrix_types[pr.value[0]]}` },
  2338. grid: { left: 8, right: 16, top: 8, bottom: 60, containLabel: true },
  2339. xAxis: {
  2340. type: "category",
  2341. data: r.matrix_types,
  2342. axisLabel: { rotate: 60, fontSize: 9, color: faint },
  2343. splitArea: { show: true, areaStyle: { color: ["#fcfcf9", "#f5f4ef"] } },
  2344. },
  2345. yAxis: {
  2346. type: "category",
  2347. data: r.matrix_actions,
  2348. axisLabel: { fontSize: 10, color: ink },
  2349. splitArea: { show: true },
  2350. },
  2351. visualMap: { show: false, min: 0, max: 1, inRange: { color: ["#f0efe8", "#bb3a22"] } },
  2352. series: [
  2353. {
  2354. type: "heatmap",
  2355. data: r.matrix_cells.map(([a, t]) => [t, a, 1]),
  2356. itemStyle: { borderColor: "#fff", borderWidth: 1 },
  2357. },
  2358. ],
  2359. });
  2360. const bar = (data, color) => ({
  2361. tooltip: {},
  2362. grid,
  2363. xAxis: { type: "value", axisLabel: { color: faint } },
  2364. yAxis: {
  2365. type: "category",
  2366. data: data.map((x) => x[0]).reverse(),
  2367. axisLabel: { color: ink, fontSize: 11, width: 130, overflow: "truncate" },
  2368. },
  2369. series: [
  2370. {
  2371. type: "bar",
  2372. data: data.map((x) => x[1]).reverse(),
  2373. itemStyle: { color, borderRadius: [0, 3, 3, 0] },
  2374. barMaxWidth: 16,
  2375. label: { show: true, position: "right", color: faint, fontSize: 10 },
  2376. },
  2377. ],
  2378. });
  2379. mk("#ch-via", r.via_top10.length ? bar(r.via_top10, "#1e3a5f") : emptyOpt());
  2380. mk("#ch-sub", r.substance_top.length ? bar(r.substance_top, "#b45309") : emptyOpt());
  2381. mk("#ch-form", r.form_top.length ? bar(r.form_top, "#0f6b5c") : emptyOpt());
  2382. mk(
  2383. "#ch-cost",
  2384. p.cost_trend.length
  2385. ? {
  2386. tooltip: { trigger: "axis" },
  2387. grid,
  2388. xAxis: { type: "category", data: p.cost_trend.map((x) => x.date), axisLabel: { color: faint } },
  2389. yAxis: { type: "value", axisLabel: { color: faint, formatter: "${value}" } },
  2390. series: [
  2391. {
  2392. type: "line",
  2393. data: p.cost_trend.map((x) => x.cost),
  2394. smooth: true,
  2395. symbolSize: 7,
  2396. lineStyle: { color: "#bb3a22", width: 2.5 },
  2397. itemStyle: { color: "#bb3a22" },
  2398. areaStyle: { color: "rgba(187,58,34,.08)" },
  2399. },
  2400. ],
  2401. }
  2402. : emptyOpt(),
  2403. );
  2404. function emptyOpt() {
  2405. return {
  2406. title: {
  2407. text: "暂无数据",
  2408. left: "center",
  2409. top: "middle",
  2410. textStyle: { color: faint, fontSize: 12, fontWeight: 400 },
  2411. },
  2412. xAxis: { show: false },
  2413. yAxis: { show: false },
  2414. };
  2415. }
  2416. }
  2417. /* ════ Dataset:query 列表 ════ */
  2418. async function loadQueries() {
  2419. /* 工序/工具各自一张搜索表,query 列表按当前子模式拉取 */
  2420. try {
  2421. state.queries = await api("/api/queries?mode=" + state.mode);
  2422. } catch (e) {
  2423. state.queries = [];
  2424. }
  2425. renderQueries();
  2426. /* 进入/切换子模式时默认选中第一个 query(进而联动第一帖与解构结果) */
  2427. if (!state.queryId && state.queries.length) await selectQuery(state.queries[0].query_id);
  2428. }
  2429. function renderQueries() {
  2430. const list = state.queries;
  2431. $("#q-count").textContent = list.length ? list.length + " 组" : "";
  2432. if (!list.length) {
  2433. $("#query-list").innerHTML = '<div class="empty">暂无 query<br>点右上「新建搜索」开始</div>';
  2434. return;
  2435. }
  2436. $("#query-list").innerHTML = list
  2437. .map((q) => {
  2438. const done = state.mode === "process" ? q.process_done : q.tools_done;
  2439. return `<div class="qitem ${q.query_id === state.queryId ? "on" : ""}" onclick="selectQuery('${q.query_id}')">
  2440. <div class="qid">${q.query_id}</div>
  2441. <div class="qt">${esc(q.query_text || "(未命名)")}</div>
  2442. <div class="qm">
  2443. <span>采纳/命中 <b class="num hit">${q.hit_count ?? 0}</b></span>
  2444. <span>总帖数 <b class="num">${q.post_count}</b></span>
  2445. <span>已解构 <b class="num">${done}</b></span>
  2446. </div>
  2447. </div>`;
  2448. })
  2449. .join("");
  2450. }
  2451. async function selectQuery(qid) {
  2452. state.queryId = qid;
  2453. state.caseId = null;
  2454. state.post = null;
  2455. state.platFilter = "all";
  2456. state.selected.clear();
  2457. renderQueries();
  2458. renderExtractEmpty();
  2459. $("#post-list").innerHTML = '<div class="empty">加载中…</div>';
  2460. try {
  2461. state.posts = await api("/api/posts?mode=" + state.mode + "&query_id=" + encodeURIComponent(qid));
  2462. } catch (e) {
  2463. state.posts = [];
  2464. }
  2465. renderPosts();
  2466. /* 默认选中「可见列表」第一帖(已解构筛选下即第一个已解构帖),无可见帖则退回全部第一帖 */
  2467. if (state.posts.length) {
  2468. const vis = visiblePosts();
  2469. await selectPost((vis[0] || state.posts[0]).case_id);
  2470. }
  2471. }
  2472. /* ════ Dataset:帖子列表(按渠道分 tab)════ */
  2473. function setPlatFilter(p) {
  2474. state.platFilter = p;
  2475. renderPosts();
  2476. }
  2477. function toggleDoneFilter() {
  2478. state.doneFilter = !state.doneFilter;
  2479. renderPosts();
  2480. renderPostsAutoSelect();
  2481. }
  2482. /* 当前可见帖(渠道 + 已解构筛选后),供列表渲染与「默认选中」共用 */
  2483. function visiblePosts() {
  2484. const isDone = (p) => (state.mode === "process" ? p.has_process : p.has_tools);
  2485. let list =
  2486. state.platFilter === "all"
  2487. ? state.posts
  2488. : state.posts.filter((p) => (p.platform || "other") === state.platFilter);
  2489. if (state.doneFilter) list = list.filter(isDone);
  2490. return list;
  2491. }
  2492. /* 切换筛选后,若当前选中帖已被筛掉,则改选可见列表的第一帖 */
  2493. async function renderPostsAutoSelect() {
  2494. const vis = visiblePosts();
  2495. if (vis.length && !vis.some((p) => p.case_id === state.caseId)) await selectPost(vis[0].case_id);
  2496. }
  2497. function renderPosts() {
  2498. const all = state.posts;
  2499. updateBatchBtn();
  2500. /* 渠道 tab + 已解构筛选 */
  2501. const counts = {};
  2502. all.forEach((p) => {
  2503. const k = p.platform || "other";
  2504. counts[k] = (counts[k] || 0) + 1;
  2505. });
  2506. const plats = Object.keys(counts);
  2507. if (state.platFilter !== "all" && !counts[state.platFilter]) state.platFilter = "all";
  2508. const isDone = (p) => (state.mode === "process" ? p.has_process : p.has_tools);
  2509. const platScoped =
  2510. state.platFilter === "all" ? all : all.filter((p) => (p.platform || "other") === state.platFilter);
  2511. const doneN = platScoped.filter(isDone).length;
  2512. const tabs = $("#plat-tabs");
  2513. if (all.length) {
  2514. tabs.hidden = false;
  2515. const btns =
  2516. plats.length > 1
  2517. ? [
  2518. `<button class="${state.platFilter === "all" ? "on" : ""}" onclick="setPlatFilter('all')">全部<span class="c">${all.length}</span></button>`,
  2519. ].concat(
  2520. plats.map(
  2521. (k) =>
  2522. `<button class="${state.platFilter === k ? "on" : ""}" onclick="setPlatFilter('${esc(k)}')">${PLAT_NAME(k)}<span class="c">${counts[k]}</span></button>`,
  2523. ),
  2524. )
  2525. : [];
  2526. btns.push(`<button class="done-filter ${state.doneFilter ? "on" : ""}" onclick="toggleDoneFilter()"
  2527. title="${state.doneFilter ? "当前只看已解构,点击显示全部" : "点击只看已解构"}"><span class="dot">●</span>已解构<span class="c">${doneN}</span></button>`);
  2528. tabs.innerHTML = btns.join("");
  2529. } else {
  2530. tabs.hidden = true;
  2531. }
  2532. const list = visiblePosts();
  2533. $("#p-count").textContent = all.length
  2534. ? state.platFilter === "all" && !state.doneFilter
  2535. ? `${all.length} 帖`
  2536. : `${list.length} / ${all.length} 帖`
  2537. : "";
  2538. if (!all.length) {
  2539. $("#post-list").innerHTML = '<div class="empty">该 query 暂无帖子</div>';
  2540. return;
  2541. }
  2542. if (!list.length) {
  2543. $("#post-list").innerHTML =
  2544. `<div class="empty">${state.doneFilter ? "该筛选下暂无已解构帖子" : "该渠道暂无帖子"}</div>`;
  2545. return;
  2546. }
  2547. $("#post-list").innerHTML = list
  2548. .map((p) => {
  2549. const done = state.mode === "process" ? p.has_process : p.has_tools;
  2550. const kt = (p.knowledge_type || []).map((k) => `<span class="pill">${esc(k)}</span>`).join("");
  2551. const sb =
  2552. p.overall_score != null
  2553. ? `<span class="score-badge ${scoreCls(p.overall_score)} num"
  2554. onclick="event.stopPropagation();openPostDetail('${esc(p.case_id)}')">${p.overall_score}</span>`
  2555. : "";
  2556. const thumbSrc = (p.images || []).filter(Boolean)[0];
  2557. const thumb = thumbSrc
  2558. ? `<img class="thumb" src="${esc(imgProxy(thumbSrc))}" loading="lazy"
  2559. onerror="this.outerHTML='<div class=\\'thumb-ph\\'>🖼️</div>'">`
  2560. : `<div class="thumb-ph" title="暂无图片">🖼️</div>`;
  2561. return `<div class="post ${p.case_id === state.caseId ? "on" : ""}" onclick="selectPost('${esc(p.case_id)}')">
  2562. ${thumb}
  2563. <div style="flex:1;min-width:0">
  2564. <div class="pt">${esc(p.title || "(无标题)")}</div>
  2565. <div class="pm">
  2566. ${PLAT_LOGO(p.platform)}
  2567. ${p.adopted ? '<span class="pill green">采纳</span>' : ""}
  2568. ${kt}
  2569. ${done ? '<span class="done-dot">● 已解构</span>' : ""}
  2570. </div>
  2571. </div>
  2572. ${sb}
  2573. </div>`;
  2574. })
  2575. .join("");
  2576. }
  2577. function toggleSel(cid, on) {
  2578. on ? state.selected.add(cid) : state.selected.delete(cid);
  2579. updateBatchBtn();
  2580. }
  2581. function updateBatchBtn() {
  2582. const b = $("#btn-batch");
  2583. b.disabled = !state.selected.size;
  2584. b.textContent = state.selected.size ? `批量解构(${state.selected.size})` : "批量解构";
  2585. }
  2586. $("#btn-batch").onclick = () => state.selected.size && startExtract([...state.selected]);
  2587. /* ════ 帖子详情弹层 ════ */
  2588. /* 得分可能是字符串("1")或数字(10),统一解析;非数值返回 null */
  2589. const scoreNum = (v) => {
  2590. const n = typeof v === "number" || (typeof v === "string" && v.trim() !== "") ? Number(v) : NaN;
  2591. return Number.isFinite(n) ? n : null;
  2592. };
  2593. function collectScores(node) {
  2594. let out = [];
  2595. if (Array.isArray(node)) node.forEach((v) => (out = out.concat(collectScores(v))));
  2596. else if (node && typeof node === "object") {
  2597. for (const [k, v] of Object.entries(node)) {
  2598. if (k === "得分") {
  2599. const n = scoreNum(v);
  2600. if (n !== null) out.push(n);
  2601. } else out = out.concat(collectScores(v));
  2602. }
  2603. }
  2604. return out;
  2605. }
  2606. function scRow(label, v, reason) {
  2607. const n = scoreNum(v);
  2608. const has = n !== null;
  2609. return `<div class="sc-row">
  2610. <span style="color:${has ? "inherit" : "var(--ink-faint)"}">${esc(label)}</span>
  2611. <div class="meter"><span style="width:${has ? Math.min(n, 10) * 10 : 0}%"></span></div>
  2612. <b class="num">${has ? n : "—"}</b>
  2613. ${reason ? `<span class="info" data-label="${esc(label)}" data-reason="${esc(reason)}" data-score="${has ? n : ""}" onclick="showScorePop(this)">ⓘ</span>` : "<span></span>"}
  2614. </div>`;
  2615. }
  2616. /* 递归渲染评分;depth>0 的分组标题用二级样式,形成层级 */
  2617. function walkScores(node, depth) {
  2618. depth = depth || 0;
  2619. let html = "";
  2620. for (const [k, v] of Object.entries(node || {})) {
  2621. if (v && typeof v === "object" && !Array.isArray(v) && "得分" in v) {
  2622. html += scRow(k, v["得分"], v["理由"]);
  2623. } else if (scoreNum(v) !== null) {
  2624. html += scRow(k, v);
  2625. } else if (v && typeof v === "object" && !Array.isArray(v)) {
  2626. const inner = walkScores(v, depth + 1);
  2627. if (inner) html += `<div class="sc-sub${depth > 0 ? " lv2" : ""}">${esc(k)}</div>` + inner;
  2628. }
  2629. }
  2630. return html;
  2631. }
  2632. /* ── 质量评分:不跟随原始 JSON 嵌套,改用 mode_procedure 的规范分组与顺序 ──
  2633. 固定维度 → 用例 → 工序 → 能力 → 工具;丢弃「字段完整性」「动态维度」等中间表头 */
  2634. const QUALITY_ORDER = {
  2635. 工序: ["流程完整性", "输入完整性", "实现完整性", "输出完整性", "泛化性"],
  2636. 能力: ["输入完整性", "实现完整性", "输出完整性", "泛化性"],
  2637. 工具: ["能力边界覆盖", "有效比较", "参数/接口具体性", "实操示例", "版本&限制"],
  2638. };
  2639. /* DFS 找到名为 name 的容器节点(工序/能力/工具) */
  2640. function findScoreNode(n, name) {
  2641. if (!n || typeof n !== "object" || Array.isArray(n)) return null;
  2642. if (name in n && n[name] && typeof n[name] === "object" && !Array.isArray(n[name])) return n[name];
  2643. for (const v of Object.values(n)) {
  2644. if (v && typeof v === "object" && !Array.isArray(v)) {
  2645. const r = findScoreNode(v, name);
  2646. if (r) return r;
  2647. }
  2648. }
  2649. return null;
  2650. }
  2651. /* 递归收集子树叶子评分 [name,{得分,理由}],打平中间分组头 */
  2652. function collectLeaves(node) {
  2653. let out = [];
  2654. for (const [k, v] of Object.entries(node || {})) {
  2655. if (v && typeof v === "object" && !Array.isArray(v) && "得分" in v) out.push([k, v]);
  2656. else if (scoreNum(v) !== null) out.push([k, { 得分: v }]);
  2657. else if (v && typeof v === "object" && !Array.isArray(v)) out = out.concat(collectLeaves(v));
  2658. }
  2659. return out;
  2660. }
  2661. function renderQuality(qnode) {
  2662. /* 固定维度/用例 的维度名全局唯一,扁平索引即可取 */
  2663. const flat = {};
  2664. (function collect(n) {
  2665. for (const [k, v] of Object.entries(n || {})) {
  2666. if (v && typeof v === "object" && !Array.isArray(v)) {
  2667. if ("得分" in v) flat[k] = v;
  2668. else collect(v);
  2669. } else if (scoreNum(v) !== null) flat[k] = { 得分: v };
  2670. }
  2671. })(qnode);
  2672. const sub = (t) => `<div class="sc-sub">${esc(t)}</div>`;
  2673. const rows = (pairs) => pairs.map(([n, o]) => scRow(n, o["得分"], o["理由"])).join("");
  2674. const pick = (names) => names.filter((n) => flat[n]).map((n) => [n, flat[n]]);
  2675. let html = "";
  2676. let p = pick(["时效性", "热度性", "评论反馈"]); // ① 固定维度(置顶)
  2677. if (p.length) html += sub("固定维度") + rows(p);
  2678. p = pick(["真实感", "真实感 (非AI)", "真实感(非AI)", "表现力"]); // ② 用例
  2679. if (p.length) html += sub("用例") + rows(p);
  2680. for (const name of ["工序", "能力", "工具"]) {
  2681. // ③ 动态维度(按方向命名,内部规范排序)
  2682. const node = findScoreNode(qnode, name);
  2683. if (!node) continue;
  2684. const leaves = collectLeaves(node);
  2685. if (!leaves.length) continue;
  2686. const order = QUALITY_ORDER[name] || [];
  2687. leaves.sort((a, b) => (order.indexOf(a[0]) + 1 || 99) - (order.indexOf(b[0]) + 1 || 99));
  2688. html += sub(name) + rows(leaves);
  2689. }
  2690. return html || '<span style="color:var(--ink-faint)">无评分</span>';
  2691. }
  2692. /* ── 判定理由弹层:点击 ⓘ 浮现,符合当前页面样式 ── */
  2693. let _scorePop = null;
  2694. function closeScorePop() {
  2695. if (_scorePop) {
  2696. _scorePop.remove();
  2697. _scorePop = null;
  2698. }
  2699. document.removeEventListener("mousedown", _scorePopOutside, true);
  2700. }
  2701. function _scorePopOutside(e) {
  2702. if (_scorePop && !_scorePop.contains(e.target) && !e.target.classList.contains("info")) closeScorePop();
  2703. }
  2704. function showScorePop(el) {
  2705. const reopen = _scorePop && _scorePop._anchor === el;
  2706. closeScorePop();
  2707. if (reopen) return; // 再次点击同一图标 → 收起
  2708. const score = el.dataset.score;
  2709. const pop = document.createElement("div");
  2710. pop.className = "score-pop";
  2711. pop._anchor = el;
  2712. pop.innerHTML = `<div class="sp-head">
  2713. <span class="sp-tag">判定理由</span>
  2714. <span class="sp-name">${esc(el.dataset.label || "")}</span>
  2715. ${score !== "" && score != null ? `<span class="sp-score">${esc(score)}</span>` : ""}
  2716. </div>
  2717. <div class="sp-body">${esc(el.dataset.reason || "")}</div>`;
  2718. // 挂在 dialog 内,确保位于 showModal 顶层之上
  2719. (document.getElementById("post-dialog") || document.body).appendChild(pop);
  2720. _scorePop = pop;
  2721. // 定位:图标下方右对齐;越界则上翻 / 收边
  2722. const r = el.getBoundingClientRect();
  2723. let top = r.bottom + 8,
  2724. left = r.right - pop.offsetWidth;
  2725. if (left < 12) left = 12;
  2726. if (top + pop.offsetHeight > window.innerHeight - 12) top = r.top - pop.offsetHeight - 8;
  2727. if (top < 12) top = 12;
  2728. pop.style.top = top + "px";
  2729. pop.style.left = left + "px";
  2730. setTimeout(() => document.addEventListener("mousedown", _scorePopOutside, true), 0);
  2731. }
  2732. document.getElementById("post-dialog")?.addEventListener("close", closeScorePop);
  2733. /* ── 图片预览灯箱 ── */
  2734. const lb = { imgs: [], i: 0 };
  2735. function openLightbox(i) {
  2736. if (!lb.imgs.length) return;
  2737. lb.i = (i + lb.imgs.length) % lb.imgs.length;
  2738. renderLightbox();
  2739. const d = $("#lightbox");
  2740. if (!d.open) d.showModal();
  2741. }
  2742. function closeLightbox() {
  2743. const d = $("#lightbox");
  2744. if (d.open) d.close();
  2745. }
  2746. function lbStep(d) {
  2747. if (!lb.imgs.length) return;
  2748. lb.i = (lb.i + d + lb.imgs.length) % lb.imgs.length;
  2749. renderLightbox();
  2750. }
  2751. function renderLightbox() {
  2752. $("#lb-img").src = imgProxy(lb.imgs[lb.i]);
  2753. $("#lb-count").textContent = `${lb.i + 1} / ${lb.imgs.length}`;
  2754. const multi = lb.imgs.length > 1;
  2755. document.querySelector(".lb-prev").style.visibility = multi ? "visible" : "hidden";
  2756. document.querySelector(".lb-next").style.visibility = multi ? "visible" : "hidden";
  2757. }
  2758. document.addEventListener("keydown", (e) => {
  2759. if (!$("#lightbox").open) return;
  2760. if (e.key === "ArrowLeft") lbStep(-1);
  2761. else if (e.key === "ArrowRight") lbStep(1);
  2762. // Esc 由 <dialog> 原生处理(触发 close)
  2763. });
  2764. function openPostDetail(cid) {
  2765. const p = state.posts.find((x) => x.case_id === cid);
  2766. if (!p) return;
  2767. const e = p.llm_evaluation || {};
  2768. const meta = [];
  2769. meta.push(`${PLAT_LOGO(p.platform)}<span style="font-weight:600">${esc(PLAT_NAME(p.platform))}</span>`);
  2770. meta.push(p.adopted ? '<span class="pill green">采纳/命中</span>' : '<span class="pill">未采纳</span>');
  2771. if (p.publish_time) meta.push(`<span>${esc(String(p.publish_time).slice(0, 16))}</span>`);
  2772. if (p.like_count != null) meta.push(`<span>👍 ${p.like_count}</span>`);
  2773. if (p.quality_grade) meta.push(`<span>质量 ${esc(p.quality_grade)} ${p.quality_score ?? ""}</span>`);
  2774. if (p.url) meta.push(`<a href="${esc(p.url)}" target="_blank">原文 ↗</a>`);
  2775. $("#pd-meta").innerHTML = meta.join("");
  2776. $("#pd-title").textContent = p.title || "(无标题)";
  2777. const verdict = e["判定理由"] || e["理由"] || "";
  2778. $("#pd-verdict").innerHTML = verdict ? `<div class="pd-verdict">${esc(verdict)}</div>` : "";
  2779. $("#pd-text").textContent = p.body || "(无正文)";
  2780. const imgs = (p.images || []).filter(Boolean);
  2781. $("#pd-images").innerHTML = imgs.length
  2782. ? imgs
  2783. .map(
  2784. (s, i) => `<img src="${esc(imgProxy(s))}" loading="lazy"
  2785. onclick="openLightbox(${i})" onerror="this.style.opacity=.25">`,
  2786. )
  2787. .join("")
  2788. : '<p style="color:var(--ink-faint);font-size:12px">搜索详情未返回图片。</p>';
  2789. lb.imgs = imgs;
  2790. $("#pd-tags").innerHTML = [
  2791. ...(p.knowledge_type || []).map((t) => "类型:" + t),
  2792. ...(p.found_by || []).map((q) => "命中:" + q),
  2793. ]
  2794. .map((t) => `<span class="pill">${esc(t)}</span>`)
  2795. .join("");
  2796. $("#pd-overall").innerHTML =
  2797. p.overall_score != null
  2798. ? `${p.overall_score}<span style="font-size:11px;color:var(--ink-faint);font-weight:500"> /10</span>`
  2799. : "—";
  2800. /* 评分卡:相关性 + 质量(均分 + 各维度,ⓘ hover 看理由) */
  2801. $("#pd-scores").innerHTML =
  2802. [
  2803. ["01", "相关性"],
  2804. ["02", "质量"],
  2805. ]
  2806. .map(([no, key], i) => {
  2807. const node = e[key];
  2808. if (!node) return "";
  2809. const vs = collectScores(node);
  2810. const avg = vs.length ? (vs.reduce((a, b) => a + b, 0) / vs.length).toFixed(1) : "N/A";
  2811. return `<div class="sc-card">
  2812. <div class="sc-card-head">
  2813. <span><span class="badge">${no}</span>${esc(key)}</span>
  2814. <span class="avg">均分 <b>${avg}</b>/10</span>
  2815. </div>
  2816. <div class="sc-card-body">${(key === "质量" ? renderQuality(node) : walkScores(node)) || '<span style="color:var(--ink-faint)">无评分</span>'}</div>
  2817. </div>`;
  2818. })
  2819. .join("") || '<div class="empty">无评估数据</div>';
  2820. $("#post-dialog").showModal();
  2821. }
  2822. /* ════ Dataset:右栏解构结果 ════ */
  2823. function renderExtractEmpty() {
  2824. $("#xp-head").innerHTML = '<span class="st">解构结果</span>';
  2825. $("#xp-body").innerHTML = '<div class="empty"><span class="glyph">←</span>选择一个帖子查看解构结果</div>';
  2826. }
  2827. async function selectPost(cid) {
  2828. state.caseId = cid;
  2829. state.version = null;
  2830. state.post = state.posts.find((p) => p.case_id === cid) || null;
  2831. renderPosts();
  2832. await loadExtract();
  2833. }
  2834. async function loadExtract() {
  2835. if (!state.caseId) return renderExtractEmpty();
  2836. const isProc = state.mode === "process";
  2837. const vURL = `/api/${isProc ? "process" : "tools"}_versions?case_id=` + encodeURIComponent(state.caseId);
  2838. const dURL =
  2839. `/api/${isProc ? "process" : "tools"}?case_id=` +
  2840. encodeURIComponent(state.caseId) +
  2841. (state.version ? "&version=" + encodeURIComponent(state.version) : "");
  2842. let versions = [],
  2843. data = null,
  2844. missing = false;
  2845. try {
  2846. versions = await api(vURL);
  2847. } catch (e) {}
  2848. try {
  2849. data = await api(dURL);
  2850. } catch (e) {
  2851. if (e.status === 404) missing = true;
  2852. else throw e;
  2853. }
  2854. renderExtractHead(versions, data, missing);
  2855. const body = $("#xp-body");
  2856. if (missing || !data) {
  2857. body.innerHTML = `<div class="empty">该帖暂无${isProc ? "工序" : "工具"}解构<br><br>
  2858. <button class="btn primary" onclick="startExtract(['${esc(state.caseId)}'])">开始解构</button></div>`;
  2859. return;
  2860. }
  2861. state.version = data.version;
  2862. syncVersionSelect();
  2863. body.innerHTML = isProc ? renderProcedures(data) : renderTools(data);
  2864. requestAnimationFrame(markSrcTextClamp);
  2865. if (isProc) requestAnimationFrame(markStepClamps);
  2866. else requestAnimationFrame(markClampedCells);
  2867. }
  2868. function renderExtractHead(versions, data, missing) {
  2869. const isProc = state.mode === "process";
  2870. const title = state.post ? esc(state.post.title || state.caseId) : esc(state.caseId || "");
  2871. const opts = versions
  2872. .map(
  2873. (v, i) =>
  2874. `<option value="${esc(v.version)}">${esc(v.version)}${i === 0 ? " (最新)" : ""} · ${v.n}${isProc ? "工序" : "工具"}</option>`,
  2875. )
  2876. .join("");
  2877. const models = (isProc ? MODELS_PROC : MODELS_TOOL).map((m) => `<option>${m}</option>`).join("");
  2878. $("#xp-head").innerHTML = `
  2879. <span class="st">大模型${isProc ? "工序" : "工具"}:<em>${missing ? "未提取" : "已提取"}</em></span>
  2880. <span style="font-size:12px;color:var(--ink-faint);max-width:330px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap" title="${title}">${title}</span>
  2881. <span class="spacer"></span>
  2882. ${versions.length ? `<select id="ver-sel">${opts}</select>` : ""}
  2883. <select id="model-sel" title="解构模型">${models}</select>
  2884. <button class="btn sm primary" onclick="startExtract(['${esc(state.caseId || "")}'])">${missing ? "提取" : "♻ 重新生成"}</button>
  2885. <button class="btn sm" onclick="showTaskPanel()" title="重新打开任务日志面板">📋 操作日志</button>`;
  2886. const vs = $("#ver-sel");
  2887. if (vs)
  2888. vs.onchange = () => {
  2889. state.version = vs.value;
  2890. loadExtract();
  2891. };
  2892. }
  2893. function syncVersionSelect() {
  2894. const vs = $("#ver-sel");
  2895. if (vs && state.version) vs.value = state.version;
  2896. }
  2897. /* ── 原文卡片:标题 + 图片缩略图(横滑、可灯箱预览)+ 正文(定高可展开),整体可收起 ── */
  2898. let srcOpen = true,
  2899. srcTextOpen = false;
  2900. function renderSourceBlock() {
  2901. const p = state.post;
  2902. if (!p || !(p.title || (p.images || []).length || p.body)) return "";
  2903. const imgs = (p.images || []).filter(Boolean);
  2904. const thumbs = imgs.length
  2905. ? `<div class="src-thumbs">${imgs
  2906. .map(
  2907. (s, i) =>
  2908. `<img src="${esc(imgProxy(s))}" loading="lazy" onclick="openSrcLightbox(${i})" onerror="this.style.opacity=.25">`,
  2909. )
  2910. .join("")}</div>`
  2911. : "";
  2912. const body = p.body
  2913. ? `<div class="src-text${srcTextOpen ? "" : " clamp"}" id="src-text">${esc(p.body)}</div>
  2914. <button class="src-text-toggle" id="src-text-toggle" onclick="toggleSrcText()" hidden>${srcTextOpen ? "收起 ▲" : "展开 ▼"}</button>`
  2915. : "";
  2916. const link = p.url
  2917. ? `<a class="src-link" href="${esc(p.url)}" target="_blank" rel="noreferrer" onclick="event.stopPropagation()">原文 ↗</a>`
  2918. : "";
  2919. return `<div class="src-block${srcOpen ? " open" : ""}" id="src-block">
  2920. <div class="src-head" onclick="toggleSrc()">
  2921. <span class="src-caret">▸</span>
  2922. <span class="src-label">原文</span>
  2923. <span class="src-title">${esc(p.title || "(无标题)")}</span>
  2924. ${link}
  2925. </div>
  2926. <div class="src-body">${thumbs}${body}</div>
  2927. </div>`;
  2928. }
  2929. function toggleSrc() {
  2930. srcOpen = !srcOpen;
  2931. const b = $("#src-block");
  2932. if (b) b.classList.toggle("open", srcOpen);
  2933. requestAnimationFrame(markSrcTextClamp);
  2934. }
  2935. function toggleSrcText() {
  2936. srcTextOpen = !srcTextOpen;
  2937. const t = $("#src-text"),
  2938. btn = $("#src-text-toggle");
  2939. if (t) t.classList.toggle("clamp", !srcTextOpen);
  2940. if (btn) btn.textContent = srcTextOpen ? "收起 ▲" : "展开 ▼";
  2941. }
  2942. function openSrcLightbox(i) {
  2943. lb.imgs = ((state.post && state.post.images) || []).filter(Boolean);
  2944. openLightbox(i);
  2945. }
  2946. /* 仅当正文在定高下溢出时才显示「展开」按钮(需在可见、未展开态测量) */
  2947. function markSrcTextClamp() {
  2948. const t = $("#src-text"),
  2949. btn = $("#src-text-toggle");
  2950. if (!t || !btn) return;
  2951. if (srcTextOpen) {
  2952. btn.hidden = false;
  2953. return;
  2954. }
  2955. btn.hidden = !(t.scrollHeight > t.clientHeight + 2);
  2956. }
  2957. /* ── 工序渲染 ── */
  2958. function renderProcedures(data) {
  2959. const src = data.source || {};
  2960. return (
  2961. renderSourceBlock() +
  2962. (data.procedures || [])
  2963. .map((p) => {
  2964. const d = p.declarations || {};
  2965. const ins =
  2966. (d.inputs || [])
  2967. .map(
  2968. (x) =>
  2969. `<span class="pill amber">${esc(x.type || "")}</span> ${x.name ? `<b>${esc(x.name)}</b>` : ""} ${x.desc ? `<span style="color:var(--ink-faint)">— ${esc(x.desc)}</span>` : ""}`,
  2970. )
  2971. .join("<br>") || '<span style="color:var(--ink-faint)">无</span>';
  2972. const ret = d.returns
  2973. ? `<span class="pill teal">${esc(d.returns.type || "")}</span>`
  2974. : '<span style="color:var(--ink-faint)">无</span>';
  2975. return `<div class="proc">
  2976. <div class="proc-head">
  2977. <div class="nm"><span class="pid">工序 ${esc(p.id || "")}</span>${esc(p.name || "")}</div>
  2978. ${p.purpose ? `<div class="pp">#目的:${esc(p.purpose)}</div>` : ""}
  2979. <div class="meta">
  2980. ${p.category ? `<span class="pill red">类别:${esc(p.category)}</span>` : ""}
  2981. ${src.platform ? `<span class="pill">#平台:${esc(src.platform)}</span>` : ""}
  2982. ${src.author ? `<span class="pill">#作者:${esc(src.author)}</span>` : ""}
  2983. <span class="pill">case:${esc(data.case_id)}</span>
  2984. ${(p.tools_used || []).map((t) => `<span class="pill teal">${esc(t)}</span>`).join("")}
  2985. </div>
  2986. </div>
  2987. <div class="decl">
  2988. <div><div class="dl">输入</div><div class="di">${ins}</div></div>
  2989. <div><div class="dl">返回</div><div class="di">${ret}</div></div>
  2990. </div>
  2991. ${renderSteps(p.steps || [])}
  2992. </div>`;
  2993. })
  2994. .join("") || '<div class="empty">本版本无工序</div>'
  2995. );
  2996. }
  2997. function renderSteps(steps) {
  2998. if (!steps.length) return '<div class="empty">无步骤</div>';
  2999. let rows = "";
  3000. for (const s of steps) {
  3001. const ins = s.inputs && s.inputs.length ? s.inputs : [null];
  3002. const outs = s.outputs && s.outputs.length ? s.outputs : [null];
  3003. const n = Math.max(ins.length, outs.length);
  3004. for (let i = 0; i < n; i++) {
  3005. rows += "<tr>";
  3006. if (i === 0) {
  3007. rows += `<td rowspan="${n}" class="sid">${esc(s.id || "")}</td>
  3008. <td rowspan="${n}">${esc(s.directive || s.intent || "")}</td>
  3009. <td rowspan="${n}">${s.effect ? `<span class="pill navy">${esc(s.effect)}</span>` : ""}</td>
  3010. <td rowspan="${n}">${esc(fmtSF(s.substance))}</td>
  3011. <td rowspan="${n}">${esc(fmtSF(s.form))}</td>`;
  3012. }
  3013. rows += ioCell(ins[i], "in");
  3014. if (i === 0) {
  3015. rows += `<td rowspan="${n}">${s.via ? `<span class="pill teal">${esc(s.via)}</span>` : ""}</td>
  3016. <td rowspan="${n}" class="vtxt">${esc(s.action || "")}</td>`;
  3017. }
  3018. rows += ioCell(outs[i], "out");
  3019. rows += "</tr>";
  3020. }
  3021. }
  3022. return `<div style="overflow-x:auto"><table class="steps">
  3023. <colgroup>
  3024. <col style="width:44px"><col style="width:200px"><col style="width:92px">
  3025. <col style="width:112px"><col style="width:100px">
  3026. <col style="width:112px"><col style="width:330px"><col style="width:92px">
  3027. <col style="width:118px"><col style="width:130px">
  3028. <col style="width:112px"><col style="width:360px"><col style="width:110px">
  3029. </colgroup>
  3030. <thead>
  3031. <tr><th class="h-req" colspan="5">需 求</th><th class="h-in" colspan="3">输 入</th><th class="h-im" colspan="2">实 现</th><th class="h-out" colspan="3">输 出</th></tr>
  3032. <tr>
  3033. <th class="h-req2">#</th><th class="h-req2">目的</th><th class="h-req2">作用</th><th class="h-req2">实质</th><th class="h-req2">形式</th>
  3034. <th class="h-in2">类型</th><th class="h-in2">值</th><th class="h-in2">来源</th>
  3035. <th class="h-im2">外部工具</th><th class="h-im2">动作</th>
  3036. <th class="h-out2">类型</th><th class="h-out2">值</th><th class="h-out2">去处</th>
  3037. </tr>
  3038. </thead><tbody>${rows}</tbody></table></div>`;
  3039. }
  3040. function fmtSF(v) {
  3041. return v == null ? "" : Array.isArray(v) ? v.join("、") : v;
  3042. }
  3043. function ioCell(x, kind) {
  3044. const cls = kind === "in" ? "c-in" : "c-out";
  3045. if (!x) return `<td class="${cls}"></td><td class="${cls}"></td><td class="${cls}"></td>`;
  3046. const inf = x.inferred ? ` inf" title="推断理由:${esc(x.inferred_reason || "模型推断补全")}` : "";
  3047. const badge = x.inferred ? '<span class="ib">推</span>' : "";
  3048. return `<td class="${cls}"><span class="pill ${kind === "in" ? "amber" : "teal"}">${esc(x.type || "")}</span></td>
  3049. <td class="${cls}${inf}">${badge}<div class="clamp-val" onclick="toggleClampVal(this)"><span class="vtxt">${esc(x.value || "")}</span></div></td>
  3050. <td class="${cls}"><span class="anchor">${esc(x.anchor || "")}</span></td>`;
  3051. }
  3052. /* 点击「值」单元格展开/收起(仅在内容溢出、已标记 clampable 时生效) */
  3053. function toggleClampVal(el) {
  3054. if (!el.classList.contains("clampable") && !el.classList.contains("open")) return;
  3055. el.classList.toggle("open");
  3056. }
  3057. /* 渲染后标记真正溢出 4 行的「值」单元格:先套限高再测量,溢出才保留 clampable */
  3058. function markStepClamps() {
  3059. document.querySelectorAll("#xp-body .steps .clamp-val").forEach((el) => {
  3060. if (el.classList.contains("open")) return;
  3061. el.classList.add("clampable");
  3062. if (el.scrollHeight <= el.clientHeight + 2) el.classList.remove("clampable");
  3063. });
  3064. }
  3065. /* ── 工具渲染(表格,移植自 fixed_query_eval renderToolTable)── */
  3066. const DASH = '<span class="dash">—</span>';
  3067. function _toolCell(v) {
  3068. if (v === null || v === undefined || v === "" || (Array.isArray(v) && !v.length)) return DASH;
  3069. if (Array.isArray(v)) return "<ul>" + v.map((x) => `<li>${esc(String(x))}</li>`).join("") + "</ul>";
  3070. return esc(String(v));
  3071. }
  3072. function _scopeCell(v) {
  3073. /* 作用域是 JSON 数组:按「、」拼接成短语,不出列表 */
  3074. if (v === null || v === undefined || (Array.isArray(v) && !v.length) || v === "") return DASH;
  3075. return esc(Array.isArray(v) ? v.join("、") : String(v));
  3076. }
  3077. function _ttCell(inner, clampable) {
  3078. return clampable ? `<div class="tcell" onclick="this.classList.toggle('open')">${inner}</div>` : inner;
  3079. }
  3080. function _toolCellContent(c, t) {
  3081. let inner,
  3082. cls = "",
  3083. clampable = true,
  3084. style = "";
  3085. if (c === "工具名称") {
  3086. cls = "col-tool";
  3087. clampable = false;
  3088. inner = `🔧 ${esc(t[c] || "(未命名)")}`;
  3089. } else if (c === "来源链接") {
  3090. clampable = false;
  3091. inner = t[c]
  3092. ? `<a href="${esc(t[c])}" target="_blank" style="color:#176d64;font-weight:600;">🔗 打开</a>`
  3093. : DASH;
  3094. } else if (c === "创作层级") {
  3095. clampable = false;
  3096. inner = t[c]
  3097. ? `<span class="layer-badge ${t[c] === "制作层" ? "make" : "create"}">${esc(t[c])}</span>`
  3098. : DASH;
  3099. } else if (c === "实质作用域" || c === "形式作用域") {
  3100. inner = _scopeCell(t[c]);
  3101. } else {
  3102. inner = _toolCell(t[c]);
  3103. }
  3104. if (["输入", "输出", "用法", "缺点"].includes(c)) style = "max-width:240px;";
  3105. else if (c === "实质作用域" || c === "形式作用域") style = "max-width:170px;";
  3106. else if (!clampable) style = "white-space:nowrap;";
  3107. return { inner, cls, clampable, style };
  3108. }
  3109. function _td(c, t, rowspan) {
  3110. const { inner, cls, clampable, style } = _toolCellContent(c, t);
  3111. const rs = rowspan > 1 ? ` rowspan="${rowspan}"` : "";
  3112. return `<td class="${cls}" style="${style}"${rs}>${_ttCell(inner, clampable)}</td>`;
  3113. }
  3114. function _caseTd(cse, key) {
  3115. const v = cse && cse[key] != null && cse[key] !== "" ? esc(String(cse[key])) : DASH;
  3116. return `<td class="col-case" style="max-width:210px;">${_ttCell(v, true)}</td>`;
  3117. }
  3118. function renderTools(data) {
  3119. const tools = data.tools || [];
  3120. if (!tools.length) return renderSourceBlock() + '<div class="empty">本版本无工具</div>';
  3121. /* 案例 group(输入/输出/效果)放在 用法 后、缺点 前;用 colspan/rowspan 做两层表头 */
  3122. const before = ["工具名称", "创作层级", "实质作用域", "形式作用域", "输入", "输出", "用法"];
  3123. const after = ["缺点", "来源链接", "最新更新时间"];
  3124. const thead = `<thead>
  3125. <tr>
  3126. ${before.map((c) => `<th rowspan="2">${c}</th>`).join("")}
  3127. <th colspan="3" class="th-group">案例</th>
  3128. ${after.map((c) => `<th rowspan="2">${c}</th>`).join("")}
  3129. </tr>
  3130. <tr>${["输入", "输出", "效果"].map((c) => `<th class="th-sub">${c}</th>`).join("")}</tr>
  3131. </thead>`;
  3132. const rows = tools
  3133. .map((t, ti) => {
  3134. const cases = Array.isArray(t["案例"]) && t["案例"].length ? t["案例"] : [null];
  3135. const K = cases.length;
  3136. const par = ti % 2 ? "tr-b" : "tr-a";
  3137. return cases
  3138. .map((cse, i) => {
  3139. const caseTds = `${_caseTd(cse, "输入")}${_caseTd(cse, "输出")}${_caseTd(cse, "效果")}`;
  3140. if (i === 0) {
  3141. return `<tr class="${par}">${before.map((c) => _td(c, t, K)).join("")}${caseTds}${after.map((c) => _td(c, t, K)).join("")}</tr>`;
  3142. }
  3143. return `<tr class="${par}">${caseTds}</tr>`;
  3144. })
  3145. .join("");
  3146. })
  3147. .join("");
  3148. return (
  3149. renderSourceBlock() +
  3150. `<div class="mw-ttwrap"><table class="mw-tt">${thead}<tbody>${rows}</tbody></table></div>`
  3151. );
  3152. }
  3153. /* 渲染后标记真正溢出的单元格(才显示蒙版+可点击) */
  3154. function markClampedCells() {
  3155. document.querySelectorAll("#xp-body .mw-tt .tcell").forEach((el) => {
  3156. if (!el.classList.contains("open") && el.scrollHeight > el.clientHeight + 2) el.classList.add("clamped");
  3157. else if (el.scrollHeight <= el.clientHeight + 2) el.classList.remove("clamped");
  3158. });
  3159. }
  3160. /* ════ 解构任务 ════ */
  3161. async function startExtract(caseIds) {
  3162. if (!state.queryId || !caseIds.length) return;
  3163. const isProc = state.mode === "process";
  3164. const model = $("#model-sel")?.value || (isProc ? MODELS_PROC[0] : MODELS_TOOL[0]);
  3165. try {
  3166. const r = await api(`/api/extract_${isProc ? "process" : "tools"}`, {
  3167. method: "POST",
  3168. body: JSON.stringify({ query_id: state.queryId, case_ids: caseIds, model }),
  3169. });
  3170. showTask(`${isProc ? "工序" : "工具"}解构 · ${caseIds.length} 帖`, r.task_id, async () => {
  3171. state.selected.clear();
  3172. await selectQuery(state.queryId);
  3173. if (caseIds.includes(state.caseId)) {
  3174. /* selectQuery 清了 caseId,恢复选中 */
  3175. }
  3176. if (caseIds.length === 1) {
  3177. state.caseId = caseIds[0];
  3178. state.version = null;
  3179. renderPosts();
  3180. await loadExtract();
  3181. }
  3182. });
  3183. } catch (e) {
  3184. toast("任务启动失败:" + (e.body?.error || e.status), "error");
  3185. }
  3186. }
  3187. /* ════ 任务面板(✕ 只隐藏;「操作日志」按钮可随时唤回)════ */
  3188. let pollTimer = null,
  3189. hasTask = false;
  3190. function showTask(title, taskId, onDone) {
  3191. hasTask = true;
  3192. $("#task-panel").hidden = false;
  3193. $("#task-title").textContent = title;
  3194. $("#task-dot").className = "dot";
  3195. $("#task-log").textContent = "启动中…";
  3196. clearTimeout(pollTimer);
  3197. const poll = async () => {
  3198. let t;
  3199. try {
  3200. t = await api("/api/task_status?task_id=" + encodeURIComponent(taskId));
  3201. } catch (e) {
  3202. $("#task-log").textContent = "状态查询失败";
  3203. return;
  3204. }
  3205. const log = $("#task-log");
  3206. log.textContent = t.log_tail || "(暂无日志)";
  3207. log.scrollTop = log.scrollHeight;
  3208. if (t.status === "running") {
  3209. pollTimer = setTimeout(poll, 2000);
  3210. return;
  3211. }
  3212. $("#task-dot").className = "dot " + t.status;
  3213. $("#task-title").textContent = title + (t.status === "done" ? " · 完成" : " · 失败");
  3214. if (t.status === "done" && onDone) onDone();
  3215. };
  3216. poll();
  3217. }
  3218. /* ✕ 只隐藏面板,轮询照跑(任务完成后回调依然触发) */
  3219. function hideTask() {
  3220. $("#task-panel").hidden = true;
  3221. }
  3222. function showTaskPanel() {
  3223. if (!hasTask) return toast("本次会话还没有任务日志", "warn");
  3224. $("#task-panel").hidden = false;
  3225. const log = $("#task-log");
  3226. log.scrollTop = log.scrollHeight;
  3227. }
  3228. /* ════ 新建搜索 ════ */
  3229. /* 渠道下拉多选(选项同 search_eval:小红书/知乎/公众号/抖音/视频号/YouTube) */
  3230. const CHANNELS = [
  3231. { key: "xhs", name: "小红书", on: true },
  3232. { key: "zhihu", name: "知乎", on: true },
  3233. { key: "gzh", name: "公众号" },
  3234. { key: "douyin", name: "抖音" },
  3235. { key: "sph", name: "视频号" },
  3236. { key: "youtube", name: "YouTube" },
  3237. ];
  3238. $("#s-plat-panel").innerHTML = CHANNELS.map(
  3239. (c) => `
  3240. <label class="dd-opt ${c.on ? "sel" : ""}">
  3241. <input type="checkbox" value="${c.key}" ${c.on ? "checked" : ""}>${c.name}
  3242. </label>`,
  3243. ).join("");
  3244. function selectedPlatforms() {
  3245. return [...document.querySelectorAll("#s-plat-panel input:checked")].map((x) => x.value);
  3246. }
  3247. function syncPlatBtn() {
  3248. const names = [...document.querySelectorAll("#s-plat-panel input:checked")].map(
  3249. (x) => CHANNELS.find((c) => c.key === x.value).name,
  3250. );
  3251. $("#s-plat-btn").innerHTML =
  3252. `<span>${names.length ? esc(names.join("、")) : "选择渠道"}</span><span class="dd-arrow">▾</span>`;
  3253. }
  3254. $("#s-plat-btn").onclick = (e) => {
  3255. e.stopPropagation();
  3256. $("#s-plat-panel").hidden = !$("#s-plat-panel").hidden;
  3257. };
  3258. $("#s-plat-panel").onclick = (e) => e.stopPropagation();
  3259. $("#s-plat-panel").addEventListener("change", (e) => {
  3260. e.target.closest(".dd-opt").classList.toggle("sel", e.target.checked);
  3261. syncPlatBtn();
  3262. });
  3263. document.addEventListener("click", () => {
  3264. $("#s-plat-panel").hidden = true;
  3265. });
  3266. syncPlatBtn();
  3267. $("#btn-new-search").onclick = () => {
  3268. $("#s-mode").value = state.mode === "process" ? "工序" : "工具"; // 默认跟随当前子模式
  3269. $("#search-modal").hidden = false;
  3270. $("#s-query").focus();
  3271. };
  3272. $("#search-modal").onclick = (e) => {
  3273. if (e.target === $("#search-modal")) $("#search-modal").hidden = true;
  3274. };
  3275. $("#s-go").onclick = async () => {
  3276. const query = $("#s-query").value.trim();
  3277. if (!query) return toast("请填写 query", "warn");
  3278. const plats = selectedPlatforms();
  3279. if (!plats.length) return toast("请至少选择一个检索渠道", "warn");
  3280. const body = {
  3281. query,
  3282. synonyms: $("#s-syn").value.trim(),
  3283. mode_type: $("#s-mode").value,
  3284. platforms: plats.join(","),
  3285. max_count: parseInt($("#s-max").value) || 10,
  3286. };
  3287. try {
  3288. const r = await api("/api/run_search", { method: "POST", body: JSON.stringify(body) });
  3289. $("#search-modal").hidden = true;
  3290. showTask(`搜索 · ${r.query_id} ${query}`, r.task_id, async () => {
  3291. /* 搜索结果落在 s-mode 对应的表,完成后切到对应子模式再选中 */
  3292. const m = body.mode_type === "工具" ? "tools" : "process";
  3293. if (state.mode !== m) {
  3294. state.mode = m;
  3295. $("#m-process").classList.toggle("on", m === "process");
  3296. $("#m-tools").classList.toggle("on", m === "tools");
  3297. }
  3298. await loadQueries();
  3299. selectQuery(r.query_id);
  3300. });
  3301. } catch (e) {
  3302. toast("搜索启动失败:" + (e.body?.error || e.status), "error");
  3303. }
  3304. };
  3305. /* ════ 工序/工具子模式 ════ */
  3306. $("#m-process").onclick = () => setMode("process");
  3307. $("#m-tools").onclick = () => setMode("tools");
  3308. function setMode(m) {
  3309. if (state.mode === m) return;
  3310. state.mode = m;
  3311. state.version = null;
  3312. /* 工序/工具是两张独立搜索表,切换时整体重置三栏 */
  3313. state.queryId = null;
  3314. state.caseId = null;
  3315. state.post = null;
  3316. state.posts = [];
  3317. state.selected.clear();
  3318. state.platFilter = "all";
  3319. $("#m-process").classList.toggle("on", m === "process");
  3320. $("#m-tools").classList.toggle("on", m === "tools");
  3321. $("#plat-tabs").hidden = true;
  3322. $("#p-count").textContent = "";
  3323. $("#post-list").innerHTML = '<div class="empty"><span class="glyph">←</span>先选择左侧 query</div>';
  3324. renderExtractEmpty();
  3325. loadQueries();
  3326. }
  3327. window.addEventListener("resize", () => chartRefs.forEach((c) => c.resize()));
  3328. route();
  3329. </script>
  3330. </body>
  3331. </html>