index.html 132 KB

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