index.html 122 KB

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