index.html 113 KB

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