index.html 128 KB

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