index.html 139 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027
  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. /* Query 规则弹层 */
  2055. .qr-box { background:#fff; border-radius:14px; box-shadow:0 10px 44px rgba(0,0,0,.18);
  2056. width:96vw; max-width:1200px; max-height:92vh; display:flex; flex-direction:column; overflow:hidden; }
  2057. .qr-head { display:flex; align-items:center; padding:15px 20px; border-bottom:1px solid #eee; }
  2058. .qr-title { font-size:15px; font-weight:600; color:#1a1a1a; }
  2059. .qr-x { margin-left:auto; border:none; background:none; font-size:16px; color:#999; cursor:pointer; padding:4px 9px; border-radius:7px; line-height:1; }
  2060. .qr-x:hover { background:#f2f2f2; color:#333; }
  2061. .qr-bar { display:flex; align-items:center; gap:10px; padding:11px 20px; border-bottom:1px solid #f0f0f0; background:#fcfcfc; }
  2062. .qr-hint { color:#888; font-size:12px; margin-left:4px; }
  2063. .qr-dims { padding:8px 20px 10px; max-height:32vh; overflow:auto; border-bottom:1px solid #f0f0f0; }
  2064. .qr-row { display:flex; align-items:flex-start; gap:10px; padding:4px 0; }
  2065. .qr-row + .qr-row { border-top:1px solid #f6f6f6; }
  2066. .qr-lab { min-width:64px; color:#999; font-size:12.5px; padding-top:5px; flex-shrink:0; }
  2067. .qr-chips { display:flex; flex-wrap:wrap; gap:6px; flex:1; }
  2068. .chip { padding:4px 13px; border-radius:16px; font-size:12.5px; cursor:pointer; border:1.5px solid #e2e2e2; background:#fff; color:#555; line-height:1.4; }
  2069. .chip:hover { border-color:#bbb; color:#222; }
  2070. .chip.on { background:#1a1a1a; border-color:#1a1a1a; color:#fff; font-weight:500; }
  2071. .chip.axis.on { background:#2563eb; border-color:#2563eb; }
  2072. .qr-table-wrap { overflow:auto; flex:1; }
  2073. .qr-tab { border-collapse:collapse; font-size:11px; }
  2074. .qr-tab th, .qr-tab td { border:1px solid #eee; padding:3px 7px; white-space:nowrap; }
  2075. .qr-tab thead th { position:sticky; top:0; background:#f7f7f7; z-index:2; }
  2076. .qr-corner { position:sticky; left:0; z-index:3; background:#eef0f3; font-weight:600; color:#555; }
  2077. .qr-th { position:sticky; left:0; background:#fafafa; z-index:1; text-align:left; color:#444; }
  2078. .qr-tl1 { background:#eef0f3; font-weight:600; color:#444; }
  2079. .qr-gh { background:#e8ebef; font-weight:600; color:#333; text-align:center; }
  2080. .qr-ah { background:#f3f4f6; color:#555; text-align:center; }
  2081. .qr-c.t0 { background:#fafafa; color:#bbb; } .qr-c.t1 { background:#f1f8f1; }
  2082. .qr-c.t2 { background:#d8ecd8; } .qr-c.t3 { background:#b9ddb9; }
  2083. .qr-c.dead { color:#ccc; }
  2084. .qr-c.keep { outline:2px solid #2563eb; outline-offset:-2px; cursor:pointer; font-weight:600; }
  2085. .qr-c.keep:hover { background:#dbe7ff; }
  2086. .qr-bd { display:inline-block; margin-left:4px; font-style:normal; font-size:9px; font-weight:700; color:#2563eb; }
  2087. .qr-pop { position:fixed; z-index:60; width:300px; background:#fff; border:1px solid #e2e2e2;
  2088. border-radius:11px; box-shadow:0 8px 30px rgba(0,0,0,.18); padding:13px 15px; font-size:12.5px; color:#333; }
  2089. .qr-pop .q { font-size:13.5px; font-weight:600; color:#1a1a1a; margin-bottom:2px; word-break:break-all; }
  2090. .qr-pop .orig { font-size:11px; color:#aaa; margin-bottom:8px; }
  2091. .qr-pop .sc { display:flex; align-items:baseline; gap:8px; margin:6px 0; }
  2092. .qr-pop .sc b { font-size:22px; color:#2563eb; }
  2093. .qr-pop .dim { color:#888; font-size:11.5px; }
  2094. .qr-pop .rsn { color:#555; margin:7px 0 10px; line-height:1.5; }
  2095. .qr-pop .acts { display:flex; gap:8px; }
  2096. </style>
  2097. </head>
  2098. <body>
  2099. <div id="toast-wrap" aria-live="polite"></div>
  2100. <header>
  2101. <div class="logo">
  2102. <div class="seal">解</div>
  2103. <div><b>mode_workflow</b><small>解构工作台 · MODE WORKBENCH</small></div>
  2104. </div>
  2105. <nav id="nav">
  2106. <a
  2107. href="#dashboard"
  2108. data-tab="dashboard"
  2109. >Dashboard</a
  2110. >
  2111. <a
  2112. href="#dataset"
  2113. data-tab="dataset"
  2114. >Dataset</a
  2115. >
  2116. <a
  2117. href="#cluster"
  2118. data-tab="cluster"
  2119. >知识库</a
  2120. >
  2121. </nav>
  2122. <div class="spacer"></div>
  2123. <div class="hint">SEARCH · EXTRACT · ARCHIVE</div>
  2124. </header>
  2125. <main id="view-dashboard"></main>
  2126. <main id="view-dataset">
  2127. <div class="ds-top">
  2128. <div class="mode-switch">
  2129. <button
  2130. id="m-process"
  2131. class="on"
  2132. >
  2133. 工序
  2134. </button>
  2135. <button id="m-tools">工具</button>
  2136. </div>
  2137. <div style="flex: 1"></div>
  2138. <button
  2139. class="btn seal"
  2140. id="btn-new-search"
  2141. >
  2142. + 新建搜索
  2143. </button>
  2144. <button class="btn" id="btn-query-rule" style="margin-left:8px">Query 规则</button>
  2145. </div>
  2146. <div class="ds-grid">
  2147. <div class="card">
  2148. <div class="col-head">
  2149. QUERY
  2150. <span
  2151. class="n"
  2152. id="q-count"
  2153. ></span>
  2154. </div>
  2155. <div
  2156. class="qlist"
  2157. id="query-list"
  2158. >
  2159. <div class="empty">暂无 query</div>
  2160. </div>
  2161. </div>
  2162. <div class="card">
  2163. <div class="col-head">
  2164. 帖子
  2165. <span style="display: flex; gap: 8px; align-items: center">
  2166. <span
  2167. class="n"
  2168. id="p-count"
  2169. ></span>
  2170. <button
  2171. class="btn sm"
  2172. id="btn-batch"
  2173. disabled
  2174. hidden
  2175. >
  2176. 批量解构
  2177. </button>
  2178. </span>
  2179. </div>
  2180. <div
  2181. class="plat-tabs"
  2182. id="plat-tabs"
  2183. hidden
  2184. ></div>
  2185. <div
  2186. class="plist"
  2187. id="post-list"
  2188. >
  2189. <div class="empty"><span class="glyph">←</span>先选择左侧 query</div>
  2190. </div>
  2191. </div>
  2192. <div class="card xp">
  2193. <div
  2194. class="xp-head"
  2195. id="xp-head"
  2196. >
  2197. <span class="st">解构结果</span>
  2198. </div>
  2199. <div
  2200. class="xp-body"
  2201. id="xp-body"
  2202. >
  2203. <div class="empty"><span class="glyph">←</span>选择一个帖子查看解构结果</div>
  2204. </div>
  2205. </div>
  2206. </div>
  2207. </main>
  2208. <main id="view-cluster">
  2209. <iframe
  2210. id="cluster-frame"
  2211. title="知识检索"
  2212. loading="lazy"
  2213. ></iframe>
  2214. </main>
  2215. <div
  2216. id="task-panel"
  2217. hidden
  2218. >
  2219. <header>
  2220. <span
  2221. class="dot"
  2222. id="task-dot"
  2223. ></span
  2224. ><span id="task-title">任务</span> <button onclick="hideTask()">✕</button>
  2225. </header>
  2226. <div id="task-log"></div>
  2227. </div>
  2228. <!-- 帖子详情弹层(评分详情参考 fixed_query_eval) -->
  2229. <dialog id="post-dialog">
  2230. <div class="pd-wrap">
  2231. <div class="pd-head">
  2232. <div style="min-width: 0">
  2233. <div
  2234. class="pd-meta"
  2235. id="pd-meta"
  2236. ></div>
  2237. <h3 id="pd-title"></h3>
  2238. </div>
  2239. <button
  2240. class="pd-close"
  2241. onclick="document.getElementById('post-dialog').close()"
  2242. >
  2243. </button>
  2244. </div>
  2245. <div class="pd-body">
  2246. <section>
  2247. <div id="pd-verdict"></div>
  2248. <div class="pd-sec-title">抓取文本节选</div>
  2249. <div
  2250. class="pd-raw"
  2251. id="pd-text"
  2252. ></div>
  2253. <div class="pd-sec-title">图片预览</div>
  2254. <div
  2255. class="pd-images"
  2256. id="pd-images"
  2257. ></div>
  2258. <div
  2259. class="pd-sec-title"
  2260. id="pd-videos-title"
  2261. style="display: none"
  2262. >
  2263. 视频预览
  2264. </div>
  2265. <div
  2266. class="pd-videos"
  2267. id="pd-videos"
  2268. style="display: none"
  2269. ></div>
  2270. <div
  2271. class="pd-tags"
  2272. id="pd-tags"
  2273. ></div>
  2274. </section>
  2275. <aside>
  2276. <div class="pd-score-head">
  2277. <span class="t">评分详情</span>
  2278. <span class="pd-overall">综合评分 <b id="pd-overall">—</b></span>
  2279. </div>
  2280. <div id="pd-scores"></div>
  2281. </aside>
  2282. </div>
  2283. </div>
  2284. </dialog>
  2285. <!-- 重新解构 · 编辑解构 Prompt -->
  2286. <dialog id="reextract-dlg">
  2287. <div class="rx-wrap">
  2288. <div class="rx-head">
  2289. <div class="rx-title">重新解构 · 编辑解构 Prompt</div>
  2290. <button
  2291. class="btn sm"
  2292. onclick="document.getElementById('reextract-dlg').close()"
  2293. >
  2294. 关闭
  2295. </button>
  2296. </div>
  2297. <div class="rx-sub">
  2298. 修改下面的解构 Prompt 后,点「保存修改」将按最新 Prompt
  2299. 重新解构本帖(生成新版本,旧版本保留)。改动仅本次生效,不会改写默认 Prompt。
  2300. </div>
  2301. <div class="rx-model">
  2302. <label>模型:</label>
  2303. <select id="rx-model"></select>
  2304. </div>
  2305. <textarea
  2306. id="rx-prompt"
  2307. class="rx-prompt"
  2308. spellcheck="false"
  2309. ></textarea>
  2310. <div class="rx-foot">
  2311. <button
  2312. class="btn"
  2313. onclick="document.getElementById('reextract-dlg').close()"
  2314. >
  2315. 取消
  2316. </button>
  2317. <button
  2318. class="btn primary"
  2319. id="rx-save"
  2320. onclick="saveReextract()"
  2321. >
  2322. 保存修改
  2323. </button>
  2324. </div>
  2325. </div>
  2326. </dialog>
  2327. <!-- 图片预览灯箱(支持左右切换) -->
  2328. <dialog
  2329. class="lightbox"
  2330. id="lightbox"
  2331. onclick="if (event.target === this) closeLightbox();"
  2332. >
  2333. <button
  2334. class="lb-close"
  2335. onclick="closeLightbox()"
  2336. title="关闭 (Esc)"
  2337. >
  2338. </button>
  2339. <button
  2340. class="lb-nav lb-prev"
  2341. onclick="lbStep(-1)"
  2342. title="上一张 (←)"
  2343. >
  2344. </button>
  2345. <figure class="lb-stage">
  2346. <img
  2347. id="lb-img"
  2348. src=""
  2349. alt=""
  2350. />
  2351. <figcaption id="lb-count"></figcaption>
  2352. </figure>
  2353. <button
  2354. class="lb-nav lb-next"
  2355. onclick="lbStep(1)"
  2356. title="下一张 (→)"
  2357. >
  2358. </button>
  2359. </dialog>
  2360. <div
  2361. class="modal-bg"
  2362. id="search-modal"
  2363. hidden
  2364. >
  2365. <div class="modal">
  2366. <h2>新建搜索</h2>
  2367. <div class="mb">
  2368. <label
  2369. >Query(评估锚点,必填)<input
  2370. type="text"
  2371. id="s-query"
  2372. placeholder="如:AI 人像 图片 生成 怎么做"
  2373. /></label>
  2374. <label
  2375. >解构方向<select id="s-mode">
  2376. <option value="工序">工序</option>
  2377. <option value="工具">工具</option>
  2378. </select></label
  2379. >
  2380. <label
  2381. >同义措辞(可选,逗号分隔)<input
  2382. type="text"
  2383. id="s-syn"
  2384. placeholder="如:AI 人像生成 教程,AI 写真 怎么做"
  2385. /></label>
  2386. <label
  2387. >检索渠道(下拉多选)
  2388. <div
  2389. class="dd"
  2390. id="s-plat-dd"
  2391. >
  2392. <button
  2393. type="button"
  2394. class="dd-btn"
  2395. id="s-plat-btn"
  2396. >
  2397. 选择渠道 ▾
  2398. </button>
  2399. <div
  2400. class="dd-panel"
  2401. id="s-plat-panel"
  2402. hidden
  2403. ></div>
  2404. </div>
  2405. </label>
  2406. <label
  2407. >每措辞每渠道上限<input
  2408. type="number"
  2409. id="s-max"
  2410. value="10"
  2411. min="1"
  2412. max="50"
  2413. /></label>
  2414. </div>
  2415. <div class="mf">
  2416. <button
  2417. class="btn"
  2418. onclick="document.getElementById('search-modal').hidden = true"
  2419. >
  2420. 取消
  2421. </button>
  2422. <button
  2423. class="btn primary"
  2424. id="s-go"
  2425. >
  2426. 开始搜索
  2427. </button>
  2428. </div>
  2429. </div>
  2430. </div>
  2431. <!-- Query 规则组织器 弹层 -->
  2432. <div class="modal-bg" id="qr-modal" hidden>
  2433. <div class="qr-box">
  2434. <div class="qr-head">
  2435. <span class="qr-title">Query 词组织器</span>
  2436. <button class="qr-x" id="qr-close" title="关闭">✕</button>
  2437. </div>
  2438. <div class="qr-bar">
  2439. <button class="btn seal" id="qr-score">生成正交表 &amp; 评估高亮</button>
  2440. <button class="btn" id="qr-search-all" hidden>搜全部达标</button>
  2441. <span id="qr-hint" class="qr-hint"></span>
  2442. </div>
  2443. <div id="qr-dims" class="qr-dims"></div>
  2444. <div id="qr-table-wrap" class="qr-table-wrap"></div>
  2445. </div>
  2446. <div id="qr-pop" class="qr-pop" hidden></div>
  2447. </div>
  2448. <script>
  2449. /* ════ 基础 ════ */
  2450. const $ = (s) => document.querySelector(s);
  2451. /* 页内提示,替代浏览器原生 alert();type: info|error|success|warn */
  2452. function toast(msg, type = "info", ms = 3200) {
  2453. const wrap = $("#toast-wrap");
  2454. if (!wrap) return;
  2455. const ic = { info: "i", error: "!", success: "✓", warn: "!" }[type] || "i";
  2456. const el = document.createElement("div");
  2457. el.className = "toast " + type;
  2458. el.innerHTML = `<span class="ic">${ic}</span><span class="msg">${esc(msg)}</span>`;
  2459. const dismiss = () => {
  2460. el.classList.add("out");
  2461. el.addEventListener("animationend", () => el.remove(), { once: true });
  2462. };
  2463. el.addEventListener("click", dismiss);
  2464. wrap.appendChild(el);
  2465. setTimeout(dismiss, ms);
  2466. }
  2467. const api = (p, opt) =>
  2468. fetch(p, opt).then(async (r) => {
  2469. if (!r.ok)
  2470. throw Object.assign(new Error("api"), { status: r.status, body: await r.json().catch(() => ({})) });
  2471. return r.json();
  2472. });
  2473. const esc = (s) =>
  2474. String(s ?? "").replace(
  2475. /[&<>"']/g,
  2476. (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[c],
  2477. );
  2478. /* 目的列: 把 intent 里的 {类别:值} 标记渲染成彩色胶囊 (口径同 procedure-dsl renderer.py:render_intent)。
  2479. 合法类别 5 个: effect/via/act/in-type/out-type; 其余落 ik-other(红删除线,当 lint 警告)。
  2480. 标记外的字面文字与值都做 HTML 转义。 */
  2481. const INTENT_KIND = {
  2482. effect: "ik-effect", via: "ik-via", act: "ik-act",
  2483. "in-type": "ik-in-type", "out-type": "ik-out-type",
  2484. };
  2485. const renderIntent = (text) => {
  2486. const s = String(text ?? "");
  2487. const re = /\{([\w-]+):([^}]+)\}/g;
  2488. let out = "", last = 0, m;
  2489. while ((m = re.exec(s))) {
  2490. out += esc(s.slice(last, m.index).replace(/`/g, ""));
  2491. const kc = INTENT_KIND[m[1]] || "ik-other";
  2492. out += `<span class="intent-tok ${kc}">${esc(m[2])}</span>`;
  2493. last = m.index + m[0].length;
  2494. }
  2495. return out + esc(s.slice(last).replace(/`/g, ""));
  2496. };
  2497. /* 外链图片走本服务同源反代,绕过公众号(mmbiz.qpic.cn)等防盗链 */
  2498. const imgProxy = (u) => (/^https?:\/\//.test(u || "") ? "/api/img?u=" + encodeURIComponent(u) : u || "");
  2499. /* 图片加载策略:优先「浏览器直连 CDN」(referrerpolicy=no-referrer 多数能绕防盗链),
  2500. 直连失败再回退到同源代理 /api/img。
  2501. 为什么:公网走 Cloudflare 快速隧道(trycloudflare),所有经 /api/img 的图片字节都要
  2502. 「上游CDN → 本机 → 隧道(受本机上行带宽限制)→ 客户」,一帖十几张图(每张 100~180KB)
  2503. 就把本机上行打满,于是「本地快、公网慢」。改为浏览器直连后,绝大多数图片字节不再过本机/
  2504. 隧道,只有少数仍被防盗链拦截的才回退代理。 */
  2505. const imgDirect = (u) => (/^https?:\/\//.test(u || "") ? u : imgProxy(u));
  2506. function imgFallback(el, proxy) {
  2507. el.onerror = null; // 防止回调里再次触发自身造成死循环
  2508. if (!el.dataset.fb) {
  2509. el.dataset.fb = "1"; // 直连失败 → 回退同源代理(防盗链兜底)
  2510. el.onerror = () => imgFallback(el, proxy);
  2511. el.src = proxy;
  2512. return;
  2513. }
  2514. if (el.dataset.ph)
  2515. el.outerHTML = el.dataset.ph; // 代理也失败:换占位元素
  2516. else el.style.opacity = 0.25; // 无占位:淡化
  2517. }
  2518. function imgHtml(u, { cls = "", extra = "", ph = "" } = {}) {
  2519. const phAttr = ph ? ` data-ph="${esc(ph)}"` : "";
  2520. return `<img ${cls ? `class="${cls}" ` : ""}src="${esc(imgDirect(u))}" referrerpolicy="no-referrer" loading="lazy"${phAttr} ${extra} onerror="imgFallback(this,'${esc(imgProxy(u))}')">`;
  2521. }
  2522. const state = {
  2523. tab: "dashboard",
  2524. mode: "process",
  2525. queryId: null,
  2526. caseId: null,
  2527. post: null,
  2528. version: null,
  2529. platFilter: "all",
  2530. doneFilter: true,
  2531. selected: new Set(),
  2532. queries: [],
  2533. posts: [],
  2534. };
  2535. const PLAT_CLS = (p) =>
  2536. ({ xhs: "xhs", gzh: "gzh", zhihu: "zhihu", douyin: "douyin", sph: "sph", youtube: "youtube", x: "x" })[p] ||
  2537. "other";
  2538. const PLAT_NAME = (p) =>
  2539. ({
  2540. xhs: "小红书",
  2541. gzh: "公众号",
  2542. sph: "视频号",
  2543. github: "GitHub",
  2544. toutiao: "头条",
  2545. douyin: "抖音",
  2546. bili: "哔哩哔哩",
  2547. zhihu: "知乎",
  2548. weibo: "微博",
  2549. youtube: "YouTube",
  2550. x: "X",
  2551. })[p] ||
  2552. p ||
  2553. "?";
  2554. /* 渠道 logo 徽标(品牌色圆角方块,hover 显示渠道名) */
  2555. /* 有对应 SVG 图标的渠道(文件位于 /icons/<key>.svg) */
  2556. const PLAT_ICONS = new Set(["xhs", "gzh", "sph", "github", "douyin", "bili", "zhihu", "weibo", "youtube"]);
  2557. const PLAT_LOGO = (p, size = 18) =>
  2558. PLAT_ICONS.has(p)
  2559. ? `<span class="plat-logo" title="${PLAT_NAME(p)}"><img src="/icons/${p}.svg" width="${size}" height="${size}" alt="${PLAT_NAME(p)}" loading="lazy"></span>`
  2560. : `<span class="plat other">${esc(PLAT_NAME(p))}</span>`;
  2561. const MODELS_PROC = ["anthropic/claude-sonnet-4-6", "google/gemini-3.1-flash-lite"];
  2562. const MODELS_TOOL = ["google/gemini-3.1-flash-lite", "anthropic/claude-sonnet-4-6"];
  2563. const scoreCls = (v) => (v == null ? "s0" : v >= 9 ? "s9" : v >= 8 ? "s8" : v >= 6 ? "s6" : "s0");
  2564. /* ════ 路由 ════ */
  2565. function route() {
  2566. state.tab = (location.hash || "#dashboard").slice(1);
  2567. if (!["dashboard", "dataset", "cluster"].includes(state.tab)) state.tab = "dashboard";
  2568. document.querySelectorAll("nav a").forEach((a) => a.classList.toggle("on", a.dataset.tab === state.tab));
  2569. document.querySelectorAll("main").forEach((m) => m.classList.toggle("on", m.id === "view-" + state.tab));
  2570. if (state.tab === "dashboard") renderDashboard();
  2571. if (state.tab === "dataset" && !state.queries.length) loadQueries();
  2572. if (state.tab === "cluster") {
  2573. // 首次打开聚类库才加载内嵌检索页
  2574. const f = $("#cluster-frame");
  2575. if (f && !f.src) f.src = "/search.html";
  2576. }
  2577. }
  2578. window.addEventListener("hashchange", route);
  2579. /* ════ Dashboard ════ */
  2580. let chartRefs = [];
  2581. async function renderDashboard() {
  2582. const v = $("#view-dashboard");
  2583. let d;
  2584. try {
  2585. d = await api("/api/dashboard");
  2586. } catch (e) {
  2587. v.innerHTML = `<div class="card empty"><span class="glyph">!</span>Dashboard 加载失败:${esc(e.body?.error || e.status)}</div>`;
  2588. return;
  2589. }
  2590. const r = d.result,
  2591. p = d.process_data;
  2592. // 进度百分比向下取整:200/201=99.5% 显示 99%,未真正做完不会显示 100%
  2593. const pct = (a, b) => (b ? Math.floor((a / b) * 100) : 0);
  2594. const platBreak = (arr) =>
  2595. (arr || [])
  2596. .map(
  2597. ([k, n]) =>
  2598. `<span class="pb-item">${PLAT_LOGO(k, 15)}<b class="num">${n}</b></span>`,
  2599. )
  2600. .join("") || "—";
  2601. v.innerHTML = `
  2602. <div class="dash-section"><h2>结果数据</h2><div class="rule"></div><span class="tag">RESULTS</span></div>
  2603. <div class="cards">
  2604. <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>
  2605. <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>
  2606. <div class="card stat a"><div class="lbl">工具数量</div><div class="val num">${r.tool_count}</div><div class="sub">mode_tools 去重工具名</div></div>
  2607. <div class="card stat r"><div class="lbl">内容树覆盖节点</div><div class="val num">0</div>
  2608. <div class="sub">0%</div></div>
  2609. <div class="card stat"><div class="lbl">实质数量</div><div class="val num">${r.substance_count}</div><div class="sub">去重实质条目数</div></div>
  2610. <div class="card stat"><div class="lbl">形式数量</div><div class="val num">${r.form_count}</div><div class="sub">去重形式条目数</div></div>
  2611. </div>
  2612. <div class="dash-section"><h2>过程数据</h2><div class="rule"></div><span class="tag">PROCESS</span></div>
  2613. <div class="cards">
  2614. <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>
  2615. <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>
  2616. <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>
  2617. <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>
  2618. <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>
  2619. <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>
  2620. </div>
  2621. <div class="charts">
  2622. <div class="card chart-card span6"><h3>工序提及工具 TOP10</h3><div class="chart" id="ch-via" style="height:300px"></div></div>
  2623. <div class="card chart-card span6"><h3>解构成本趋势</h3><div class="chart" id="ch-cost" style="height:300px"></div></div>
  2624. <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>
  2625. <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>
  2626. <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>
  2627. </div>`;
  2628. chartRefs.forEach((c) => c.dispose());
  2629. chartRefs = [];
  2630. const mk = (id, opt) => {
  2631. const c = echarts.init($(id));
  2632. c.setOption(opt);
  2633. chartRefs.push(c);
  2634. return c;
  2635. };
  2636. const ink = "#1c2433",
  2637. faint = "#9aa3b0",
  2638. grid = { left: 8, right: 16, top: 8, bottom: 8, containLabel: true };
  2639. /* 热力图 */
  2640. mk("#ch-matrix", {
  2641. tooltip: { formatter: (pr) => `${r.matrix_actions[pr.value[1]]} × ${r.matrix_types[pr.value[0]]}` },
  2642. grid: { left: 8, right: 16, top: 8, bottom: 60, containLabel: true },
  2643. xAxis: {
  2644. type: "category",
  2645. data: r.matrix_types,
  2646. axisLabel: { rotate: 60, fontSize: 9, color: faint },
  2647. splitArea: { show: true, areaStyle: { color: ["#fcfcf9", "#f5f4ef"] } },
  2648. },
  2649. yAxis: {
  2650. type: "category",
  2651. data: r.matrix_actions,
  2652. axisLabel: { fontSize: 10, color: ink },
  2653. splitArea: { show: true },
  2654. },
  2655. visualMap: { show: false, min: 0, max: 1, inRange: { color: ["#f0efe8", "#bb3a22"] } },
  2656. series: [
  2657. {
  2658. type: "heatmap",
  2659. data: r.matrix_cells.map(([a, t]) => [t, a, 1]),
  2660. itemStyle: { borderColor: "#fff", borderWidth: 1 },
  2661. },
  2662. ],
  2663. });
  2664. const bar = (data, color) => ({
  2665. tooltip: {},
  2666. grid,
  2667. xAxis: { type: "value", axisLabel: { color: faint } },
  2668. yAxis: {
  2669. type: "category",
  2670. data: data.map((x) => x[0]).reverse(),
  2671. axisLabel: { color: ink, fontSize: 11, width: 130, overflow: "truncate" },
  2672. },
  2673. series: [
  2674. {
  2675. type: "bar",
  2676. data: data.map((x) => x[1]).reverse(),
  2677. itemStyle: { color, borderRadius: [0, 3, 3, 0] },
  2678. barMaxWidth: 16,
  2679. label: { show: true, position: "right", color: faint, fontSize: 10 },
  2680. },
  2681. ],
  2682. });
  2683. mk("#ch-via", r.via_top10.length ? bar(r.via_top10, "#1e3a5f") : emptyOpt());
  2684. mk("#ch-sub", r.substance_top.length ? bar(r.substance_top, "#b45309") : emptyOpt());
  2685. mk("#ch-form", r.form_top.length ? bar(r.form_top, "#0f6b5c") : emptyOpt());
  2686. mk(
  2687. "#ch-cost",
  2688. p.cost_trend.length
  2689. ? {
  2690. tooltip: { trigger: "axis" },
  2691. grid,
  2692. xAxis: { type: "category", data: p.cost_trend.map((x) => x.date), axisLabel: { color: faint } },
  2693. yAxis: { type: "value", axisLabel: { color: faint, formatter: "${value}" } },
  2694. series: [
  2695. {
  2696. type: "line",
  2697. data: p.cost_trend.map((x) => x.cost),
  2698. smooth: true,
  2699. symbolSize: 7,
  2700. lineStyle: { color: "#bb3a22", width: 2.5 },
  2701. itemStyle: { color: "#bb3a22" },
  2702. areaStyle: { color: "rgba(187,58,34,.08)" },
  2703. },
  2704. ],
  2705. }
  2706. : emptyOpt(),
  2707. );
  2708. function emptyOpt() {
  2709. return {
  2710. title: {
  2711. text: "暂无数据",
  2712. left: "center",
  2713. top: "middle",
  2714. textStyle: { color: faint, fontSize: 12, fontWeight: 400 },
  2715. },
  2716. xAxis: { show: false },
  2717. yAxis: { show: false },
  2718. };
  2719. }
  2720. }
  2721. /* ════ Dataset:query 列表 ════ */
  2722. async function loadQueries() {
  2723. /* 工序/工具各自一张搜索表,query 列表按当前子模式拉取 */
  2724. try {
  2725. state.queries = await api("/api/queries?mode=" + state.mode);
  2726. } catch (e) {
  2727. state.queries = [];
  2728. }
  2729. renderQueries();
  2730. /* 进入/切换子模式时默认选中第一个 query(进而联动第一帖与解构结果) */
  2731. if (!state.queryId && state.queries.length) await selectQuery(state.queries[0].query_id);
  2732. }
  2733. function renderQueries() {
  2734. const list = state.queries;
  2735. $("#q-count").textContent = list.length ? list.length + " 组" : "";
  2736. if (!list.length) {
  2737. $("#query-list").innerHTML = '<div class="empty">暂无 query<br>点右上「新建搜索」开始</div>';
  2738. return;
  2739. }
  2740. $("#query-list").innerHTML = list
  2741. .map((q) => {
  2742. const done = state.mode === "process" ? q.process_done : q.tools_done;
  2743. return `<div class="qitem ${q.query_id === state.queryId ? "on" : ""}" onclick="selectQuery('${q.query_id}')">
  2744. <div class="qid">${q.query_id}</div>
  2745. <div class="qt">${esc(q.query_text || "(未命名)")}</div>
  2746. <div class="qm">
  2747. <span>采纳/命中 <b class="num hit">${q.hit_count ?? 0}</b></span>
  2748. <span>总帖数 <b class="num">${q.post_count}</b></span>
  2749. <span>已解构 <b class="num">${done}</b></span>
  2750. </div>
  2751. </div>`;
  2752. })
  2753. .join("");
  2754. }
  2755. async function selectQuery(qid) {
  2756. state.queryId = qid;
  2757. state.caseId = null;
  2758. state.post = null;
  2759. state.platFilter = "all";
  2760. state.selected.clear();
  2761. renderQueries();
  2762. renderExtractEmpty();
  2763. $("#post-list").innerHTML = '<div class="empty">加载中…</div>';
  2764. try {
  2765. state.posts = await api("/api/posts?mode=" + state.mode + "&query_id=" + encodeURIComponent(qid));
  2766. } catch (e) {
  2767. state.posts = [];
  2768. }
  2769. renderPosts();
  2770. /* 默认选中「可见列表」第一帖(已解构筛选下即第一个已解构帖),无可见帖则退回全部第一帖 */
  2771. if (state.posts.length) {
  2772. const vis = visiblePosts();
  2773. await selectPost((vis[0] || state.posts[0]).case_id);
  2774. }
  2775. }
  2776. /* ════ Dataset:帖子列表(按渠道分 tab)════ */
  2777. function setPlatFilter(p) {
  2778. state.platFilter = p;
  2779. renderPosts();
  2780. }
  2781. function toggleDoneFilter() {
  2782. state.doneFilter = !state.doneFilter;
  2783. renderPosts();
  2784. renderPostsAutoSelect();
  2785. }
  2786. /* 当前可见帖(渠道 + 已解构筛选后),供列表渲染与「默认选中」共用 */
  2787. function visiblePosts() {
  2788. const isDone = (p) => (state.mode === "process" ? p.has_process : p.has_tools);
  2789. let list =
  2790. state.platFilter === "all"
  2791. ? state.posts
  2792. : state.posts.filter((p) => (p.platform || "other") === state.platFilter);
  2793. if (state.doneFilter) list = list.filter(isDone);
  2794. return list;
  2795. }
  2796. /* 切换筛选后,若当前选中帖已被筛掉,则改选可见列表的第一帖 */
  2797. async function renderPostsAutoSelect() {
  2798. const vis = visiblePosts();
  2799. if (vis.length && !vis.some((p) => p.case_id === state.caseId)) await selectPost(vis[0].case_id);
  2800. }
  2801. function renderPosts() {
  2802. const all = state.posts;
  2803. updateBatchBtn();
  2804. /* 渠道 tab + 已解构筛选 */
  2805. const counts = {};
  2806. all.forEach((p) => {
  2807. const k = p.platform || "other";
  2808. counts[k] = (counts[k] || 0) + 1;
  2809. });
  2810. const plats = Object.keys(counts);
  2811. if (state.platFilter !== "all" && !counts[state.platFilter]) state.platFilter = "all";
  2812. const isDone = (p) => (state.mode === "process" ? p.has_process : p.has_tools);
  2813. const platScoped =
  2814. state.platFilter === "all" ? all : all.filter((p) => (p.platform || "other") === state.platFilter);
  2815. const doneN = platScoped.filter(isDone).length;
  2816. const tabs = $("#plat-tabs");
  2817. if (all.length) {
  2818. tabs.hidden = false;
  2819. const btns =
  2820. plats.length > 1
  2821. ? [
  2822. `<button class="${state.platFilter === "all" ? "on" : ""}" onclick="setPlatFilter('all')">全部<span class="c">${all.length}</span></button>`,
  2823. ].concat(
  2824. plats.map(
  2825. (k) =>
  2826. `<button class="${state.platFilter === k ? "on" : ""}" onclick="setPlatFilter('${esc(k)}')">${PLAT_NAME(k)}<span class="c">${counts[k]}</span></button>`,
  2827. ),
  2828. )
  2829. : [];
  2830. btns.push(`<button class="done-filter ${state.doneFilter ? "on" : ""}" onclick="toggleDoneFilter()"
  2831. title="${state.doneFilter ? "当前只看已解构,点击显示全部" : "点击只看已解构"}"><span class="dot">●</span>已解构<span class="c">${doneN}</span></button>`);
  2832. tabs.innerHTML = btns.join("");
  2833. } else {
  2834. tabs.hidden = true;
  2835. }
  2836. const list = visiblePosts();
  2837. $("#p-count").textContent = all.length
  2838. ? state.platFilter === "all" && !state.doneFilter
  2839. ? `${all.length} 帖`
  2840. : `${list.length} / ${all.length} 帖`
  2841. : "";
  2842. if (!all.length) {
  2843. $("#post-list").innerHTML = '<div class="empty">该 query 暂无帖子</div>';
  2844. return;
  2845. }
  2846. if (!list.length) {
  2847. $("#post-list").innerHTML =
  2848. `<div class="empty">${state.doneFilter ? "该筛选下暂无已解构帖子" : "该渠道暂无帖子"}</div>`;
  2849. return;
  2850. }
  2851. $("#post-list").innerHTML = list
  2852. .map((p) => {
  2853. const done = state.mode === "process" ? p.has_process : p.has_tools;
  2854. const kt = (p.knowledge_type || []).map((k) => `<span class="pill">${esc(k)}</span>`).join("");
  2855. const sb =
  2856. p.overall_score != null
  2857. ? `<span class="score-badge ${scoreCls(p.overall_score)} num"
  2858. onclick="event.stopPropagation();openPostDetail('${esc(p.case_id)}')">${p.overall_score}</span>`
  2859. : "";
  2860. const thumbSrc = (p.images || []).filter(Boolean)[0];
  2861. const thumb = thumbSrc
  2862. ? imgHtml(thumbSrc, { cls: "thumb", ph: "<div class='thumb-ph'>🖼️</div>" })
  2863. : `<div class="thumb-ph" title="暂无图片">🖼️</div>`;
  2864. return `<div class="post ${p.case_id === state.caseId ? "on" : ""}" onclick="selectPost('${esc(p.case_id)}')">
  2865. ${thumb}
  2866. <div style="flex:1;min-width:0">
  2867. <div class="pt">${esc(p.title || "(无标题)")}</div>
  2868. <div class="pm">
  2869. ${PLAT_LOGO(p.platform)}
  2870. ${p.adopted ? '<span class="pill green">采纳</span>' : ""}
  2871. ${kt}
  2872. ${done ? '<span class="done-dot">● 已解构</span>' : ""}
  2873. </div>
  2874. </div>
  2875. ${sb}
  2876. </div>`;
  2877. })
  2878. .join("");
  2879. }
  2880. function toggleSel(cid, on) {
  2881. on ? state.selected.add(cid) : state.selected.delete(cid);
  2882. updateBatchBtn();
  2883. }
  2884. function updateBatchBtn() {
  2885. const b = $("#btn-batch");
  2886. b.disabled = !state.selected.size;
  2887. b.textContent = state.selected.size ? `批量解构(${state.selected.size})` : "批量解构";
  2888. }
  2889. $("#btn-batch").onclick = () => state.selected.size && startExtract([...state.selected]);
  2890. /* ════ 帖子详情弹层 ════ */
  2891. /* 得分可能是字符串("1")或数字(10),统一解析;非数值返回 null */
  2892. const scoreNum = (v) => {
  2893. const n = typeof v === "number" || (typeof v === "string" && v.trim() !== "") ? Number(v) : NaN;
  2894. return Number.isFinite(n) ? n : null;
  2895. };
  2896. function collectScores(node) {
  2897. let out = [];
  2898. if (Array.isArray(node)) node.forEach((v) => (out = out.concat(collectScores(v))));
  2899. else if (node && typeof node === "object") {
  2900. for (const [k, v] of Object.entries(node)) {
  2901. if (k === "得分") {
  2902. const n = scoreNum(v);
  2903. if (n !== null) out.push(n);
  2904. } else out = out.concat(collectScores(v));
  2905. }
  2906. }
  2907. return out;
  2908. }
  2909. function scRow(label, v, reason) {
  2910. const n = scoreNum(v);
  2911. const has = n !== null;
  2912. return `<div class="sc-row">
  2913. <span style="color:${has ? "inherit" : "var(--ink-faint)"}">${esc(label)}</span>
  2914. <div class="meter"><span style="width:${has ? Math.min(n, 10) * 10 : 0}%"></span></div>
  2915. <b class="num">${has ? n : "—"}</b>
  2916. ${reason ? `<span class="info" data-label="${esc(label)}" data-reason="${esc(reason)}" data-score="${has ? n : ""}" onclick="showScorePop(this)">ⓘ</span>` : "<span></span>"}
  2917. </div>`;
  2918. }
  2919. /* 递归渲染评分;depth>0 的分组标题用二级样式,形成层级 */
  2920. function walkScores(node, depth) {
  2921. depth = depth || 0;
  2922. let html = "";
  2923. for (const [k, v] of Object.entries(node || {})) {
  2924. if (v && typeof v === "object" && !Array.isArray(v) && "得分" in v) {
  2925. html += scRow(k, v["得分"], v["理由"]);
  2926. } else if (scoreNum(v) !== null) {
  2927. html += scRow(k, v);
  2928. } else if (v && typeof v === "object" && !Array.isArray(v)) {
  2929. const inner = walkScores(v, depth + 1);
  2930. if (inner) html += `<div class="sc-sub${depth > 0 ? " lv2" : ""}">${esc(k)}</div>` + inner;
  2931. }
  2932. }
  2933. return html;
  2934. }
  2935. /* ── 质量评分:不跟随原始 JSON 嵌套,改用 mode_procedure 的规范分组与顺序 ──
  2936. 固定维度 → 用例 → 工序 → 能力 → 工具;丢弃「字段完整性」「动态维度」等中间表头 */
  2937. const QUALITY_ORDER = {
  2938. 工序: ["流程完整性", "输入完整性", "实现完整性", "输出完整性", "泛化性"],
  2939. 能力: ["输入完整性", "实现完整性", "输出完整性", "泛化性"],
  2940. 工具: ["能力边界覆盖", "有效比较", "参数/接口具体性", "实操示例", "版本&限制"],
  2941. };
  2942. /* DFS 找到名为 name 的容器节点(工序/能力/工具) */
  2943. function findScoreNode(n, name) {
  2944. if (!n || typeof n !== "object" || Array.isArray(n)) return null;
  2945. if (name in n && n[name] && typeof n[name] === "object" && !Array.isArray(n[name])) return n[name];
  2946. for (const v of Object.values(n)) {
  2947. if (v && typeof v === "object" && !Array.isArray(v)) {
  2948. const r = findScoreNode(v, name);
  2949. if (r) return r;
  2950. }
  2951. }
  2952. return null;
  2953. }
  2954. /* 递归收集子树叶子评分 [name,{得分,理由}],打平中间分组头 */
  2955. function collectLeaves(node) {
  2956. let out = [];
  2957. for (const [k, v] of Object.entries(node || {})) {
  2958. if (v && typeof v === "object" && !Array.isArray(v) && "得分" in v) out.push([k, v]);
  2959. else if (scoreNum(v) !== null) out.push([k, { 得分: v }]);
  2960. else if (v && typeof v === "object" && !Array.isArray(v)) out = out.concat(collectLeaves(v));
  2961. }
  2962. return out;
  2963. }
  2964. function renderQuality(qnode) {
  2965. /* 固定维度/用例 的维度名全局唯一,扁平索引即可取 */
  2966. const flat = {};
  2967. (function collect(n) {
  2968. for (const [k, v] of Object.entries(n || {})) {
  2969. if (v && typeof v === "object" && !Array.isArray(v)) {
  2970. if ("得分" in v) flat[k] = v;
  2971. else collect(v);
  2972. } else if (scoreNum(v) !== null) flat[k] = { 得分: v };
  2973. }
  2974. })(qnode);
  2975. const sub = (t) => `<div class="sc-sub">${esc(t)}</div>`;
  2976. const rows = (pairs) => pairs.map(([n, o]) => scRow(n, o["得分"], o["理由"])).join("");
  2977. const pick = (names) => names.filter((n) => flat[n]).map((n) => [n, flat[n]]);
  2978. let html = "";
  2979. let p = pick(["时效性", "热度性", "评论反馈", "可复现性", "意图可控性"]); // ① 固定维度(置顶)
  2980. if (p.length) html += sub("固定维度") + rows(p);
  2981. p = pick(["真实感", "真实感 (非AI)", "真实感(非AI)", "表现力"]); // ② 用例
  2982. if (p.length) html += sub("用例") + rows(p);
  2983. for (const name of ["工序", "能力", "工具"]) {
  2984. // ③ 动态维度(按方向命名,内部规范排序)
  2985. const node = findScoreNode(qnode, name);
  2986. if (!node) continue;
  2987. const leaves = collectLeaves(node);
  2988. if (!leaves.length) continue;
  2989. const order = QUALITY_ORDER[name] || [];
  2990. leaves.sort((a, b) => (order.indexOf(a[0]) + 1 || 99) - (order.indexOf(b[0]) + 1 || 99));
  2991. html += sub(name) + rows(leaves);
  2992. }
  2993. return html || '<span style="color:var(--ink-faint)">无评分</span>';
  2994. }
  2995. /* ── 判定理由弹层:点击 ⓘ 浮现,符合当前页面样式 ── */
  2996. let _scorePop = null;
  2997. function closeScorePop() {
  2998. if (_scorePop) {
  2999. _scorePop.remove();
  3000. _scorePop = null;
  3001. }
  3002. document.removeEventListener("mousedown", _scorePopOutside, true);
  3003. }
  3004. function _scorePopOutside(e) {
  3005. if (_scorePop && !_scorePop.contains(e.target) && !e.target.classList.contains("info")) closeScorePop();
  3006. }
  3007. function showScorePop(el) {
  3008. const reopen = _scorePop && _scorePop._anchor === el;
  3009. closeScorePop();
  3010. if (reopen) return; // 再次点击同一图标 → 收起
  3011. const score = el.dataset.score;
  3012. const pop = document.createElement("div");
  3013. pop.className = "score-pop";
  3014. pop._anchor = el;
  3015. pop.innerHTML = `<div class="sp-head">
  3016. <span class="sp-tag">判定理由</span>
  3017. <span class="sp-name">${esc(el.dataset.label || "")}</span>
  3018. ${score !== "" && score != null ? `<span class="sp-score">${esc(score)}</span>` : ""}
  3019. </div>
  3020. <div class="sp-body">${esc(el.dataset.reason || "")}</div>`;
  3021. // 挂在 dialog 内,确保位于 showModal 顶层之上
  3022. (document.getElementById("post-dialog") || document.body).appendChild(pop);
  3023. _scorePop = pop;
  3024. // 定位:图标下方右对齐;越界则上翻 / 收边
  3025. const r = el.getBoundingClientRect();
  3026. let top = r.bottom + 8,
  3027. left = r.right - pop.offsetWidth;
  3028. if (left < 12) left = 12;
  3029. if (top + pop.offsetHeight > window.innerHeight - 12) top = r.top - pop.offsetHeight - 8;
  3030. if (top < 12) top = 12;
  3031. pop.style.top = top + "px";
  3032. pop.style.left = left + "px";
  3033. setTimeout(() => document.addEventListener("mousedown", _scorePopOutside, true), 0);
  3034. }
  3035. document.getElementById("post-dialog")?.addEventListener("close", closeScorePop);
  3036. /* ── 图片预览灯箱 ── */
  3037. const lb = { imgs: [], i: 0 };
  3038. function openLightbox(i) {
  3039. if (!lb.imgs.length) return;
  3040. lb.i = (i + lb.imgs.length) % lb.imgs.length;
  3041. renderLightbox();
  3042. const d = $("#lightbox");
  3043. if (!d.open) d.showModal();
  3044. }
  3045. function closeLightbox() {
  3046. const d = $("#lightbox");
  3047. if (d.open) d.close();
  3048. }
  3049. function lbStep(d) {
  3050. if (!lb.imgs.length) return;
  3051. lb.i = (lb.i + d + lb.imgs.length) % lb.imgs.length;
  3052. renderLightbox();
  3053. }
  3054. function renderLightbox() {
  3055. const url = lb.imgs[lb.i];
  3056. const el = $("#lb-img");
  3057. delete el.dataset.fb; // 切换图片前清除上一张的回退标记
  3058. el.onerror = () => imgFallback(el, imgProxy(url));
  3059. el.src = imgDirect(url); // 大图同样优先直连,失败回退代理
  3060. $("#lb-count").textContent = `${lb.i + 1} / ${lb.imgs.length}`;
  3061. const multi = lb.imgs.length > 1;
  3062. document.querySelector(".lb-prev").style.visibility = multi ? "visible" : "hidden";
  3063. document.querySelector(".lb-next").style.visibility = multi ? "visible" : "hidden";
  3064. }
  3065. document.addEventListener("keydown", (e) => {
  3066. if (!$("#lightbox").open) return;
  3067. if (e.key === "ArrowLeft") lbStep(-1);
  3068. else if (e.key === "ArrowRight") lbStep(1);
  3069. // Esc 由 <dialog> 原生处理(触发 close)
  3070. });
  3071. function openPostDetail(cid) {
  3072. const p = state.posts.find((x) => x.case_id === cid);
  3073. if (!p) return;
  3074. const e = p.llm_evaluation || {};
  3075. const meta = [];
  3076. meta.push(`${PLAT_LOGO(p.platform)}<span style="font-weight:600">${esc(PLAT_NAME(p.platform))}</span>`);
  3077. meta.push(p.adopted ? '<span class="pill green">采纳/命中</span>' : '<span class="pill">未采纳</span>');
  3078. if (p.publish_time) meta.push(`<span>${esc(String(p.publish_time).slice(0, 16))}</span>`);
  3079. if (p.like_count != null) meta.push(`<span>👍 ${p.like_count}</span>`);
  3080. if (p.quality_grade) meta.push(`<span>质量 ${esc(p.quality_grade)} ${p.quality_score ?? ""}</span>`);
  3081. if (p.url) meta.push(`<a href="${esc(p.url)}" target="_blank">原文 ↗</a>`);
  3082. meta.push(`<span class="pill" title="case_id" style="font-family:'IBM Plex Mono',ui-monospace,monospace">${esc(p.case_id || cid)}</span>`);
  3083. $("#pd-meta").innerHTML = meta.join("");
  3084. $("#pd-title").textContent = p.title || "(无标题)";
  3085. const verdict = e["判定理由"] || e["理由"] || "";
  3086. $("#pd-verdict").innerHTML = verdict ? `<div class="pd-verdict">${esc(verdict)}</div>` : "";
  3087. $("#pd-text").textContent = p.body || "(无正文)";
  3088. const imgs = (p.images || []).filter(Boolean);
  3089. $("#pd-images").innerHTML = imgs.length
  3090. ? imgs
  3091. .map(
  3092. (s, i) => imgHtml(s, { extra: `onclick="openLightbox(${i})"` }),
  3093. )
  3094. .join("")
  3095. : '<p style="color:var(--ink-faint);font-size:12px">搜索详情未返回图片。</p>';
  3096. lb.imgs = imgs;
  3097. // 视频预览:仅当 videos 有值时显示模块
  3098. const vids = (p.videos || []).filter(Boolean);
  3099. const showVids = vids.length > 0;
  3100. $("#pd-videos-title").style.display = showVids ? "" : "none";
  3101. const pdVideos = $("#pd-videos");
  3102. pdVideos.style.display = showVids ? "" : "none";
  3103. pdVideos.innerHTML = showVids
  3104. ? vids
  3105. .map(
  3106. (s) =>
  3107. `<video src="${esc(imgDirect(s))}" referrerpolicy="no-referrer" controls preload="metadata" playsinline onerror="this.onerror=null;this.src='${esc(imgProxy(s))}'"></video>`,
  3108. )
  3109. .join("")
  3110. : "";
  3111. $("#pd-tags").innerHTML = [
  3112. ...(p.knowledge_type || []).map((t) => "类型:" + t),
  3113. ...(p.found_by || []).map((q) => "命中:" + q),
  3114. ]
  3115. .map((t) => `<span class="pill">${esc(t)}</span>`)
  3116. .join("");
  3117. $("#pd-overall").innerHTML =
  3118. p.overall_score != null
  3119. ? `${p.overall_score}<span style="font-size:11px;color:var(--ink-faint);font-weight:500"> /10</span>`
  3120. : "—";
  3121. /* 评分卡:相关性 + 质量(均分 + 各维度,ⓘ hover 看理由) */
  3122. $("#pd-scores").innerHTML =
  3123. [
  3124. ["01", "相关性"],
  3125. ["02", "质量"],
  3126. ]
  3127. .map(([no, key], i) => {
  3128. const node = e[key];
  3129. if (!node) return "";
  3130. const vs = collectScores(node);
  3131. const avg = vs.length ? (vs.reduce((a, b) => a + b, 0) / vs.length).toFixed(1) : "N/A";
  3132. return `<div class="sc-card">
  3133. <div class="sc-card-head">
  3134. <span><span class="badge">${no}</span>${esc(key)}</span>
  3135. <span class="avg">均分 <b>${avg}</b>/10</span>
  3136. </div>
  3137. <div class="sc-card-body">${(key === "质量" ? renderQuality(node) : walkScores(node)) || '<span style="color:var(--ink-faint)">无评分</span>'}</div>
  3138. </div>`;
  3139. })
  3140. .join("") || '<div class="empty">无评估数据</div>';
  3141. $("#post-dialog").showModal();
  3142. }
  3143. /* ════ Dataset:右栏解构结果 ════ */
  3144. function renderExtractEmpty() {
  3145. $("#xp-head").innerHTML = '<span class="st">解构结果</span>';
  3146. $("#xp-body").innerHTML = '<div class="empty"><span class="glyph">←</span>选择一个帖子查看解构结果</div>';
  3147. }
  3148. async function selectPost(cid) {
  3149. state.caseId = cid;
  3150. state.version = null;
  3151. state.post = state.posts.find((p) => p.case_id === cid) || null;
  3152. renderPosts();
  3153. await loadExtract();
  3154. }
  3155. /* ── 解构结果:客户端缓存 + 请求竞态守卫(解决「多次点击卡顿 / 残留上一帖」)──
  3156. · _extractCache:解构数据只在「重新解构」时变(由本页 startExtract 触发,届时清缓存),
  3157. 故缓存可长留——再次点开看过的帖 0 往返、瞬时渲染。
  3158. · _extractSeq:每次发起 +1;晚到的旧响应据 seq 丢弃,杜绝快速连点时旧响应覆盖新选中。 */
  3159. const _extractCache = new Map(); // key: mode|case_id|version → {versions,data,missing}
  3160. const _extractKey = (cid, ver) => `${state.mode}|${cid}|${ver || ""}`;
  3161. let _extractSeq = 0;
  3162. function invalidateExtractCache(cid) {
  3163. for (const k of [..._extractCache.keys()]) if (k.includes(`|${cid}|`)) _extractCache.delete(k);
  3164. }
  3165. async function loadExtract() {
  3166. if (!state.caseId) return renderExtractEmpty();
  3167. const isProc = state.mode === "process";
  3168. const seq = ++_extractSeq; // 本次请求序号
  3169. const key = _extractKey(state.caseId, state.version);
  3170. // 1) 命中缓存:瞬时渲染,0 往返
  3171. const cached = _extractCache.get(key);
  3172. if (cached) return paintExtract(cached, seq);
  3173. // 2) 未命中:立即显示「原文 + loading」。关键:重写 #xp-body 会移除上一帖的 <img>,
  3174. // 浏览器随即取消其 /api/img 下载,腾出每域 ~6 条连接额度,新的 /api/extract 不再
  3175. // 排在旧图片请求后面等待——这是「多次点击要等很久」的根因。同时给出加载态,
  3176. // 不再停留在上一帖的解构结果。
  3177. renderExtractHead([], null, false, true);
  3178. $("#xp-body").innerHTML =
  3179. renderSourceBlock() +
  3180. `<div class="empty"><span class="spinner"></span>正在加载${isProc ? "工序" : "工具"}解构…</div>`;
  3181. // 版本列表 + 解构详情合一,一个请求拿全(服务端同连接两查,ETag 命中可走 304)
  3182. const url =
  3183. `/api/extract?mode=${state.mode}&case_id=` +
  3184. encodeURIComponent(state.caseId) +
  3185. (state.version ? "&version=" + encodeURIComponent(state.version) : "");
  3186. let res;
  3187. try {
  3188. res = await api(url);
  3189. } catch (e) {
  3190. if (seq !== _extractSeq) return; // 已切到别的帖,丢弃本响应
  3191. $("#xp-body").innerHTML = renderSourceBlock() + '<div class="empty">解构数据加载失败,请重试</div>';
  3192. return;
  3193. }
  3194. if (seq !== _extractSeq) return; // 晚到的旧响应:不覆盖新选中
  3195. const payload = { versions: res.versions || [], data: res.data, missing: res.missing || !res.data };
  3196. _extractCache.set(key, payload);
  3197. paintExtract(payload, seq);
  3198. }
  3199. function paintExtract({ versions, data, missing }, seq) {
  3200. if (seq !== _extractSeq) return; // 渲染前再校验(缓存命中路径也经此)
  3201. const isProc = state.mode === "process";
  3202. renderExtractHead(versions, data, missing);
  3203. const body = $("#xp-body");
  3204. if (missing || !data) {
  3205. body.innerHTML =
  3206. renderSourceBlock() +
  3207. `<div class="empty">该帖暂无${isProc ? "工序" : "工具"}解构<br><br>
  3208. <button class="btn primary" onclick="startExtract(['${esc(state.caseId)}'])">开始解构</button></div>`;
  3209. return;
  3210. }
  3211. state.version = data.version;
  3212. // 以「具体 version」补一条缓存别名,版本下拉切回时也能命中
  3213. _extractCache.set(_extractKey(state.caseId, data.version), { versions, data, missing });
  3214. syncVersionSelect();
  3215. body.innerHTML = isProc ? renderProcedures(data) : renderTools(data);
  3216. requestAnimationFrame(markSrcTextClamp);
  3217. if (isProc) requestAnimationFrame(markStepClamps);
  3218. else requestAnimationFrame(markClampedCells);
  3219. }
  3220. function renderExtractHead(versions, data, missing, loading) {
  3221. const isProc = state.mode === "process";
  3222. const title = state.post ? esc(state.post.title || state.caseId) : esc(state.caseId || "");
  3223. const opts = versions
  3224. .map(
  3225. (v, i) =>
  3226. `<option value="${esc(v.version)}">${esc(v.version)}${i === 0 ? " (最新)" : ""} · ${v.n}${isProc ? "工序" : "工具"}</option>`,
  3227. )
  3228. .join("");
  3229. const stat = loading ? "加载中…" : missing ? "未提取" : "已提取";
  3230. $("#xp-head").innerHTML = `
  3231. <span class="st">大模型${isProc ? "工序" : "工具"}:<em>${stat}</em></span>
  3232. <span style="font-size:12px;color:var(--ink-faint);max-width:330px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap" title="${title}">${title}</span>
  3233. <span class="spacer"></span>
  3234. ${versions.length ? `<select id="ver-sel">${opts}</select>` : ""}
  3235. <button class="btn sm primary" onclick="openReextractDialog()">${missing ? "提取" : "♻ 重新生成"}</button>
  3236. <button class="btn sm" onclick="showTaskPanel()" title="重新打开任务日志面板">📋 操作日志</button>`;
  3237. const vs = $("#ver-sel");
  3238. if (vs)
  3239. vs.onchange = () => {
  3240. state.version = vs.value;
  3241. loadExtract();
  3242. };
  3243. }
  3244. function syncVersionSelect() {
  3245. const vs = $("#ver-sel");
  3246. if (vs && state.version) vs.value = state.version;
  3247. }
  3248. /* ── 原文卡片:标题 + 图片缩略图(横滑、可灯箱预览)+ 正文(定高可展开),整体可收起 ── */
  3249. let srcOpen = true,
  3250. srcTextOpen = false;
  3251. function renderSourceBlock() {
  3252. const p = state.post;
  3253. if (!p || !(p.title || (p.images || []).length || p.body)) return "";
  3254. const imgs = (p.images || []).filter(Boolean);
  3255. const thumbs = imgs.length
  3256. ? `<div class="src-thumbs">${imgs
  3257. .map(
  3258. (s, i) =>
  3259. imgHtml(s, { extra: `onclick="openSrcLightbox(${i})"` }),
  3260. )
  3261. .join("")}</div>`
  3262. : "";
  3263. const body = p.body
  3264. ? `<div class="src-text${srcTextOpen ? "" : " clamp"}" id="src-text">${esc(p.body)}</div>
  3265. <button class="src-text-toggle" id="src-text-toggle" onclick="toggleSrcText()" hidden>${srcTextOpen ? "收起 ▲" : "展开 ▼"}</button>`
  3266. : "";
  3267. const link = p.url
  3268. ? `<a class="src-link" href="${esc(p.url)}" target="_blank" rel="noreferrer" onclick="event.stopPropagation()">原文 ↗</a>`
  3269. : "";
  3270. return `<div class="src-block${srcOpen ? " open" : ""}" id="src-block">
  3271. <div class="src-head" onclick="toggleSrc()">
  3272. <span class="src-caret">▸</span>
  3273. <span class="src-label">原文</span>
  3274. <span class="src-title">${esc(p.title || "(无标题)")}</span>
  3275. ${link}
  3276. <span class="src-case" title="case_id" onclick="event.stopPropagation()">${esc(p.case_id || "")}</span>
  3277. </div>
  3278. <div class="src-body">${thumbs}${body}</div>
  3279. </div>`;
  3280. }
  3281. function toggleSrc() {
  3282. srcOpen = !srcOpen;
  3283. const b = $("#src-block");
  3284. if (b) b.classList.toggle("open", srcOpen);
  3285. requestAnimationFrame(markSrcTextClamp);
  3286. }
  3287. function toggleSrcText() {
  3288. srcTextOpen = !srcTextOpen;
  3289. const t = $("#src-text"),
  3290. btn = $("#src-text-toggle");
  3291. if (t) t.classList.toggle("clamp", !srcTextOpen);
  3292. if (btn) btn.textContent = srcTextOpen ? "收起 ▲" : "展开 ▼";
  3293. }
  3294. function openSrcLightbox(i) {
  3295. lb.imgs = ((state.post && state.post.images) || []).filter(Boolean);
  3296. openLightbox(i);
  3297. }
  3298. /* 仅当正文在定高下溢出时才显示「展开」按钮(需在可见、未展开态测量) */
  3299. function markSrcTextClamp() {
  3300. const t = $("#src-text"),
  3301. btn = $("#src-text-toggle");
  3302. if (!t || !btn) return;
  3303. if (srcTextOpen) {
  3304. btn.hidden = false;
  3305. return;
  3306. }
  3307. btn.hidden = !(t.scrollHeight > t.clientHeight + 2);
  3308. }
  3309. /* ── 工序渲染 ── */
  3310. function renderProcedures(data) {
  3311. const src = data.source || {};
  3312. return (
  3313. renderSourceBlock() +
  3314. (data.procedures || [])
  3315. .map((p) => {
  3316. const d = p.declarations || {};
  3317. const ins =
  3318. (d.inputs || [])
  3319. .map(
  3320. (x) =>
  3321. `<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>` : ""}`,
  3322. )
  3323. .join("<br>") || '<span style="color:var(--ink-faint)">无</span>';
  3324. const ret = d.returns
  3325. ? `<span class="pill teal">${esc(d.returns.type || "")}</span>`
  3326. : '<span style="color:var(--ink-faint)">无</span>';
  3327. return `<div class="proc">
  3328. <div class="proc-head">
  3329. <div class="nm"><span class="pid">工序 ${esc(p.id || "")}</span>${esc(p.name || "")}</div>
  3330. ${p.purpose ? `<div class="pp">#目的:${esc(p.purpose)}</div>` : ""}
  3331. <div class="meta">
  3332. ${p.category ? `<span class="pill red">类别:${esc(p.category)}</span>` : ""}
  3333. ${src.platform ? `<span class="pill">#平台:${esc(src.platform)}</span>` : ""}
  3334. ${src.author ? `<span class="pill">#作者:${esc(src.author)}</span>` : ""}
  3335. <span class="pill">case:${esc(data.case_id)}</span>
  3336. ${(p.tools_used || []).map((t) => `<span class="pill teal">${esc(t)}</span>`).join("")}
  3337. </div>
  3338. </div>
  3339. <div class="decl">
  3340. <div><div class="dl">输入</div><div class="di">${ins}</div></div>
  3341. <div><div class="dl">返回</div><div class="di">${ret}</div></div>
  3342. </div>
  3343. ${renderSteps(p.steps || [])}
  3344. </div>`;
  3345. })
  3346. .join("") || '<div class="empty">本版本无工序</div>'
  3347. );
  3348. }
  3349. function renderSteps(steps) {
  3350. if (!steps.length) return '<div class="empty">无步骤</div>';
  3351. let rows = "";
  3352. for (const s of steps) {
  3353. const ins = s.inputs && s.inputs.length ? s.inputs : [null];
  3354. const outs = s.outputs && s.outputs.length ? s.outputs : [null];
  3355. const n = Math.max(ins.length, outs.length);
  3356. for (let i = 0; i < n; i++) {
  3357. rows += "<tr>";
  3358. if (i === 0) {
  3359. rows += `<td rowspan="${n}" class="sid">${esc(s.id || "")}</td>
  3360. <td rowspan="${n}"><div class="intent-text">${renderIntent(s.intent || s.directive || "")}</div></td>
  3361. <td rowspan="${n}">${s.effect ? `<span class="pill navy">${esc(s.effect)}</span>` : ""}</td>
  3362. <td rowspan="${n}">${esc(fmtSF(s.substance))}</td>
  3363. <td rowspan="${n}">${esc(fmtSF(s.form))}</td>`;
  3364. }
  3365. rows += ioCell(ins[i], "in");
  3366. if (i === 0) {
  3367. rows += `<td rowspan="${n}">${s.via ? `<span class="pill teal">${esc(s.via)}</span>` : ""}</td>
  3368. <td rowspan="${n}" class="vtxt">${esc(s.action || "")}</td>`;
  3369. }
  3370. rows += ioCell(outs[i], "out");
  3371. rows += "</tr>";
  3372. }
  3373. }
  3374. return `<div style="overflow-x:auto"><table class="steps">
  3375. <colgroup>
  3376. <col style="width:44px"><col style="width:200px"><col style="width:92px">
  3377. <col style="width:112px"><col style="width:100px">
  3378. <col style="width:112px"><col style="width:330px"><col style="width:92px">
  3379. <col style="width:118px"><col style="width:130px">
  3380. <col style="width:112px"><col style="width:360px"><col style="width:110px">
  3381. </colgroup>
  3382. <thead>
  3383. <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>
  3384. <tr>
  3385. <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>
  3386. <th class="h-in2">类型</th><th class="h-in2">值</th><th class="h-in2">来源</th>
  3387. <th class="h-im2">外部工具</th><th class="h-im2">动作</th>
  3388. <th class="h-out2">类型</th><th class="h-out2">值</th><th class="h-out2">去处</th>
  3389. </tr>
  3390. </thead><tbody>${rows}</tbody></table></div>`;
  3391. }
  3392. function fmtSF(v) {
  3393. return v == null ? "" : Array.isArray(v) ? v.join("、") : v;
  3394. }
  3395. function ioCell(x, kind) {
  3396. const cls = kind === "in" ? "c-in" : "c-out";
  3397. if (!x) return `<td class="${cls}"></td><td class="${cls}"></td><td class="${cls}"></td>`;
  3398. const inf = x.inferred ? ` inf" title="推断理由:${esc(x.inferred_reason || "模型推断补全")}` : "";
  3399. const badge = x.inferred ? '<span class="ib">推</span>' : "";
  3400. return `<td class="${cls}"><span class="pill ${kind === "in" ? "amber" : "blue"}">${esc(x.type || "")}</span></td>
  3401. <td class="${cls}${inf}">${badge}<div class="clamp-val" onclick="toggleClampVal(this)"><span class="vtxt">${esc(x.value || "")}</span></div></td>
  3402. <td class="${cls}"><span class="anchor">${esc(x.anchor || "")}</span></td>`;
  3403. }
  3404. /* 点击「值」单元格展开/收起(仅在内容溢出、已标记 clampable 时生效) */
  3405. function toggleClampVal(el) {
  3406. if (!el.classList.contains("clampable") && !el.classList.contains("open")) return;
  3407. el.classList.toggle("open");
  3408. }
  3409. /* 渲染后标记真正溢出 4 行的「值」单元格:先套限高再测量,溢出才保留 clampable */
  3410. function markStepClamps() {
  3411. document.querySelectorAll("#xp-body .steps .clamp-val").forEach((el) => {
  3412. if (el.classList.contains("open")) return;
  3413. el.classList.add("clampable");
  3414. if (el.scrollHeight <= el.clientHeight + 2) el.classList.remove("clampable");
  3415. });
  3416. }
  3417. /* ── 工具渲染(表格,移植自 fixed_query_eval renderToolTable)── */
  3418. const DASH = '<span class="dash">—</span>';
  3419. function _toolCell(v) {
  3420. if (v === null || v === undefined || v === "" || (Array.isArray(v) && !v.length)) return DASH;
  3421. if (Array.isArray(v)) return "<ul>" + v.map((x) => `<li>${esc(String(x))}</li>`).join("") + "</ul>";
  3422. return esc(String(v));
  3423. }
  3424. function _scopeCell(v) {
  3425. /* 作用域是 JSON 数组:按「、」拼接成短语,不出列表 */
  3426. if (v === null || v === undefined || (Array.isArray(v) && !v.length) || v === "") return DASH;
  3427. return esc(Array.isArray(v) ? v.join("、") : String(v));
  3428. }
  3429. function _ttCell(inner, clampable) {
  3430. return clampable ? `<div class="tcell" onclick="this.classList.toggle('open')">${inner}</div>` : inner;
  3431. }
  3432. function _toolCellContent(c, t) {
  3433. let inner,
  3434. cls = "",
  3435. clampable = true,
  3436. style = "";
  3437. if (c === "工具名称") {
  3438. cls = "col-tool";
  3439. clampable = false;
  3440. inner = `🔧 ${esc(t[c] || "(未命名)")}`;
  3441. } else if (c === "来源链接") {
  3442. clampable = false;
  3443. inner = t[c]
  3444. ? `<a href="${esc(t[c])}" target="_blank" style="color:#176d64;font-weight:600;">🔗 打开</a>`
  3445. : DASH;
  3446. } else if (c === "创作层级") {
  3447. clampable = false;
  3448. inner = t[c]
  3449. ? `<span class="layer-badge ${t[c] === "制作层" ? "make" : "create"}">${esc(t[c])}</span>`
  3450. : DASH;
  3451. } else if (c === "实质作用域" || c === "形式作用域") {
  3452. inner = _scopeCell(t[c]);
  3453. } else {
  3454. inner = _toolCell(t[c]);
  3455. }
  3456. if (["输入", "输出", "用法", "缺点"].includes(c)) style = "max-width:240px;";
  3457. else if (c === "实质作用域" || c === "形式作用域") style = "max-width:170px;";
  3458. else if (!clampable) style = "white-space:nowrap;";
  3459. return { inner, cls, clampable, style };
  3460. }
  3461. function _td(c, t, rowspan) {
  3462. const { inner, cls, clampable, style } = _toolCellContent(c, t);
  3463. const rs = rowspan > 1 ? ` rowspan="${rowspan}"` : "";
  3464. return `<td class="${cls}" style="${style}"${rs}>${_ttCell(inner, clampable)}</td>`;
  3465. }
  3466. function _caseTd(cse, key) {
  3467. const v = cse && cse[key] != null && cse[key] !== "" ? esc(String(cse[key])) : DASH;
  3468. return `<td class="col-case" style="max-width:210px;">${_ttCell(v, true)}</td>`;
  3469. }
  3470. function renderTools(data) {
  3471. const tools = data.tools || [];
  3472. if (!tools.length) return renderSourceBlock() + '<div class="empty">本版本无工具</div>';
  3473. /* 案例 group(输入/输出/效果)放在 用法 后、缺点 前;用 colspan/rowspan 做两层表头 */
  3474. const before = ["工具名称", "创作层级", "实质作用域", "形式作用域", "输入", "输出", "用法"];
  3475. const after = ["缺点", "来源链接", "最新更新时间"];
  3476. const thead = `<thead>
  3477. <tr>
  3478. ${before.map((c) => `<th rowspan="2">${c}</th>`).join("")}
  3479. <th colspan="3" class="th-group">案例</th>
  3480. ${after.map((c) => `<th rowspan="2">${c}</th>`).join("")}
  3481. </tr>
  3482. <tr>${["输入", "输出", "效果"].map((c) => `<th class="th-sub">${c}</th>`).join("")}</tr>
  3483. </thead>`;
  3484. const rows = tools
  3485. .map((t, ti) => {
  3486. const cases = Array.isArray(t["案例"]) && t["案例"].length ? t["案例"] : [null];
  3487. const K = cases.length;
  3488. const par = ti % 2 ? "tr-b" : "tr-a";
  3489. return cases
  3490. .map((cse, i) => {
  3491. const caseTds = `${_caseTd(cse, "输入")}${_caseTd(cse, "输出")}${_caseTd(cse, "效果")}`;
  3492. if (i === 0) {
  3493. return `<tr class="${par}">${before.map((c) => _td(c, t, K)).join("")}${caseTds}${after.map((c) => _td(c, t, K)).join("")}</tr>`;
  3494. }
  3495. return `<tr class="${par}">${caseTds}</tr>`;
  3496. })
  3497. .join("");
  3498. })
  3499. .join("");
  3500. return (
  3501. renderSourceBlock() +
  3502. `<div class="mw-ttwrap"><table class="mw-tt">${thead}<tbody>${rows}</tbody></table></div>`
  3503. );
  3504. }
  3505. /* 渲染后标记真正溢出的单元格(才显示蒙版+可点击) */
  3506. function markClampedCells() {
  3507. document.querySelectorAll("#xp-body .mw-tt .tcell").forEach((el) => {
  3508. if (!el.classList.contains("open") && el.scrollHeight > el.clientHeight + 2) el.classList.add("clamped");
  3509. else if (el.scrollHeight <= el.clientHeight + 2) el.classList.remove("clamped");
  3510. });
  3511. }
  3512. /* ════ 重新解构 · 编辑 Prompt 弹框 ════ */
  3513. async function openReextractDialog() {
  3514. if (!state.caseId) {
  3515. toast("请先选择帖子", "info");
  3516. return;
  3517. }
  3518. const isProc = state.mode === "process";
  3519. const dlg = $("#reextract-dlg"),
  3520. sel = $("#rx-model"),
  3521. ta = $("#rx-prompt"),
  3522. save = $("#rx-save");
  3523. sel.innerHTML = (isProc ? MODELS_PROC : MODELS_TOOL)
  3524. .map((m) => `<option>${m}</option>`)
  3525. .join("");
  3526. ta.value = "加载中…";
  3527. ta.disabled = save.disabled = true;
  3528. dlg.showModal();
  3529. try {
  3530. const r = await api(`/api/extract_prompt?mode=${state.mode}`);
  3531. ta.value = r.prompt || "";
  3532. } catch (e) {
  3533. ta.value = "";
  3534. toast("加载 Prompt 失败:" + (e.body?.error || e.status), "error");
  3535. } finally {
  3536. ta.disabled = save.disabled = false;
  3537. }
  3538. }
  3539. async function saveReextract() {
  3540. const cid = state.caseId;
  3541. if (!cid) return;
  3542. const model = $("#rx-model").value,
  3543. prompt = $("#rx-prompt").value;
  3544. $("#reextract-dlg").close();
  3545. // 临时 prompt 覆盖 + force 重解构(仅本次生效,不改默认 Prompt)
  3546. await startExtract([cid], { model, prompt, force: true });
  3547. }
  3548. /* ════ 解构任务 ════ */
  3549. async function startExtract(caseIds, opts = {}) {
  3550. if (!state.queryId || !caseIds.length) return;
  3551. const isProc = state.mode === "process";
  3552. const model = opts.model || (isProc ? MODELS_PROC[0] : MODELS_TOOL[0]);
  3553. try {
  3554. const body = { query_id: state.queryId, case_ids: caseIds, model };
  3555. if (opts.prompt != null) body.prompt = opts.prompt; // 临时 prompt 覆盖(仅本次)
  3556. if (opts.force) body.force = true; // 换 prompt/模型重解构需跳过去重
  3557. const r = await api(`/api/extract_${isProc ? "process" : "tools"}`, {
  3558. method: "POST",
  3559. body: JSON.stringify(body),
  3560. });
  3561. // 全部正在解构中(被认领跳过):没有 task_id,提示一下即可,别去轮询空任务
  3562. if (!r.task_id) {
  3563. toast(r.note || "所选帖子正在解构中,已跳过", "info");
  3564. return;
  3565. }
  3566. if ((r.skipped || []).length) toast(`${r.skipped.length} 帖正在解构中,已跳过`, "info");
  3567. showTask(`${isProc ? "工序" : "工具"}解构 · ${caseIds.length} 帖`, r.task_id, async () => {
  3568. state.selected.clear();
  3569. caseIds.forEach(invalidateExtractCache); // 重新解构后数据已变,清这些帖的缓存
  3570. await selectQuery(state.queryId);
  3571. if (caseIds.includes(state.caseId)) {
  3572. /* selectQuery 清了 caseId,恢复选中 */
  3573. }
  3574. if (caseIds.length === 1) {
  3575. state.caseId = caseIds[0];
  3576. state.version = null;
  3577. renderPosts();
  3578. await loadExtract();
  3579. }
  3580. });
  3581. } catch (e) {
  3582. toast("任务启动失败:" + (e.body?.error || e.status), "error");
  3583. }
  3584. }
  3585. /* ════ 任务面板(✕ 只隐藏;「操作日志」按钮可随时唤回)════ */
  3586. let pollTimer = null,
  3587. hasTask = false;
  3588. function showTask(title, taskId, onDone) {
  3589. hasTask = true;
  3590. $("#task-panel").hidden = false;
  3591. $("#task-title").textContent = title;
  3592. $("#task-dot").className = "dot";
  3593. $("#task-log").textContent = "启动中…";
  3594. clearTimeout(pollTimer);
  3595. const poll = async () => {
  3596. let t;
  3597. try {
  3598. t = await api("/api/task_status?task_id=" + encodeURIComponent(taskId));
  3599. } catch (e) {
  3600. $("#task-log").textContent = "状态查询失败";
  3601. return;
  3602. }
  3603. const log = $("#task-log");
  3604. log.textContent = t.log_tail || "(暂无日志)";
  3605. log.scrollTop = log.scrollHeight;
  3606. if (t.status === "running") {
  3607. pollTimer = setTimeout(poll, 2000);
  3608. return;
  3609. }
  3610. $("#task-dot").className = "dot " + t.status;
  3611. $("#task-title").textContent = title + (t.status === "done" ? " · 完成" : " · 失败");
  3612. if (t.status === "done" && onDone) onDone();
  3613. };
  3614. poll();
  3615. }
  3616. /* ✕ 只隐藏面板,轮询照跑(任务完成后回调依然触发) */
  3617. function hideTask() {
  3618. $("#task-panel").hidden = true;
  3619. }
  3620. function showTaskPanel() {
  3621. if (!hasTask) return toast("本次会话还没有任务日志", "warn");
  3622. $("#task-panel").hidden = false;
  3623. const log = $("#task-log");
  3624. log.scrollTop = log.scrollHeight;
  3625. }
  3626. /* ════ Query 规则组织器 ════ */
  3627. // 扁平维度词表(移植自 query-builder.html DIMS);实质/形式 改为接口下钻,不在此。
  3628. const QR_FLAT = [
  3629. { id: "tool_type", label: "工具类型", items: ["AI", "桌面 APP", "云端 Web", "API·CLI", "插件扩展"] },
  3630. { id: "modality", label: "模态", items: ["图片", "视频"] },
  3631. { id: "suffix", label: "后缀", items: ["怎么做"] },
  3632. ];
  3633. const QR_TREE = [
  3634. { id: "substance", label: "实质", source: "实质" },
  3635. { id: "form", label: "形式", source: "形式" },
  3636. ];
  3637. const qrState = {
  3638. flat: { tool_type: null, modality: null, suffix: null },
  3639. treePath: { substance: [], form: [] }, // 实质/形式 选中 name 路径(仅作 Sonnet 上下文)
  3640. treeData: { substance: null, form: null },
  3641. axisPath: { action: [], type: [] }, // 动作/类型 筛选路径(l1/l2/叶子,来自 matrix,筛表显示)
  3642. matrix: null, // /api/query_matrix
  3643. scores: null, // 最近一次评分结果 cells
  3644. };
  3645. function qrChip(label, active, on, cls) {
  3646. const b = document.createElement("button");
  3647. b.className = "chip" + (cls ? " " + cls : "") + (active ? " on" : "");
  3648. b.textContent = label;
  3649. b.onclick = on;
  3650. return b;
  3651. }
  3652. function qrRow(root, labtxt) {
  3653. const row = document.createElement("div");
  3654. row.className = "qr-row";
  3655. row.innerHTML = `<span class="qr-lab">${labtxt}</span>`;
  3656. const wrap = document.createElement("span");
  3657. wrap.className = "qr-chips";
  3658. row.appendChild(wrap);
  3659. root.appendChild(row);
  3660. return wrap;
  3661. }
  3662. // 动作/类型 三级(l1/l2/叶子)取自 matrix items 的 l1/l2/name
  3663. function qrAxisLevelOptions(items, prefix) {
  3664. if (prefix.length === 0) return [...new Set(items.map((x) => x.l1))];
  3665. if (prefix.length === 1) return [...new Set(items.filter((x) => x.l1 === prefix[0]).map((x) => x.l2))];
  3666. return items.filter((x) => x.l1 === prefix[0] && x.l2 === prefix[1]).map((x) => x.name);
  3667. }
  3668. function qrAxisMatch(item, path) {
  3669. if (path[0] && item.l1 !== path[0]) return false;
  3670. if (path[1] && item.l2 !== path[1]) return false;
  3671. if (path[2] && item.name !== path[2]) return false;
  3672. return true;
  3673. }
  3674. function renderQrDims() {
  3675. const root = $("#qr-dims");
  3676. root.innerHTML = "";
  3677. // 扁平维度(工具类型/模态/后缀):拼词上下文
  3678. QR_FLAT.forEach((d) => {
  3679. const wrap = qrRow(root, `· ${d.label}`);
  3680. wrap.appendChild(qrChip("无", qrState.flat[d.id] == null, () => { qrState.flat[d.id] = null; renderQrDims(); renderQrTable(); }));
  3681. d.items.forEach((it) =>
  3682. wrap.appendChild(qrChip(it, qrState.flat[d.id] === it, () => { qrState.flat[d.id] = it; renderQrDims(); renderQrTable(); })));
  3683. });
  3684. // 实质/形式 接口下钻:仅作 Sonnet 上下文,不拼词、不筛表
  3685. QR_TREE.forEach((d) => {
  3686. const path = qrState.treePath[d.id];
  3687. let level = qrState.treeData[d.id] ? qrState.treeData[d.id].tree : [];
  3688. for (let depth = 0; ; depth++) {
  3689. const wrap = qrRow(root, depth === 0 ? `· ${d.label}` : "");
  3690. wrap.appendChild(qrChip("无", path.length === depth, () => { qrState.treePath[d.id] = path.slice(0, depth); renderQrDims(); }));
  3691. (level || []).forEach((node) =>
  3692. wrap.appendChild(qrChip(node.name, path[depth] === node.name,
  3693. () => { qrState.treePath[d.id] = [...path.slice(0, depth), node.name]; renderQrDims(); })));
  3694. const sel = (level || []).find((n) => n.name === path[depth]);
  3695. if (!sel || !(sel.children && sel.children.length)) break;
  3696. level = sel.children;
  3697. }
  3698. });
  3699. // 动作/类型 下钻(来自 matrix l1/l2):筛选表格显示
  3700. if (qrState.matrix) {
  3701. [{ id: "action", label: "动作", items: qrState.matrix.actions },
  3702. { id: "type", label: "类型", items: qrState.matrix.types }].forEach((d) => {
  3703. const path = qrState.axisPath[d.id];
  3704. for (let depth = 0; depth <= 2; depth++) {
  3705. const opts = qrAxisLevelOptions(d.items, path.slice(0, depth));
  3706. if (!opts.length) break;
  3707. const wrap = qrRow(root, depth === 0 ? `· ${d.label}` : "");
  3708. wrap.appendChild(qrChip("无", path.length === depth,
  3709. () => { qrState.axisPath[d.id] = path.slice(0, depth); renderQrDims(); renderQrTable(); }, "axis"));
  3710. opts.forEach((name) =>
  3711. wrap.appendChild(qrChip(name, path[depth] === name,
  3712. () => { qrState.axisPath[d.id] = [...path.slice(0, depth), name]; renderQrDims(); renderQrTable(); }, "axis")));
  3713. if (path[depth] == null) break; // 未选中本层 → 不展开下一层
  3714. }
  3715. });
  3716. }
  3717. }
  3718. async function qrOpen() {
  3719. qrClosePop();
  3720. renderQrDims();
  3721. // 并行拉矩阵 + 两棵分类树(接口挂则该维度降级:提示不可选)
  3722. try { qrState.matrix = qrState.matrix || await api("/api/query_matrix"); }
  3723. catch (e) { return toast("内容树矩阵加载失败", "error"); }
  3724. for (const d of QR_TREE) {
  3725. if (qrState.treeData[d.id]) continue;
  3726. try { qrState.treeData[d.id] = await api("/api/category_tree?source_type=" + encodeURIComponent(d.source)); }
  3727. catch (e) { toast(`${d.label} 接口不可达,该维度暂不可选`, "warn"); }
  3728. }
  3729. renderQrDims();
  3730. renderQrTable();
  3731. }
  3732. // 单格 query = [工具类型] 动作叶 类型叶 [模态] [后缀](与后端 query_score._build_cells 一致)
  3733. function qrCellQuery(action, type) {
  3734. const f = qrState.flat;
  3735. return [f.tool_type, action, type, f.modality, f.suffix].filter((x) => x && x !== "无").join(" ");
  3736. }
  3737. function renderQrTable() {
  3738. const m = qrState.matrix;
  3739. if (!m) return;
  3740. const { actions, types, matrix } = m;
  3741. const sc = qrState.scores; // {"ai_ti":{keep,score,rewrite,...}}
  3742. // 按 动作/类型 筛选路径过滤可见行列(保留原始索引 ai/ti 供评分键 ai_ti)
  3743. const aIdx = actions.map((_, i) => i).filter((i) => qrAxisMatch(actions[i], qrState.axisPath.action));
  3744. const tIdx = types.map((_, i) => i).filter((i) => qrAxisMatch(types[i], qrState.axisPath.type));
  3745. let html = '<table class="qr-tab"><thead>';
  3746. html += '<tr><th class="qr-corner" rowspan="2">类型 \\ 动作</th>';
  3747. const groups = [];
  3748. aIdx.forEach((ai) => {
  3749. const l1 = actions[ai].l1;
  3750. const last = groups[groups.length - 1];
  3751. if (last && last.l1 === l1) last.span++;
  3752. else groups.push({ l1, span: 1 });
  3753. });
  3754. groups.forEach((g) => { html += `<th colspan="${g.span}" class="qr-gh">${g.l1}</th>`; });
  3755. html += "</tr><tr>";
  3756. aIdx.forEach((ai) => { html += `<th class="qr-ah">${actions[ai].name}</th>`; });
  3757. html += "</tr></thead><tbody>";
  3758. let curL1 = null;
  3759. tIdx.forEach((ti) => {
  3760. const t = types[ti];
  3761. if (t.l1 !== curL1) {
  3762. curL1 = t.l1;
  3763. html += `<tr><td class="qr-tl1" colspan="${aIdx.length + 1}">${t.l1}</td></tr>`;
  3764. }
  3765. html += `<tr><th class="qr-th">${t.name}</th>`;
  3766. aIdx.forEach((ai) => {
  3767. const tier = (matrix[ai][ti] || {}).tier || 0;
  3768. const q = qrCellQuery(actions[ai].name, t.name);
  3769. const v = sc ? sc[`${ai}_${ti}`] : null;
  3770. const keep = v && v.keep;
  3771. const cls = `qr-c t${tier}` + (tier === 0 ? " dead" : "") + (keep ? " keep" : "");
  3772. const badge = keep && v.score != null ? `<i class="qr-bd">${v.score}</i>` : "";
  3773. html += `<td class="${cls}" data-ai="${ai}" data-ti="${ti}">${q}${badge}</td>`;
  3774. });
  3775. html += "</tr>";
  3776. });
  3777. html += "</tbody></table>";
  3778. $("#qr-table-wrap").innerHTML = html;
  3779. }
  3780. function qrSelBody() {
  3781. return {
  3782. tool_type: qrState.flat.tool_type || "",
  3783. modality: qrState.flat.modality || "",
  3784. suffix: qrState.flat.suffix || "",
  3785. substance_path: qrState.treePath.substance,
  3786. form_path: qrState.treePath.form,
  3787. };
  3788. }
  3789. async function qrLoadScores(sel) {
  3790. const r = await api("/api/query_score?sel=" + encodeURIComponent(sel));
  3791. if (r && r.pending) return false;
  3792. qrState.scores = r.cells || {};
  3793. renderQrTable();
  3794. const kept = Object.values(qrState.scores).filter((v) => v.keep).length;
  3795. $("#qr-hint").textContent = `评估完成:keep ${kept} 格 · $${r.cost_usd ?? "?"}`;
  3796. $("#qr-search-all").hidden = kept === 0;
  3797. return true;
  3798. }
  3799. $("#qr-score").onclick = async () => {
  3800. renderQrTable(); // 先按当前 chips 刷新拼词
  3801. $("#qr-hint").textContent = "提交评分…";
  3802. let r;
  3803. try { r = await api("/api/query_score", { method: "POST", body: JSON.stringify(qrSelBody()) }); }
  3804. catch (e) { return toast("评分启动失败:" + (e.body?.error || e.status), "error"); }
  3805. if (r.cached) { await qrLoadScores(r.sel); return; }
  3806. showTask("Query 评分 · 643 格", r.task_id, async () => { await qrLoadScores(r.sel); });
  3807. };
  3808. async function qrRunSearch(query) {
  3809. const body = { query, platforms: "xhs,gzh", max_count: 20 }; // 方向无关,标签自动路由
  3810. const r = await api("/api/run_search", { method: "POST", body: JSON.stringify(body) });
  3811. return r; // {task_id, query_id}
  3812. }
  3813. // 点高亮格 → 气泡显示评分/理由 + 发起搜索/复制(不再用浏览器原生 confirm)
  3814. function qrClosePop() { $("#qr-pop").hidden = true; }
  3815. function qrShowPop(td, v) {
  3816. const pop = $("#qr-pop");
  3817. const query = v.rewrite || v.query;
  3818. const orig = v.rewrite && v.rewrite !== v.query ? `<div class="orig">原: ${v.query}</div>` : "";
  3819. const tier = td.classList.contains("t3") ? 3 : td.classList.contains("t2") ? 2 : td.classList.contains("t1") ? 1 : 0;
  3820. pop.innerHTML =
  3821. `<div class="q">${query}</div>${orig}` +
  3822. `<div class="sc"><b>${v.score ?? "?"}</b><span class="dim">人话 ${v.natural ?? "?"} · 可搜 ${v.findable ?? "?"} · 价值 ${v.useful ?? "?"} · tier ${tier}</span></div>` +
  3823. `<div class="rsn">${v.reason || "(无理由)"}</div>` +
  3824. `<div class="acts"><button class="btn seal" id="qr-pop-go">发起搜索</button><button class="btn" id="qr-pop-copy">复制</button></div>`;
  3825. pop.hidden = false;
  3826. const r = td.getBoundingClientRect(), pw = 300, ph = pop.offsetHeight || 150;
  3827. let left = r.left, top = r.bottom + 6;
  3828. if (left + pw > window.innerWidth - 10) left = window.innerWidth - pw - 10;
  3829. if (top + ph > window.innerHeight - 10) top = r.top - ph - 6;
  3830. pop.style.left = Math.max(10, left) + "px";
  3831. pop.style.top = Math.max(10, top) + "px";
  3832. $("#qr-pop-go").onclick = async () => {
  3833. qrClosePop();
  3834. try { const rr = await qrRunSearch(query); showTask(`搜索 · ${rr.query_id} ${query}`, rr.task_id, null); }
  3835. catch (err) { toast("搜索启动失败:" + (err.body?.error || err.status), "error"); }
  3836. };
  3837. $("#qr-pop-copy").onclick = () => { navigator.clipboard && navigator.clipboard.writeText(query); toast("已复制", "info", 1200); };
  3838. }
  3839. $("#qr-table-wrap").onclick = (e) => {
  3840. const td = e.target.closest("td.qr-c.keep");
  3841. if (!td) return;
  3842. const v = qrState.scores && qrState.scores[`${td.dataset.ai}_${td.dataset.ti}`];
  3843. if (v) qrShowPop(td, v);
  3844. };
  3845. // 点气泡外/表格空白处 关闭气泡
  3846. $("#qr-modal").addEventListener("click", (e) => {
  3847. if (!e.target.closest("#qr-pop") && !e.target.closest("td.qr-c.keep")) qrClosePop();
  3848. });
  3849. // 搜全部达标:逐格起任务(朴素循环,失败不阻断)
  3850. $("#qr-search-all").onclick = async () => {
  3851. const keeps = Object.entries(qrState.scores || {}).filter(([, v]) => v.keep);
  3852. if (!keeps.length) return;
  3853. if (!confirm(`将对 ${keeps.length} 个达标 query 各起一次搜索(小红书+公众号 各20),确认?`)) return;
  3854. let ok = 0;
  3855. for (const [, v] of keeps) {
  3856. try { await qrRunSearch(v.rewrite || v.query); ok++; }
  3857. catch (e) { /* 单格失败不阻断 */ }
  3858. }
  3859. toast(`已发起 ${ok}/${keeps.length} 个搜索任务`, "info");
  3860. };
  3861. /* ════ 新建搜索 ════ */
  3862. /* 渠道下拉多选(选项同 search_eval:小红书/知乎/公众号/抖音/视频号/YouTube) */
  3863. const CHANNELS = [
  3864. { key: "xhs", name: "小红书", on: true },
  3865. { key: "zhihu", name: "知乎", on: true },
  3866. { key: "gzh", name: "公众号" },
  3867. { key: "douyin", name: "抖音" },
  3868. { key: "sph", name: "视频号" },
  3869. { key: "youtube", name: "YouTube" },
  3870. ];
  3871. $("#s-plat-panel").innerHTML = CHANNELS.map(
  3872. (c) => `
  3873. <label class="dd-opt ${c.on ? "sel" : ""}">
  3874. <input type="checkbox" value="${c.key}" ${c.on ? "checked" : ""}>${c.name}
  3875. </label>`,
  3876. ).join("");
  3877. function selectedPlatforms() {
  3878. return [...document.querySelectorAll("#s-plat-panel input:checked")].map((x) => x.value);
  3879. }
  3880. function syncPlatBtn() {
  3881. const names = [...document.querySelectorAll("#s-plat-panel input:checked")].map(
  3882. (x) => CHANNELS.find((c) => c.key === x.value).name,
  3883. );
  3884. $("#s-plat-btn").innerHTML =
  3885. `<span>${names.length ? esc(names.join("、")) : "选择渠道"}</span><span class="dd-arrow">▾</span>`;
  3886. }
  3887. $("#s-plat-btn").onclick = (e) => {
  3888. e.stopPropagation();
  3889. $("#s-plat-panel").hidden = !$("#s-plat-panel").hidden;
  3890. };
  3891. $("#s-plat-panel").onclick = (e) => e.stopPropagation();
  3892. $("#s-plat-panel").addEventListener("change", (e) => {
  3893. e.target.closest(".dd-opt").classList.toggle("sel", e.target.checked);
  3894. syncPlatBtn();
  3895. });
  3896. document.addEventListener("click", () => {
  3897. $("#s-plat-panel").hidden = true;
  3898. });
  3899. syncPlatBtn();
  3900. $("#btn-new-search").onclick = () => {
  3901. $("#s-mode").value = state.mode === "process" ? "工序" : "工具"; // 默认跟随当前子模式
  3902. $("#search-modal").hidden = false;
  3903. $("#s-query").focus();
  3904. };
  3905. $("#search-modal").onclick = (e) => {
  3906. if (e.target === $("#search-modal")) $("#search-modal").hidden = true;
  3907. };
  3908. $("#s-go").onclick = async () => {
  3909. const query = $("#s-query").value.trim();
  3910. if (!query) return toast("请填写 query", "warn");
  3911. const plats = selectedPlatforms();
  3912. if (!plats.length) return toast("请至少选择一个检索渠道", "warn");
  3913. const body = {
  3914. query,
  3915. synonyms: $("#s-syn").value.trim(),
  3916. mode_type: $("#s-mode").value,
  3917. platforms: plats.join(","),
  3918. max_count: parseInt($("#s-max").value) || 10,
  3919. };
  3920. try {
  3921. const r = await api("/api/run_search", { method: "POST", body: JSON.stringify(body) });
  3922. $("#search-modal").hidden = true;
  3923. showTask(`搜索 · ${r.query_id} ${query}`, r.task_id, async () => {
  3924. /* 搜索结果落在 s-mode 对应的表,完成后切到对应子模式再选中 */
  3925. const m = body.mode_type === "工具" ? "tools" : "process";
  3926. if (state.mode !== m) {
  3927. state.mode = m;
  3928. $("#m-process").classList.toggle("on", m === "process");
  3929. $("#m-tools").classList.toggle("on", m === "tools");
  3930. }
  3931. await loadQueries();
  3932. selectQuery(r.query_id);
  3933. });
  3934. } catch (e) {
  3935. toast("搜索启动失败:" + (e.body?.error || e.status), "error");
  3936. }
  3937. };
  3938. /* ════ 工序/工具子模式 ════ */
  3939. $("#m-process").onclick = () => setMode("process");
  3940. $("#m-tools").onclick = () => setMode("tools");
  3941. function setMode(m) {
  3942. if (state.mode === m) return;
  3943. state.mode = m;
  3944. state.version = null;
  3945. /* 工序/工具是两张独立搜索表,切换时整体重置三栏 */
  3946. state.queryId = null;
  3947. state.caseId = null;
  3948. state.post = null;
  3949. state.posts = [];
  3950. state.selected.clear();
  3951. state.platFilter = "all";
  3952. $("#m-process").classList.toggle("on", m === "process");
  3953. $("#m-tools").classList.toggle("on", m === "tools");
  3954. $("#plat-tabs").hidden = true;
  3955. $("#p-count").textContent = "";
  3956. $("#post-list").innerHTML = '<div class="empty"><span class="glyph">←</span>先选择左侧 query</div>';
  3957. renderExtractEmpty();
  3958. loadQueries();
  3959. }
  3960. $("#btn-query-rule").onclick = () => { $("#qr-modal").hidden = false; qrOpen(); };
  3961. $("#qr-close").onclick = () => { $("#qr-modal").hidden = true; };
  3962. $("#qr-modal").onclick = (e) => { if (e.target === $("#qr-modal")) $("#qr-modal").hidden = true; };
  3963. window.addEventListener("resize", () => chartRefs.forEach((c) => c.resize()));
  3964. route();
  3965. </script>
  3966. </body>
  3967. </html>