index.html 149 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190
  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. .pd-videos iframe {
  1365. width: 100%;
  1366. aspect-ratio: 16 / 9;
  1367. border: 1px solid var(--line);
  1368. border-radius: 10px;
  1369. background: #000;
  1370. }
  1371. .pd-videos .vid-fallback {
  1372. display: block;
  1373. padding: 10px 12px;
  1374. font-size: 12px;
  1375. color: var(--accent, #2d6cdf);
  1376. border: 1px dashed var(--line);
  1377. border-radius: 10px;
  1378. text-decoration: none;
  1379. }
  1380. /* ── 图片预览灯箱 ── */
  1381. dialog.lightbox {
  1382. position: fixed;
  1383. inset: 0;
  1384. width: 100%;
  1385. height: 100%;
  1386. max-width: 100%;
  1387. max-height: 100%;
  1388. margin: 0;
  1389. padding: 40px 72px;
  1390. border: none;
  1391. gap: 18px;
  1392. align-items: center;
  1393. justify-content: center;
  1394. background: rgba(20, 20, 22, 0.86);
  1395. backdrop-filter: blur(2px);
  1396. overflow: hidden;
  1397. }
  1398. dialog.lightbox[open] {
  1399. display: flex;
  1400. }
  1401. dialog.lightbox::backdrop {
  1402. background: rgba(20, 20, 22, 0.5);
  1403. }
  1404. .lb-stage {
  1405. margin: 0;
  1406. max-width: 100%;
  1407. max-height: 100%;
  1408. display: flex;
  1409. flex-direction: column;
  1410. align-items: center;
  1411. gap: 12px;
  1412. }
  1413. .lb-stage img {
  1414. max-width: min(1100px, 86vw);
  1415. max-height: 82vh;
  1416. object-fit: contain;
  1417. border-radius: 8px;
  1418. box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
  1419. background: #2a2a2c;
  1420. }
  1421. .lb-stage figcaption {
  1422. color: rgba(255, 255, 255, 0.78);
  1423. font-size: 13px;
  1424. letter-spacing: 0.5px;
  1425. }
  1426. .lb-nav {
  1427. flex: 0 0 auto;
  1428. width: 46px;
  1429. height: 46px;
  1430. border-radius: 50%;
  1431. border: none;
  1432. background: rgba(255, 255, 255, 0.12);
  1433. color: #fff;
  1434. font-size: 28px;
  1435. line-height: 1;
  1436. cursor: pointer;
  1437. transition: 0.15s;
  1438. }
  1439. .lb-nav:hover {
  1440. background: rgba(255, 255, 255, 0.26);
  1441. }
  1442. .lb-close {
  1443. position: absolute;
  1444. top: 20px;
  1445. right: 24px;
  1446. width: 38px;
  1447. height: 38px;
  1448. border-radius: 50%;
  1449. border: none;
  1450. background: rgba(255, 255, 255, 0.12);
  1451. color: #fff;
  1452. font-size: 18px;
  1453. cursor: pointer;
  1454. transition: 0.15s;
  1455. }
  1456. .lb-close:hover {
  1457. background: rgba(255, 255, 255, 0.26);
  1458. }
  1459. /* ── 帖子列表缩略图 ── */
  1460. .post .thumb {
  1461. flex: 0 0 auto;
  1462. width: 44px;
  1463. height: 44px;
  1464. border-radius: 7px;
  1465. object-fit: cover;
  1466. background: #f0efe9;
  1467. border: 1px solid var(--line);
  1468. }
  1469. .post .thumb-ph {
  1470. flex: 0 0 auto;
  1471. width: 44px;
  1472. height: 44px;
  1473. border-radius: 7px;
  1474. background: #f0efe9;
  1475. border: 1px solid var(--line);
  1476. display: flex;
  1477. align-items: center;
  1478. justify-content: center;
  1479. color: var(--ink-faint);
  1480. font-size: 16px;
  1481. }
  1482. /* ── 原文卡片(可整体展开/收起;含标题、图片缩略图、正文) ── */
  1483. .src-block {
  1484. border: 1px solid var(--line);
  1485. border-radius: 10px;
  1486. margin-bottom: 14px;
  1487. background: #faf9f5;
  1488. overflow: hidden;
  1489. }
  1490. .src-head {
  1491. display: flex;
  1492. align-items: center;
  1493. gap: 8px;
  1494. padding: 9px 12px;
  1495. cursor: pointer;
  1496. user-select: none;
  1497. }
  1498. .src-head:hover {
  1499. background: #f3f2ed;
  1500. }
  1501. .src-caret {
  1502. flex: 0 0 auto;
  1503. color: var(--ink-faint);
  1504. font-size: 11px;
  1505. transition: transform 0.15s;
  1506. }
  1507. .src-block.open .src-caret {
  1508. transform: rotate(90deg);
  1509. }
  1510. .src-label {
  1511. flex: 0 0 auto;
  1512. font-size: 11px;
  1513. font-weight: 700;
  1514. color: var(--blue);
  1515. background: var(--blue-bg);
  1516. padding: 1px 7px;
  1517. border-radius: 4px;
  1518. }
  1519. .src-title {
  1520. flex: 1;
  1521. min-width: 0;
  1522. font-weight: 600;
  1523. font-size: 13px;
  1524. white-space: nowrap;
  1525. overflow: hidden;
  1526. text-overflow: ellipsis;
  1527. }
  1528. .src-link {
  1529. flex: 0 0 auto;
  1530. font-size: 12px;
  1531. color: var(--blue);
  1532. text-decoration: none;
  1533. }
  1534. .src-case {
  1535. flex: 0 0 auto;
  1536. font-size: 11px;
  1537. font-family: "IBM Plex Mono", ui-monospace, monospace;
  1538. color: var(--ink-faint);
  1539. background: var(--paper, #f3f2ed);
  1540. border: 1px solid var(--line);
  1541. padding: 1px 7px;
  1542. border-radius: 4px;
  1543. white-space: nowrap;
  1544. }
  1545. .src-body {
  1546. padding: 0 12px 12px;
  1547. }
  1548. .src-block:not(.open) .src-body {
  1549. display: none;
  1550. }
  1551. .src-thumbs {
  1552. display: flex;
  1553. gap: 8px;
  1554. overflow-x: auto;
  1555. padding: 4px 2px 10px;
  1556. scrollbar-width: thin;
  1557. }
  1558. .src-thumbs img {
  1559. flex: 0 0 auto;
  1560. height: 96px;
  1561. width: auto;
  1562. max-width: 150px;
  1563. border-radius: 8px;
  1564. border: 1px solid var(--line);
  1565. object-fit: cover;
  1566. background: #f0efe9;
  1567. cursor: zoom-in;
  1568. }
  1569. .src-text {
  1570. font-size: 13px;
  1571. line-height: 1.7;
  1572. color: #3d3f44;
  1573. white-space: pre-wrap;
  1574. }
  1575. .src-text.clamp {
  1576. max-height: 88px;
  1577. overflow: hidden;
  1578. -webkit-mask-image: linear-gradient(180deg, #000 62%, transparent);
  1579. mask-image: linear-gradient(180deg, #000 62%, transparent);
  1580. }
  1581. .src-text-toggle {
  1582. margin-top: 4px;
  1583. background: none;
  1584. border: none;
  1585. color: var(--blue);
  1586. cursor: pointer;
  1587. font-size: 12px;
  1588. padding: 2px 0;
  1589. }
  1590. .pd-tags {
  1591. display: flex;
  1592. gap: 6px;
  1593. flex-wrap: wrap;
  1594. margin-top: 12px;
  1595. }
  1596. .pd-score-head {
  1597. display: flex;
  1598. justify-content: space-between;
  1599. align-items: center;
  1600. margin-bottom: 10px;
  1601. }
  1602. .pd-score-head .t {
  1603. font-weight: 800;
  1604. font-size: 14px;
  1605. }
  1606. .pd-overall {
  1607. display: flex;
  1608. align-items: center;
  1609. gap: 6px;
  1610. font-size: 12.5px;
  1611. font-weight: 700;
  1612. color: var(--ink-soft);
  1613. background: #faf9f5;
  1614. border: 1px solid var(--line);
  1615. padding: 4px 12px;
  1616. border-radius: 8px;
  1617. }
  1618. .pd-overall b {
  1619. font-size: 20px;
  1620. color: var(--blue);
  1621. font-weight: 900;
  1622. line-height: 1;
  1623. }
  1624. .sc-card {
  1625. border: 1px solid var(--line);
  1626. border-radius: 10px;
  1627. background: #fff;
  1628. overflow: hidden;
  1629. margin-bottom: 12px;
  1630. }
  1631. .sc-card-head {
  1632. display: flex;
  1633. justify-content: space-between;
  1634. align-items: center;
  1635. gap: 10px;
  1636. padding: 10px 12px;
  1637. background: #faf9f5;
  1638. border-bottom: 1px solid var(--line);
  1639. font-size: 13px;
  1640. font-weight: 800;
  1641. }
  1642. .sc-card-head .badge {
  1643. display: inline-grid;
  1644. place-items: center;
  1645. width: 20px;
  1646. height: 20px;
  1647. border-radius: 5px;
  1648. background: var(--navy);
  1649. color: #fff;
  1650. font-size: 10px;
  1651. font-weight: 700;
  1652. margin-right: 7px;
  1653. }
  1654. .sc-card-head .avg {
  1655. font-size: 12px;
  1656. color: var(--ink-faint);
  1657. font-weight: 600;
  1658. }
  1659. .sc-card-head .avg b {
  1660. font-size: 17px;
  1661. color: var(--blue);
  1662. font-weight: 900;
  1663. }
  1664. .sc-card-body {
  1665. display: grid;
  1666. gap: 8px;
  1667. padding: 11px 12px;
  1668. }
  1669. /* 维度分组小标题:参考 mode_procedure —— 一级虚线大写,二级点线常规 */
  1670. .sc-sub {
  1671. font-size: 11px;
  1672. font-weight: 800;
  1673. letter-spacing: 0.8px;
  1674. color: var(--ink-faint);
  1675. text-transform: uppercase;
  1676. margin: 14px 0 8px;
  1677. padding-bottom: 5px;
  1678. border-bottom: 1px dashed var(--line-dark);
  1679. }
  1680. .sc-card-body > .sc-sub:first-child {
  1681. margin-top: 2px;
  1682. }
  1683. .sc-sub.lv2 {
  1684. font-size: 11px;
  1685. font-weight: 700;
  1686. letter-spacing: 0.3px;
  1687. text-transform: none;
  1688. color: var(--ink-soft);
  1689. margin: 11px 0 6px;
  1690. padding-bottom: 4px;
  1691. border-bottom: 1px dotted var(--line);
  1692. }
  1693. .sc-row {
  1694. display: grid;
  1695. grid-template-columns: 118px 1fr 30px 16px;
  1696. gap: 9px;
  1697. align-items: center;
  1698. font-size: 12.5px;
  1699. }
  1700. .sc-row .meter {
  1701. height: 8px;
  1702. border-radius: 99px;
  1703. background: #edebe4;
  1704. overflow: hidden;
  1705. }
  1706. .sc-row .meter span {
  1707. display: block;
  1708. height: 100%;
  1709. border-radius: 99px;
  1710. background: linear-gradient(90deg, #60a5fa, #2563eb);
  1711. }
  1712. .sc-row b {
  1713. font-weight: 700;
  1714. text-align: right;
  1715. }
  1716. .sc-row .info {
  1717. color: var(--ink-faint);
  1718. cursor: pointer;
  1719. font-size: 12px;
  1720. opacity: 0.75;
  1721. user-select: none;
  1722. }
  1723. .sc-row .info:hover {
  1724. color: var(--blue);
  1725. opacity: 1;
  1726. }
  1727. /* 判定理由弹层:点击 ⓘ 时浮现,挂在 dialog 顶层 */
  1728. .score-pop {
  1729. position: fixed;
  1730. z-index: 90;
  1731. width: 288px;
  1732. max-width: calc(100vw - 24px);
  1733. background: var(--card);
  1734. border: 1px solid var(--line-dark);
  1735. border-radius: 10px;
  1736. box-shadow: var(--shadow-lg);
  1737. padding: 12px 14px;
  1738. font-size: 12.5px;
  1739. line-height: 1.65;
  1740. color: var(--ink-soft);
  1741. animation: popIn 0.12s ease;
  1742. }
  1743. .score-pop .sp-head {
  1744. display: flex;
  1745. align-items: center;
  1746. gap: 8px;
  1747. margin-bottom: 8px;
  1748. padding-bottom: 8px;
  1749. border-bottom: 1px solid var(--line);
  1750. }
  1751. .score-pop .sp-tag {
  1752. font-size: 9px;
  1753. letter-spacing: 1.5px;
  1754. color: var(--ink-faint);
  1755. font-weight: 700;
  1756. border: 1px solid var(--line-dark);
  1757. border-radius: 5px;
  1758. padding: 2px 6px;
  1759. white-space: nowrap;
  1760. }
  1761. .score-pop .sp-name {
  1762. font-weight: 800;
  1763. font-size: 13px;
  1764. color: var(--ink);
  1765. }
  1766. .score-pop .sp-score {
  1767. margin-left: auto;
  1768. font-size: 16px;
  1769. font-weight: 900;
  1770. color: var(--blue);
  1771. }
  1772. .score-pop .sp-body {
  1773. white-space: pre-wrap;
  1774. }
  1775. @keyframes popIn {
  1776. from {
  1777. opacity: 0;
  1778. transform: translateY(-4px);
  1779. }
  1780. to {
  1781. opacity: 1;
  1782. transform: none;
  1783. }
  1784. }
  1785. /* 任务面板 */
  1786. #task-panel {
  1787. position: fixed;
  1788. right: 22px;
  1789. bottom: 22px;
  1790. width: 440px;
  1791. max-height: 55vh;
  1792. z-index: 130; /* 高于弹层(modal-bg 70/dialog 120),搜索进度日志始终可见 */
  1793. display: flex;
  1794. flex-direction: column;
  1795. border: 1px solid var(--line-dark);
  1796. border-radius: 12px;
  1797. background: var(--card);
  1798. box-shadow: var(--shadow-lg);
  1799. overflow: hidden;
  1800. }
  1801. #task-panel header {
  1802. all: unset;
  1803. display: flex;
  1804. align-items: center;
  1805. gap: 9px;
  1806. padding: 11px 14px;
  1807. background: var(--navy-deep);
  1808. color: #fff;
  1809. font-size: 13px;
  1810. font-weight: 700;
  1811. }
  1812. #task-panel header .dot {
  1813. width: 8px;
  1814. height: 8px;
  1815. border-radius: 50%;
  1816. background: #f5b942;
  1817. animation: blink 1s infinite;
  1818. }
  1819. #task-panel header .dot.done {
  1820. background: #3fb27f;
  1821. animation: none;
  1822. }
  1823. #task-panel header .dot.failed {
  1824. background: #e0492f;
  1825. animation: none;
  1826. }
  1827. @keyframes blink {
  1828. 50% {
  1829. opacity: 0.3;
  1830. }
  1831. }
  1832. #task-panel header button {
  1833. margin-left: auto;
  1834. background: none;
  1835. border: 0;
  1836. color: #9eb0c5;
  1837. font-size: 15px;
  1838. }
  1839. #task-panel header button:hover {
  1840. color: #fff;
  1841. }
  1842. #task-log {
  1843. font-family: "IBM Plex Mono", monospace;
  1844. font-size: 11px;
  1845. line-height: 1.65;
  1846. color: var(--ink-soft);
  1847. white-space: pre-wrap;
  1848. overflow: auto;
  1849. padding: 12px 14px;
  1850. background: #fafaf6;
  1851. flex: 1;
  1852. }
  1853. /* 弹窗(新建搜索) */
  1854. .modal-bg {
  1855. position: fixed;
  1856. inset: 0;
  1857. background: rgba(19, 30, 46, 0.5);
  1858. z-index: 70;
  1859. display: grid;
  1860. place-items: center;
  1861. backdrop-filter: blur(2px);
  1862. }
  1863. /* 不能 overflow:hidden,否则渠道下拉面板会被裁掉 */
  1864. .modal {
  1865. width: 460px;
  1866. background: var(--card);
  1867. border-radius: 14px;
  1868. box-shadow: var(--shadow-lg);
  1869. }
  1870. .modal h2 {
  1871. padding: 14px 18px;
  1872. background: var(--navy-deep);
  1873. color: #fff;
  1874. font-size: 15px;
  1875. letter-spacing: 2px;
  1876. border-radius: 14px 14px 0 0;
  1877. }
  1878. .modal .mb {
  1879. padding: 18px;
  1880. display: grid;
  1881. gap: 12px;
  1882. }
  1883. .modal label {
  1884. font-size: 12px;
  1885. color: var(--ink-soft);
  1886. display: grid;
  1887. gap: 5px;
  1888. }
  1889. .modal .mf {
  1890. display: flex;
  1891. justify-content: flex-end;
  1892. gap: 10px;
  1893. padding: 0 18px 18px;
  1894. }
  1895. /* 渠道下拉多选 */
  1896. .dd {
  1897. position: relative;
  1898. }
  1899. .dd-btn {
  1900. width: 100%;
  1901. display: flex;
  1902. justify-content: space-between;
  1903. align-items: center;
  1904. gap: 8px;
  1905. text-align: left;
  1906. padding: 7px 10px;
  1907. border: 1px solid var(--line-dark);
  1908. border-radius: 8px;
  1909. background: #fff;
  1910. font-size: 13px;
  1911. color: var(--ink);
  1912. }
  1913. .dd-btn .dd-arrow {
  1914. color: var(--ink-faint);
  1915. flex: none;
  1916. }
  1917. .dd-btn:focus {
  1918. border-color: var(--blue);
  1919. }
  1920. .dd-panel {
  1921. position: absolute;
  1922. left: 0;
  1923. right: 0;
  1924. top: calc(100% + 4px);
  1925. z-index: 10;
  1926. background: #fff;
  1927. border: 1px solid var(--line-dark);
  1928. border-radius: 10px;
  1929. box-shadow: var(--shadow-lg);
  1930. padding: 6px;
  1931. max-height: 220px;
  1932. overflow: auto;
  1933. }
  1934. .modal label.dd-opt {
  1935. display: flex;
  1936. flex-direction: row;
  1937. align-items: center;
  1938. gap: 8px;
  1939. padding: 7px 9px;
  1940. border-radius: 6px;
  1941. font-size: 13px;
  1942. color: var(--ink);
  1943. cursor: pointer;
  1944. }
  1945. .dd-opt:hover {
  1946. background: #f4f3ee;
  1947. }
  1948. .dd-opt input {
  1949. accent-color: var(--blue);
  1950. margin: 0;
  1951. cursor: pointer;
  1952. }
  1953. .dd-opt.sel {
  1954. background: var(--blue-bg);
  1955. font-weight: 500;
  1956. }
  1957. /* 聚类库占位 */
  1958. .cluster-empty {
  1959. display: grid;
  1960. place-items: center;
  1961. min-height: 60vh;
  1962. }
  1963. .cluster-empty .inner {
  1964. text-align: center;
  1965. color: var(--ink-faint);
  1966. }
  1967. .cluster-empty .stamp {
  1968. width: 120px;
  1969. height: 120px;
  1970. margin: 0 auto 18px;
  1971. border: 3px solid var(--line-dark);
  1972. border-radius: 50%;
  1973. display: grid;
  1974. place-items: center;
  1975. font-family: "Noto Serif SC", serif;
  1976. font-size: 30px;
  1977. font-weight: 900;
  1978. color: var(--line-dark);
  1979. transform: rotate(-8deg);
  1980. letter-spacing: 4px;
  1981. }
  1982. [hidden] {
  1983. display: none !important;
  1984. }
  1985. /* ── 页内提示(替代浏览器原生 alert) ── */
  1986. #toast-wrap {
  1987. position: fixed;
  1988. top: 18px;
  1989. left: 50%;
  1990. transform: translateX(-50%);
  1991. z-index: 120;
  1992. display: flex;
  1993. flex-direction: column;
  1994. align-items: center;
  1995. gap: 10px;
  1996. pointer-events: none;
  1997. }
  1998. .toast {
  1999. pointer-events: auto;
  2000. display: flex;
  2001. align-items: flex-start;
  2002. gap: 10px;
  2003. min-width: 240px;
  2004. max-width: min(440px, calc(100vw - 32px));
  2005. padding: 12px 14px 12px 13px;
  2006. background: var(--card);
  2007. color: var(--ink);
  2008. border: 1px solid var(--line-dark);
  2009. border-left: 4px solid var(--navy);
  2010. border-radius: 10px;
  2011. box-shadow: var(--shadow-lg);
  2012. font-size: 13px;
  2013. line-height: 1.55;
  2014. animation: toastIn 0.18s ease;
  2015. }
  2016. .toast.out {
  2017. animation: toastOut 0.16s ease forwards;
  2018. }
  2019. .toast .ic {
  2020. flex: none;
  2021. width: 18px;
  2022. height: 18px;
  2023. margin-top: 1px;
  2024. display: grid;
  2025. place-items: center;
  2026. border-radius: 50%;
  2027. font-size: 12px;
  2028. font-weight: 900;
  2029. color: #fff;
  2030. background: var(--navy);
  2031. }
  2032. .toast .msg {
  2033. flex: 1;
  2034. word-break: break-word;
  2035. }
  2036. .toast.error {
  2037. border-left-color: var(--seal);
  2038. }
  2039. .toast.error .ic {
  2040. background: var(--seal);
  2041. }
  2042. .toast.success {
  2043. border-left-color: var(--green);
  2044. }
  2045. .toast.success .ic {
  2046. background: var(--green);
  2047. }
  2048. .toast.warn {
  2049. border-left-color: var(--amber);
  2050. }
  2051. .toast.warn .ic {
  2052. background: var(--amber);
  2053. }
  2054. @keyframes toastIn {
  2055. from {
  2056. opacity: 0;
  2057. transform: translateY(-10px);
  2058. }
  2059. to {
  2060. opacity: 1;
  2061. transform: none;
  2062. }
  2063. }
  2064. @keyframes toastOut {
  2065. to {
  2066. opacity: 0;
  2067. transform: translateY(-8px);
  2068. }
  2069. }
  2070. /* Query 规则弹层 */
  2071. .qr-box { background:#fff; border-radius:14px; box-shadow:0 10px 44px rgba(0,0,0,.18);
  2072. width:96vw; max-width:1200px; max-height:92vh; display:flex; flex-direction:column; overflow:hidden; }
  2073. .qr-head { display:flex; align-items:center; padding:15px 20px; border-bottom:1px solid #eee; }
  2074. .qr-title { font-size:15px; font-weight:600; color:#1a1a1a; }
  2075. .qr-x { margin-left:auto; border:none; background:none; font-size:16px; color:#999; cursor:pointer; padding:4px 9px; border-radius:7px; line-height:1; }
  2076. .qr-x:hover { background:#f2f2f2; color:#333; }
  2077. .qr-bar { display:flex; align-items:center; gap:10px; padding:11px 20px; border-bottom:1px solid #f0f0f0; background:#fcfcfc; }
  2078. .qr-hint { color:#888; font-size:12px; margin-left:4px; }
  2079. .qr-thr-lab { color:#666; font-size:12px; }
  2080. .qr-thr { width:46px; padding:3px 5px; border:1px solid #ddd; border-radius:6px; font-size:12px; }
  2081. #qr-score:disabled { opacity:.6; cursor:wait; }
  2082. .ui-confirm-bg { position:fixed; inset:0; background:rgba(0,0,0,.38); z-index:200; display:flex; align-items:center; justify-content:center; }
  2083. .ui-confirm { background:#fff; border-radius:14px; box-shadow:0 14px 50px rgba(0,0,0,.28); width:400px; max-width:92vw; padding:22px 24px; }
  2084. .ui-confirm-msg { font-size:14px; color:#1a1a1a; line-height:1.6; white-space:pre-line; margin-bottom:18px; }
  2085. .ui-confirm-acts { display:flex; justify-content:flex-end; gap:10px; }
  2086. .qr-dims { padding:8px 20px 10px; max-height:32vh; overflow:auto; border-bottom:1px solid #f0f0f0; }
  2087. .qr-row { display:flex; align-items:flex-start; gap:10px; padding:4px 0; }
  2088. .qr-row + .qr-row { border-top:1px solid #f6f6f6; }
  2089. .qr-lab { min-width:64px; color:#999; font-size:12.5px; padding-top:5px; flex-shrink:0; }
  2090. .qr-chips { display:flex; flex-wrap:wrap; gap:6px; flex:1; }
  2091. .chip { padding:4px 13px; border-radius:16px; font-size:12.5px; cursor:pointer; border:1.5px solid #e2e2e2; background:#fff; color:#555; line-height:1.4; }
  2092. .chip:hover { border-color:#bbb; color:#222; }
  2093. .chip.on { background:#1a1a1a; border-color:#1a1a1a; color:#fff; font-weight:500; }
  2094. .chip.axis.on { background:#2563eb; border-color:#2563eb; }
  2095. .qr-table-wrap { overflow:auto; flex:1; }
  2096. .qr-tab { border-collapse:collapse; font-size:11px; }
  2097. .qr-tab th, .qr-tab td { border:1px solid #eee; padding:3px 7px; white-space:nowrap; }
  2098. .qr-tab thead th { position:sticky; top:0; background:#f7f7f7; z-index:2; }
  2099. .qr-corner { position:sticky; left:0; z-index:3; background:#eef0f3; font-weight:600; color:#555; }
  2100. .qr-th { position:sticky; left:0; background:#fafafa; z-index:1; text-align:left; color:#444; }
  2101. .qr-tl1 { background:#eef0f3; font-weight:600; color:#444; }
  2102. .qr-gh { background:#e8ebef; font-weight:600; color:#333; text-align:center; }
  2103. .qr-ah { background:#f3f4f6; color:#555; text-align:center; }
  2104. .qr-c.t0 { background:#fafafa; color:#bbb; } .qr-c.t1 { background:#f1f8f1; }
  2105. .qr-c.t2 { background:#d8ecd8; } .qr-c.t3 { background:#b9ddb9; }
  2106. .qr-c.dead { color:#ccc; }
  2107. .qr-c.keep { background:#fff3bf !important; box-shadow:inset 0 0 0 2px #f59e0b; color:#111; font-weight:700; cursor:pointer; }
  2108. .qr-c.keep:hover { background:#ffe066 !important; }
  2109. .qr-bd { display:inline-block; margin-left:5px; font-style:normal; font-size:11px; font-weight:800; color:#fff; background:#f59e0b; padding:0 6px; border-radius:9px; }
  2110. .qr-pop { position:fixed; z-index:60; width:300px; background:#fff; border:1px solid #e2e2e2;
  2111. border-radius:11px; box-shadow:0 8px 30px rgba(0,0,0,.18); padding:13px 15px; font-size:12.5px; color:#333; }
  2112. .qr-pop .q { font-size:13.5px; font-weight:600; color:#1a1a1a; margin-bottom:2px; word-break:break-all; }
  2113. .qr-pop .orig { font-size:11px; color:#aaa; margin-bottom:8px; }
  2114. .qr-pop .sc { display:flex; align-items:baseline; gap:8px; margin:6px 0; }
  2115. .qr-pop .sc b { font-size:22px; color:#2563eb; }
  2116. .qr-pop .dim { color:#888; font-size:11.5px; }
  2117. .qr-pop .rsn { color:#555; margin:7px 0 10px; line-height:1.5; }
  2118. .qr-pop .acts { display:flex; gap:8px; }
  2119. </style>
  2120. </head>
  2121. <body>
  2122. <div id="toast-wrap" aria-live="polite"></div>
  2123. <header>
  2124. <div class="logo">
  2125. <div class="seal">解</div>
  2126. <div><b>mode_workflow</b><small>解构工作台 · MODE WORKBENCH</small></div>
  2127. </div>
  2128. <nav id="nav">
  2129. <a
  2130. href="#dashboard"
  2131. data-tab="dashboard"
  2132. >Dashboard</a
  2133. >
  2134. <a
  2135. href="#dataset"
  2136. data-tab="dataset"
  2137. >Dataset</a
  2138. >
  2139. <a
  2140. href="#cluster"
  2141. data-tab="cluster"
  2142. >知识库</a
  2143. >
  2144. </nav>
  2145. <div class="spacer"></div>
  2146. <div class="hint">SEARCH · EXTRACT · ARCHIVE</div>
  2147. </header>
  2148. <main id="view-dashboard"></main>
  2149. <main id="view-dataset">
  2150. <div class="ds-top">
  2151. <div class="mode-switch">
  2152. <button
  2153. id="m-process"
  2154. class="on"
  2155. >
  2156. 工序
  2157. </button>
  2158. <button id="m-tools">工具</button>
  2159. </div>
  2160. <div style="flex: 1"></div>
  2161. <button
  2162. class="btn seal"
  2163. id="btn-new-search"
  2164. >
  2165. + 新建搜索
  2166. </button>
  2167. <button class="btn" id="btn-query-rule" style="margin-left:8px">Query 规则</button>
  2168. </div>
  2169. <div class="ds-grid">
  2170. <div class="card">
  2171. <div class="col-head">
  2172. QUERY
  2173. <span
  2174. class="n"
  2175. id="q-count"
  2176. ></span>
  2177. </div>
  2178. <div
  2179. class="qlist"
  2180. id="query-list"
  2181. >
  2182. <div class="empty">暂无 query</div>
  2183. </div>
  2184. </div>
  2185. <div class="card">
  2186. <div class="col-head">
  2187. 帖子
  2188. <span style="display: flex; gap: 8px; align-items: center">
  2189. <span
  2190. class="n"
  2191. id="p-count"
  2192. ></span>
  2193. <button
  2194. class="btn sm"
  2195. id="btn-batch"
  2196. disabled
  2197. hidden
  2198. >
  2199. 批量解构
  2200. </button>
  2201. <button class="btn sm" id="btn-extract-adopted" hidden>解构全部已采纳</button>
  2202. </span>
  2203. </div>
  2204. <div
  2205. class="plat-tabs"
  2206. id="plat-tabs"
  2207. hidden
  2208. ></div>
  2209. <div
  2210. class="plist"
  2211. id="post-list"
  2212. >
  2213. <div class="empty"><span class="glyph">←</span>先选择左侧 query</div>
  2214. </div>
  2215. </div>
  2216. <div class="card xp">
  2217. <div
  2218. class="xp-head"
  2219. id="xp-head"
  2220. >
  2221. <span class="st">解构结果</span>
  2222. </div>
  2223. <div
  2224. class="xp-body"
  2225. id="xp-body"
  2226. >
  2227. <div class="empty"><span class="glyph">←</span>选择一个帖子查看解构结果</div>
  2228. </div>
  2229. </div>
  2230. </div>
  2231. </main>
  2232. <main id="view-cluster">
  2233. <iframe
  2234. id="cluster-frame"
  2235. title="知识检索"
  2236. loading="lazy"
  2237. ></iframe>
  2238. </main>
  2239. <div
  2240. id="task-panel"
  2241. hidden
  2242. >
  2243. <header>
  2244. <span
  2245. class="dot"
  2246. id="task-dot"
  2247. ></span
  2248. ><span id="task-title">任务</span> <button onclick="hideTask()">✕</button>
  2249. </header>
  2250. <div id="task-log"></div>
  2251. </div>
  2252. <!-- 帖子详情弹层(评分详情参考 fixed_query_eval) -->
  2253. <dialog id="post-dialog">
  2254. <div class="pd-wrap">
  2255. <div class="pd-head">
  2256. <div style="min-width: 0">
  2257. <div
  2258. class="pd-meta"
  2259. id="pd-meta"
  2260. ></div>
  2261. <h3 id="pd-title"></h3>
  2262. </div>
  2263. <button
  2264. class="pd-close"
  2265. onclick="document.getElementById('post-dialog').close()"
  2266. >
  2267. </button>
  2268. </div>
  2269. <div class="pd-body">
  2270. <section>
  2271. <div id="pd-verdict"></div>
  2272. <div class="pd-sec-title">抓取文本节选</div>
  2273. <div
  2274. class="pd-raw"
  2275. id="pd-text"
  2276. ></div>
  2277. <div class="pd-sec-title">图片预览</div>
  2278. <div
  2279. class="pd-images"
  2280. id="pd-images"
  2281. ></div>
  2282. <div
  2283. class="pd-sec-title"
  2284. id="pd-videos-title"
  2285. style="display: none"
  2286. >
  2287. 视频预览
  2288. </div>
  2289. <div
  2290. class="pd-videos"
  2291. id="pd-videos"
  2292. style="display: none"
  2293. ></div>
  2294. <div
  2295. class="pd-tags"
  2296. id="pd-tags"
  2297. ></div>
  2298. </section>
  2299. <aside>
  2300. <div class="pd-score-head">
  2301. <span class="t">评分详情</span>
  2302. <span class="pd-overall">综合评分 <b id="pd-overall">—</b></span>
  2303. </div>
  2304. <div id="pd-scores"></div>
  2305. </aside>
  2306. </div>
  2307. </div>
  2308. </dialog>
  2309. <!-- 重新解构 · 编辑解构 Prompt -->
  2310. <dialog id="reextract-dlg">
  2311. <div class="rx-wrap">
  2312. <div class="rx-head">
  2313. <div class="rx-title">重新解构 · 编辑解构 Prompt</div>
  2314. <button
  2315. class="btn sm"
  2316. onclick="document.getElementById('reextract-dlg').close()"
  2317. >
  2318. 关闭
  2319. </button>
  2320. </div>
  2321. <div class="rx-sub">
  2322. 修改下面的解构 Prompt 后,点「保存修改」将按最新 Prompt
  2323. 重新解构本帖(生成新版本,旧版本保留)。改动仅本次生效,不会改写默认 Prompt。
  2324. </div>
  2325. <div class="rx-model">
  2326. <label>模型:</label>
  2327. <select id="rx-model"></select>
  2328. </div>
  2329. <textarea
  2330. id="rx-prompt"
  2331. class="rx-prompt"
  2332. spellcheck="false"
  2333. ></textarea>
  2334. <div class="rx-foot">
  2335. <button
  2336. class="btn"
  2337. onclick="document.getElementById('reextract-dlg').close()"
  2338. >
  2339. 取消
  2340. </button>
  2341. <button
  2342. class="btn primary"
  2343. id="rx-save"
  2344. onclick="saveReextract()"
  2345. >
  2346. 保存修改
  2347. </button>
  2348. </div>
  2349. </div>
  2350. </dialog>
  2351. <!-- 图片预览灯箱(支持左右切换) -->
  2352. <dialog
  2353. class="lightbox"
  2354. id="lightbox"
  2355. onclick="if (event.target === this) closeLightbox();"
  2356. >
  2357. <button
  2358. class="lb-close"
  2359. onclick="closeLightbox()"
  2360. title="关闭 (Esc)"
  2361. >
  2362. </button>
  2363. <button
  2364. class="lb-nav lb-prev"
  2365. onclick="lbStep(-1)"
  2366. title="上一张 (←)"
  2367. >
  2368. </button>
  2369. <figure class="lb-stage">
  2370. <img
  2371. id="lb-img"
  2372. src=""
  2373. alt=""
  2374. />
  2375. <figcaption id="lb-count"></figcaption>
  2376. </figure>
  2377. <button
  2378. class="lb-nav lb-next"
  2379. onclick="lbStep(1)"
  2380. title="下一张 (→)"
  2381. >
  2382. </button>
  2383. </dialog>
  2384. <div
  2385. class="modal-bg"
  2386. id="search-modal"
  2387. hidden
  2388. >
  2389. <div class="modal">
  2390. <h2>新建搜索</h2>
  2391. <div class="mb">
  2392. <label
  2393. >Query(评估锚点,必填)<input
  2394. type="text"
  2395. id="s-query"
  2396. placeholder="如:AI 人像 图片 生成 怎么做"
  2397. /></label>
  2398. <label
  2399. >解构方向<select id="s-mode">
  2400. <option value="工序">工序</option>
  2401. <option value="工具">工具</option>
  2402. </select></label
  2403. >
  2404. <label
  2405. >同义措辞(可选,逗号分隔)<input
  2406. type="text"
  2407. id="s-syn"
  2408. placeholder="如:AI 人像生成 教程,AI 写真 怎么做"
  2409. /></label>
  2410. <label
  2411. >检索渠道(下拉多选)
  2412. <div
  2413. class="dd"
  2414. id="s-plat-dd"
  2415. >
  2416. <button
  2417. type="button"
  2418. class="dd-btn"
  2419. id="s-plat-btn"
  2420. >
  2421. 选择渠道 ▾
  2422. </button>
  2423. <div
  2424. class="dd-panel"
  2425. id="s-plat-panel"
  2426. hidden
  2427. ></div>
  2428. </div>
  2429. </label>
  2430. <label
  2431. >每措辞每渠道上限<input
  2432. type="number"
  2433. id="s-max"
  2434. value="10"
  2435. min="1"
  2436. max="50"
  2437. /></label>
  2438. </div>
  2439. <div class="mf">
  2440. <button
  2441. class="btn"
  2442. onclick="document.getElementById('search-modal').hidden = true"
  2443. >
  2444. 取消
  2445. </button>
  2446. <button
  2447. class="btn primary"
  2448. id="s-go"
  2449. >
  2450. 开始搜索
  2451. </button>
  2452. </div>
  2453. </div>
  2454. </div>
  2455. <!-- Query 规则组织器 弹层 -->
  2456. <div class="modal-bg" id="qr-modal" hidden>
  2457. <div class="qr-box">
  2458. <div class="qr-head">
  2459. <span class="qr-title">Query 词组织器</span>
  2460. <button class="qr-x" id="qr-close" title="关闭">✕</button>
  2461. </div>
  2462. <div class="qr-bar">
  2463. <button class="btn seal" id="qr-score">生成正交表</button>
  2464. <button class="btn" id="qr-search-all" hidden>搜全部达标</button>
  2465. <label class="qr-thr-lab">达标分 ≥ <input id="qr-thr" class="qr-thr" type="number" min="0" max="10" step="0.5" value="7"></label>
  2466. <span id="qr-hint" class="qr-hint"></span>
  2467. </div>
  2468. <div id="qr-dims" class="qr-dims"></div>
  2469. <div id="qr-table-wrap" class="qr-table-wrap"></div>
  2470. </div>
  2471. <div id="qr-pop" class="qr-pop" hidden></div>
  2472. </div>
  2473. <script>
  2474. /* ════ 基础 ════ */
  2475. const $ = (s) => document.querySelector(s);
  2476. /* 页内提示,替代浏览器原生 alert();type: info|error|success|warn */
  2477. function toast(msg, type = "info", ms = 3200) {
  2478. const wrap = $("#toast-wrap");
  2479. if (!wrap) return;
  2480. const ic = { info: "i", error: "!", success: "✓", warn: "!" }[type] || "i";
  2481. const el = document.createElement("div");
  2482. el.className = "toast " + type;
  2483. el.innerHTML = `<span class="ic">${ic}</span><span class="msg">${esc(msg)}</span>`;
  2484. const dismiss = () => {
  2485. el.classList.add("out");
  2486. el.addEventListener("animationend", () => el.remove(), { once: true });
  2487. };
  2488. el.addEventListener("click", dismiss);
  2489. wrap.appendChild(el);
  2490. setTimeout(dismiss, ms);
  2491. }
  2492. const api = (p, opt) =>
  2493. fetch(p, opt).then(async (r) => {
  2494. if (!r.ok)
  2495. throw Object.assign(new Error("api"), { status: r.status, body: await r.json().catch(() => ({})) });
  2496. return r.json();
  2497. });
  2498. const esc = (s) =>
  2499. String(s ?? "").replace(
  2500. /[&<>"']/g,
  2501. (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[c],
  2502. );
  2503. /* 目的列: 把 intent 里的 {类别:值} 标记渲染成彩色胶囊 (口径同 procedure-dsl renderer.py:render_intent)。
  2504. 合法类别 5 个: effect/via/act/in-type/out-type; 其余落 ik-other(红删除线,当 lint 警告)。
  2505. 标记外的字面文字与值都做 HTML 转义。 */
  2506. const INTENT_KIND = {
  2507. effect: "ik-effect", via: "ik-via", act: "ik-act",
  2508. "in-type": "ik-in-type", "out-type": "ik-out-type",
  2509. };
  2510. const renderIntent = (text) => {
  2511. const s = String(text ?? "");
  2512. const re = /\{([\w-]+):([^}]+)\}/g;
  2513. let out = "", last = 0, m;
  2514. while ((m = re.exec(s))) {
  2515. out += esc(s.slice(last, m.index).replace(/`/g, ""));
  2516. const kc = INTENT_KIND[m[1]] || "ik-other";
  2517. out += `<span class="intent-tok ${kc}">${esc(m[2])}</span>`;
  2518. last = m.index + m[0].length;
  2519. }
  2520. return out + esc(s.slice(last).replace(/`/g, ""));
  2521. };
  2522. /* 外链图片走本服务同源反代,绕过公众号(mmbiz.qpic.cn)等防盗链 */
  2523. const imgProxy = (u) => (/^https?:\/\//.test(u || "") ? "/api/img?u=" + encodeURIComponent(u) : u || "");
  2524. /* 图片加载策略:优先「浏览器直连 CDN」(referrerpolicy=no-referrer 多数能绕防盗链),
  2525. 直连失败再回退到同源代理 /api/img。
  2526. 为什么:公网走 Cloudflare 快速隧道(trycloudflare),所有经 /api/img 的图片字节都要
  2527. 「上游CDN → 本机 → 隧道(受本机上行带宽限制)→ 客户」,一帖十几张图(每张 100~180KB)
  2528. 就把本机上行打满,于是「本地快、公网慢」。改为浏览器直连后,绝大多数图片字节不再过本机/
  2529. 隧道,只有少数仍被防盗链拦截的才回退代理。 */
  2530. const imgDirect = (u) => (/^https?:\/\//.test(u || "") ? u : imgProxy(u));
  2531. /* 视频走专用同源反代 /api/video:服务端按平台补 Referer(抖音 aweme/play 等必需)
  2532. + 透传 Range 头做边下边播/拖拽。不像 /api/img 那样整文件缓冲,避免慢 + BrokenPipe。 */
  2533. const vidProxy = (u) => (/^https?:\/\//.test(u || "") ? "/api/video?u=" + encodeURIComponent(u) : u || "");
  2534. /* 从各种 YouTube 链接里抠出 video_id(watch?v= / youtu.be/ / embed/) */
  2535. const ytId = (u) => {
  2536. const m =
  2537. (u || "").match(/[?&]v=([\w-]{6,})/) ||
  2538. (u || "").match(/youtu\.be\/([\w-]{6,})/) ||
  2539. (u || "").match(/embed\/([\w-]{6,})/);
  2540. return m ? m[1] : "";
  2541. };
  2542. /* 视频代理也失败时,把 <video> 换成「源站打开」链接(data-src 存原始 URL) */
  2543. function vidFallback(el) {
  2544. el.onerror = null;
  2545. const u = el.dataset.src || "";
  2546. if (u)
  2547. el.outerHTML =
  2548. '<a class="vid-fallback" href="' + u.replace(/"/g, "&quot;") +
  2549. '" target="_blank" rel="noopener">源站打开视频 ↗</a>';
  2550. }
  2551. function imgFallback(el, proxy) {
  2552. el.onerror = null; // 防止回调里再次触发自身造成死循环
  2553. if (!el.dataset.fb) {
  2554. el.dataset.fb = "1"; // 直连失败 → 回退同源代理(防盗链兜底)
  2555. el.onerror = () => imgFallback(el, proxy);
  2556. el.src = proxy;
  2557. return;
  2558. }
  2559. if (el.dataset.ph)
  2560. el.outerHTML = el.dataset.ph; // 代理也失败:换占位元素
  2561. else el.style.opacity = 0.25; // 无占位:淡化
  2562. }
  2563. function imgHtml(u, { cls = "", extra = "", ph = "" } = {}) {
  2564. const phAttr = ph ? ` data-ph="${esc(ph)}"` : "";
  2565. return `<img ${cls ? `class="${cls}" ` : ""}src="${esc(imgDirect(u))}" referrerpolicy="no-referrer" loading="lazy"${phAttr} ${extra} onerror="imgFallback(this,'${esc(imgProxy(u))}')">`;
  2566. }
  2567. const state = {
  2568. tab: "dashboard",
  2569. mode: "process",
  2570. queryId: null,
  2571. caseId: null,
  2572. post: null,
  2573. version: null,
  2574. platFilter: "all",
  2575. doneFilter: true,
  2576. selected: new Set(),
  2577. queries: [],
  2578. posts: [],
  2579. };
  2580. const PLAT_CLS = (p) =>
  2581. ({ xhs: "xhs", gzh: "gzh", zhihu: "zhihu", douyin: "douyin", sph: "sph", youtube: "youtube", x: "x" })[p] ||
  2582. "other";
  2583. const PLAT_NAME = (p) =>
  2584. ({
  2585. xhs: "小红书",
  2586. gzh: "公众号",
  2587. sph: "视频号",
  2588. github: "GitHub",
  2589. toutiao: "头条",
  2590. douyin: "抖音",
  2591. bili: "哔哩哔哩",
  2592. zhihu: "知乎",
  2593. weibo: "微博",
  2594. youtube: "YouTube",
  2595. x: "X",
  2596. })[p] ||
  2597. p ||
  2598. "?";
  2599. /* 渠道 logo 徽标(品牌色圆角方块,hover 显示渠道名) */
  2600. /* 有对应 SVG 图标的渠道(文件位于 /icons/<key>.svg) */
  2601. const PLAT_ICONS = new Set(["xhs", "gzh", "sph", "github", "douyin", "bili", "zhihu", "weibo", "youtube"]);
  2602. const PLAT_LOGO = (p, size = 18) =>
  2603. PLAT_ICONS.has(p)
  2604. ? `<span class="plat-logo" title="${PLAT_NAME(p)}"><img src="/icons/${p}.svg" width="${size}" height="${size}" alt="${PLAT_NAME(p)}" loading="lazy"></span>`
  2605. : `<span class="plat other">${esc(PLAT_NAME(p))}</span>`;
  2606. const MODELS_PROC = ["anthropic/claude-sonnet-4-6", "google/gemini-3.1-flash-lite"];
  2607. const MODELS_TOOL = ["google/gemini-3.1-flash-lite", "anthropic/claude-sonnet-4-6"];
  2608. const scoreCls = (v) => (v == null ? "s0" : v >= 9 ? "s9" : v >= 8 ? "s8" : v >= 6 ? "s6" : "s0");
  2609. /* ════ 路由 ════ */
  2610. function route() {
  2611. state.tab = (location.hash || "#dashboard").slice(1);
  2612. if (!["dashboard", "dataset", "cluster"].includes(state.tab)) state.tab = "dashboard";
  2613. document.querySelectorAll("nav a").forEach((a) => a.classList.toggle("on", a.dataset.tab === state.tab));
  2614. document.querySelectorAll("main").forEach((m) => m.classList.toggle("on", m.id === "view-" + state.tab));
  2615. if (state.tab === "dashboard") renderDashboard();
  2616. if (state.tab === "dataset" && !state.queries.length) loadQueries();
  2617. if (state.tab === "cluster") {
  2618. // 首次打开聚类库才加载内嵌检索页
  2619. const f = $("#cluster-frame");
  2620. if (f && !f.src) f.src = "/search.html";
  2621. }
  2622. }
  2623. window.addEventListener("hashchange", route);
  2624. /* ════ Dashboard ════ */
  2625. let chartRefs = [];
  2626. async function renderDashboard() {
  2627. const v = $("#view-dashboard");
  2628. let d;
  2629. try {
  2630. d = await api("/api/dashboard");
  2631. } catch (e) {
  2632. v.innerHTML = `<div class="card empty"><span class="glyph">!</span>Dashboard 加载失败:${esc(e.body?.error || e.status)}</div>`;
  2633. return;
  2634. }
  2635. const r = d.result,
  2636. p = d.process_data;
  2637. // 进度百分比向下取整:200/201=99.5% 显示 99%,未真正做完不会显示 100%
  2638. const pct = (a, b) => (b ? Math.floor((a / b) * 100) : 0);
  2639. const platBreak = (arr) =>
  2640. (arr || [])
  2641. .map(
  2642. ([k, n]) =>
  2643. `<span class="pb-item">${PLAT_LOGO(k, 15)}<b class="num">${n}</b></span>`,
  2644. )
  2645. .join("") || "—";
  2646. v.innerHTML = `
  2647. <div class="dash-section"><h2>结果数据</h2><div class="rule"></div><span class="tag">RESULTS</span></div>
  2648. <div class="cards">
  2649. <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>
  2650. <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>
  2651. <div class="card stat a"><div class="lbl">工具数量</div><div class="val num">${r.tool_count}</div><div class="sub">mode_tools 去重工具名</div></div>
  2652. <div class="card stat r"><div class="lbl">内容树覆盖节点</div><div class="val num">0</div>
  2653. <div class="sub">0%</div></div>
  2654. <div class="card stat"><div class="lbl">实质数量</div><div class="val num">${r.substance_count}</div><div class="sub">去重实质条目数</div></div>
  2655. <div class="card stat"><div class="lbl">形式数量</div><div class="val num">${r.form_count}</div><div class="sub">去重形式条目数</div></div>
  2656. </div>
  2657. <div class="dash-section"><h2>过程数据</h2><div class="rule"></div><span class="tag">PROCESS</span></div>
  2658. <div class="cards">
  2659. <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>
  2660. <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>
  2661. <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>
  2662. <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>
  2663. <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>
  2664. <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>
  2665. </div>
  2666. <div class="charts">
  2667. <div class="card chart-card span6"><h3>工序提及工具 TOP10</h3><div class="chart" id="ch-via" style="height:300px"></div></div>
  2668. <div class="card chart-card span6"><h3>解构成本趋势</h3><div class="chart" id="ch-cost" style="height:300px"></div></div>
  2669. <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>
  2670. <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>
  2671. <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>
  2672. </div>`;
  2673. chartRefs.forEach((c) => c.dispose());
  2674. chartRefs = [];
  2675. const mk = (id, opt) => {
  2676. const c = echarts.init($(id));
  2677. c.setOption(opt);
  2678. chartRefs.push(c);
  2679. return c;
  2680. };
  2681. const ink = "#1c2433",
  2682. faint = "#9aa3b0",
  2683. grid = { left: 8, right: 16, top: 8, bottom: 8, containLabel: true };
  2684. /* 热力图 */
  2685. mk("#ch-matrix", {
  2686. tooltip: { formatter: (pr) => `${r.matrix_actions[pr.value[1]]} × ${r.matrix_types[pr.value[0]]}` },
  2687. grid: { left: 8, right: 16, top: 8, bottom: 60, containLabel: true },
  2688. xAxis: {
  2689. type: "category",
  2690. data: r.matrix_types,
  2691. axisLabel: { rotate: 60, fontSize: 9, color: faint },
  2692. splitArea: { show: true, areaStyle: { color: ["#fcfcf9", "#f5f4ef"] } },
  2693. },
  2694. yAxis: {
  2695. type: "category",
  2696. data: r.matrix_actions,
  2697. axisLabel: { fontSize: 10, color: ink },
  2698. splitArea: { show: true },
  2699. },
  2700. visualMap: { show: false, min: 0, max: 1, inRange: { color: ["#f0efe8", "#bb3a22"] } },
  2701. series: [
  2702. {
  2703. type: "heatmap",
  2704. data: r.matrix_cells.map(([a, t]) => [t, a, 1]),
  2705. itemStyle: { borderColor: "#fff", borderWidth: 1 },
  2706. },
  2707. ],
  2708. });
  2709. const bar = (data, color) => ({
  2710. tooltip: {},
  2711. grid,
  2712. xAxis: { type: "value", axisLabel: { color: faint } },
  2713. yAxis: {
  2714. type: "category",
  2715. data: data.map((x) => x[0]).reverse(),
  2716. axisLabel: { color: ink, fontSize: 11, width: 130, overflow: "truncate" },
  2717. },
  2718. series: [
  2719. {
  2720. type: "bar",
  2721. data: data.map((x) => x[1]).reverse(),
  2722. itemStyle: { color, borderRadius: [0, 3, 3, 0] },
  2723. barMaxWidth: 16,
  2724. label: { show: true, position: "right", color: faint, fontSize: 10 },
  2725. },
  2726. ],
  2727. });
  2728. mk("#ch-via", r.via_top10.length ? bar(r.via_top10, "#1e3a5f") : emptyOpt());
  2729. mk("#ch-sub", r.substance_top.length ? bar(r.substance_top, "#b45309") : emptyOpt());
  2730. mk("#ch-form", r.form_top.length ? bar(r.form_top, "#0f6b5c") : emptyOpt());
  2731. mk(
  2732. "#ch-cost",
  2733. p.cost_trend.length
  2734. ? {
  2735. tooltip: { trigger: "axis" },
  2736. grid,
  2737. xAxis: { type: "category", data: p.cost_trend.map((x) => x.date), axisLabel: { color: faint } },
  2738. yAxis: { type: "value", axisLabel: { color: faint, formatter: "${value}" } },
  2739. series: [
  2740. {
  2741. type: "line",
  2742. data: p.cost_trend.map((x) => x.cost),
  2743. smooth: true,
  2744. symbolSize: 7,
  2745. lineStyle: { color: "#bb3a22", width: 2.5 },
  2746. itemStyle: { color: "#bb3a22" },
  2747. areaStyle: { color: "rgba(187,58,34,.08)" },
  2748. },
  2749. ],
  2750. }
  2751. : emptyOpt(),
  2752. );
  2753. function emptyOpt() {
  2754. return {
  2755. title: {
  2756. text: "暂无数据",
  2757. left: "center",
  2758. top: "middle",
  2759. textStyle: { color: faint, fontSize: 12, fontWeight: 400 },
  2760. },
  2761. xAxis: { show: false },
  2762. yAxis: { show: false },
  2763. };
  2764. }
  2765. }
  2766. /* ════ Dataset:query 列表 ════ */
  2767. async function loadQueries() {
  2768. /* 工序/工具各自一张搜索表,query 列表按当前子模式拉取 */
  2769. try {
  2770. /* 接口按 query_id 升序返回;列表倒序显示(最新在上) */
  2771. state.queries = (await api("/api/queries?mode=" + state.mode)).reverse();
  2772. } catch (e) {
  2773. state.queries = [];
  2774. }
  2775. renderQueries();
  2776. /* 进入/切换子模式时默认选中第一个(即最新)query(进而联动第一帖与解构结果) */
  2777. if (!state.queryId && state.queries.length) await selectQuery(state.queries[0].query_id);
  2778. }
  2779. function renderQueries() {
  2780. const list = state.queries;
  2781. $("#q-count").textContent = list.length ? list.length + " 组" : "";
  2782. if (!list.length) {
  2783. $("#query-list").innerHTML = '<div class="empty">暂无 query<br>点右上「新建搜索」开始</div>';
  2784. return;
  2785. }
  2786. $("#query-list").innerHTML = list
  2787. .map((q) => {
  2788. const done = state.mode === "process" ? q.process_done : q.tools_done;
  2789. return `<div class="qitem ${q.query_id === state.queryId ? "on" : ""}" onclick="selectQuery('${q.query_id}')">
  2790. <div class="qid">${q.query_id}</div>
  2791. <div class="qt">${esc(q.query_text || "(未命名)")}</div>
  2792. <div class="qm">
  2793. <span>采纳/命中 <b class="num hit">${q.hit_count ?? 0}</b></span>
  2794. <span>总帖数 <b class="num">${q.post_count}</b></span>
  2795. <span>已解构 <b class="num">${done}</b></span>
  2796. </div>
  2797. </div>`;
  2798. })
  2799. .join("");
  2800. }
  2801. async function selectQuery(qid) {
  2802. state.queryId = qid;
  2803. state.caseId = null;
  2804. state.post = null;
  2805. state.platFilter = "all";
  2806. state.selected.clear();
  2807. renderQueries();
  2808. renderExtractEmpty();
  2809. $("#post-list").innerHTML = '<div class="empty">加载中…</div>';
  2810. try {
  2811. state.posts = await api("/api/posts?mode=" + state.mode + "&query_id=" + encodeURIComponent(qid));
  2812. } catch (e) {
  2813. state.posts = [];
  2814. }
  2815. renderPosts();
  2816. /* 默认选中「可见列表」第一帖(已解构筛选下即第一个已解构帖),无可见帖则退回全部第一帖 */
  2817. if (state.posts.length) {
  2818. const vis = visiblePosts();
  2819. await selectPost((vis[0] || state.posts[0]).case_id);
  2820. }
  2821. }
  2822. /* ════ Dataset:帖子列表(按渠道分 tab)════ */
  2823. function setPlatFilter(p) {
  2824. state.platFilter = p;
  2825. renderPosts();
  2826. }
  2827. function toggleDoneFilter() {
  2828. state.doneFilter = !state.doneFilter;
  2829. renderPosts();
  2830. renderPostsAutoSelect();
  2831. }
  2832. /* 当前可见帖(渠道 + 已解构筛选后),供列表渲染与「默认选中」共用 */
  2833. function visiblePosts() {
  2834. const isDone = (p) => (state.mode === "process" ? p.has_process : p.has_tools);
  2835. let list =
  2836. state.platFilter === "all"
  2837. ? state.posts
  2838. : state.posts.filter((p) => (p.platform || "other") === state.platFilter);
  2839. if (state.doneFilter) list = list.filter(isDone);
  2840. return list;
  2841. }
  2842. /* 切换筛选后,若当前选中帖已被筛掉,则改选可见列表的第一帖 */
  2843. async function renderPostsAutoSelect() {
  2844. const vis = visiblePosts();
  2845. if (vis.length && !vis.some((p) => p.case_id === state.caseId)) await selectPost(vis[0].case_id);
  2846. }
  2847. function renderPosts() {
  2848. const all = state.posts;
  2849. updateBatchBtn();
  2850. /* 渠道 tab + 已解构筛选 */
  2851. const counts = {};
  2852. all.forEach((p) => {
  2853. const k = p.platform || "other";
  2854. counts[k] = (counts[k] || 0) + 1;
  2855. });
  2856. const plats = Object.keys(counts);
  2857. if (state.platFilter !== "all" && !counts[state.platFilter]) state.platFilter = "all";
  2858. const isDone = (p) => (state.mode === "process" ? p.has_process : p.has_tools);
  2859. const platScoped =
  2860. state.platFilter === "all" ? all : all.filter((p) => (p.platform || "other") === state.platFilter);
  2861. const doneN = platScoped.filter(isDone).length;
  2862. const tabs = $("#plat-tabs");
  2863. if (all.length) {
  2864. tabs.hidden = false;
  2865. const btns =
  2866. plats.length > 1
  2867. ? [
  2868. `<button class="${state.platFilter === "all" ? "on" : ""}" onclick="setPlatFilter('all')">全部<span class="c">${all.length}</span></button>`,
  2869. ].concat(
  2870. plats.map(
  2871. (k) =>
  2872. `<button class="${state.platFilter === k ? "on" : ""}" onclick="setPlatFilter('${esc(k)}')">${PLAT_NAME(k)}<span class="c">${counts[k]}</span></button>`,
  2873. ),
  2874. )
  2875. : [];
  2876. btns.push(`<button class="done-filter ${state.doneFilter ? "on" : ""}" onclick="toggleDoneFilter()"
  2877. title="${state.doneFilter ? "当前只看已解构,点击显示全部" : "点击只看已解构"}"><span class="dot">●</span>已解构<span class="c">${doneN}</span></button>`);
  2878. tabs.innerHTML = btns.join("");
  2879. } else {
  2880. tabs.hidden = true;
  2881. }
  2882. const list = visiblePosts();
  2883. $("#p-count").textContent = all.length
  2884. ? state.platFilter === "all" && !state.doneFilter
  2885. ? `${all.length} 帖`
  2886. : `${list.length} / ${all.length} 帖`
  2887. : "";
  2888. if (!all.length) {
  2889. $("#post-list").innerHTML = '<div class="empty">该 query 暂无帖子</div>';
  2890. return;
  2891. }
  2892. if (!list.length) {
  2893. $("#post-list").innerHTML =
  2894. `<div class="empty">${state.doneFilter ? "该筛选下暂无已解构帖子" : "该渠道暂无帖子"}</div>`;
  2895. return;
  2896. }
  2897. $("#post-list").innerHTML = list
  2898. .map((p) => {
  2899. const done = state.mode === "process" ? p.has_process : p.has_tools;
  2900. const kt = (p.knowledge_type || []).map((k) => `<span class="pill">${esc(k)}</span>`).join("");
  2901. const sb =
  2902. p.overall_score != null
  2903. ? `<span class="score-badge ${scoreCls(p.overall_score)} num"
  2904. onclick="event.stopPropagation();openPostDetail('${esc(p.case_id)}')">${p.overall_score}</span>`
  2905. : "";
  2906. const thumbSrc = (p.images || []).filter(Boolean)[0];
  2907. const thumb = thumbSrc
  2908. ? imgHtml(thumbSrc, { cls: "thumb", ph: "<div class='thumb-ph'>🖼️</div>" })
  2909. : `<div class="thumb-ph" title="暂无图片">🖼️</div>`;
  2910. return `<div class="post ${p.case_id === state.caseId ? "on" : ""}" onclick="selectPost('${esc(p.case_id)}')">
  2911. ${thumb}
  2912. <div style="flex:1;min-width:0">
  2913. <div class="pt">${esc(p.title || "(无标题)")}</div>
  2914. <div class="pm">
  2915. ${PLAT_LOGO(p.platform)}
  2916. ${p.adopted ? '<span class="pill green">采纳</span>' : ""}
  2917. ${kt}
  2918. ${done ? '<span class="done-dot">● 已解构</span>' : ""}
  2919. </div>
  2920. </div>
  2921. ${sb}
  2922. </div>`;
  2923. })
  2924. .join("");
  2925. }
  2926. function toggleSel(cid, on) {
  2927. on ? state.selected.add(cid) : state.selected.delete(cid);
  2928. updateBatchBtn();
  2929. }
  2930. function updateBatchBtn() {
  2931. const b = $("#btn-batch");
  2932. b.disabled = !state.selected.size;
  2933. b.textContent = state.selected.size ? `批量解构(${state.selected.size})` : "批量解构";
  2934. // 解构全部已采纳:有采纳帖才显示,带数量(口径同帖列表的 采纳 标记)
  2935. const adoptedN = (state.posts || []).filter((p) => p.adopted).length;
  2936. const ea = $("#btn-extract-adopted");
  2937. ea.hidden = !adoptedN;
  2938. ea.textContent = `解构全部已采纳(${adoptedN})`;
  2939. }
  2940. $("#btn-batch").onclick = () => state.selected.size && startExtract([...state.selected]);
  2941. $("#btn-extract-adopted").onclick = async () => {
  2942. const cids = (state.posts || []).filter((p) => p.adopted).map((p) => p.case_id);
  2943. if (!cids.length) return toast("当前 query 下没有已采纳的帖子", "warn");
  2944. const dir = state.mode === "process" ? "工序" : "工具";
  2945. if (!(await uiConfirm(`对该 query 下全部 ${cids.length} 个已采纳帖做${dir}解构?\n已解构过的会自动跳过/复用,不重复花钱。`))) return;
  2946. startExtract(cids); // 复用:认领锁 + 解构去重 + showTask 轮询
  2947. };
  2948. /* ════ 帖子详情弹层 ════ */
  2949. /* 得分可能是字符串("1")或数字(10),统一解析;非数值返回 null */
  2950. const scoreNum = (v) => {
  2951. const n = typeof v === "number" || (typeof v === "string" && v.trim() !== "") ? Number(v) : NaN;
  2952. return Number.isFinite(n) ? n : null;
  2953. };
  2954. function collectScores(node) {
  2955. let out = [];
  2956. if (Array.isArray(node)) node.forEach((v) => (out = out.concat(collectScores(v))));
  2957. else if (node && typeof node === "object") {
  2958. for (const [k, v] of Object.entries(node)) {
  2959. if (k === "得分") {
  2960. const n = scoreNum(v);
  2961. if (n !== null) out.push(n);
  2962. } else out = out.concat(collectScores(v));
  2963. }
  2964. }
  2965. return out;
  2966. }
  2967. function scRow(label, v, reason) {
  2968. const n = scoreNum(v);
  2969. const has = n !== null;
  2970. return `<div class="sc-row">
  2971. <span style="color:${has ? "inherit" : "var(--ink-faint)"}">${esc(label)}</span>
  2972. <div class="meter"><span style="width:${has ? Math.min(n, 10) * 10 : 0}%"></span></div>
  2973. <b class="num">${has ? n : "—"}</b>
  2974. ${reason ? `<span class="info" data-label="${esc(label)}" data-reason="${esc(reason)}" data-score="${has ? n : ""}" onclick="showScorePop(this)">ⓘ</span>` : "<span></span>"}
  2975. </div>`;
  2976. }
  2977. /* 递归渲染评分;depth>0 的分组标题用二级样式,形成层级 */
  2978. function walkScores(node, depth) {
  2979. depth = depth || 0;
  2980. let html = "";
  2981. for (const [k, v] of Object.entries(node || {})) {
  2982. if (v && typeof v === "object" && !Array.isArray(v) && "得分" in v) {
  2983. html += scRow(k, v["得分"], v["理由"]);
  2984. } else if (scoreNum(v) !== null) {
  2985. html += scRow(k, v);
  2986. } else if (v && typeof v === "object" && !Array.isArray(v)) {
  2987. const inner = walkScores(v, depth + 1);
  2988. if (inner) html += `<div class="sc-sub${depth > 0 ? " lv2" : ""}">${esc(k)}</div>` + inner;
  2989. }
  2990. }
  2991. return html;
  2992. }
  2993. /* ── 质量评分:不跟随原始 JSON 嵌套,改用 mode_procedure 的规范分组与顺序 ──
  2994. 固定维度 → 用例 → 工序 → 能力 → 工具;丢弃「字段完整性」「动态维度」等中间表头 */
  2995. const QUALITY_ORDER = {
  2996. 工序: ["流程完整性", "输入完整性", "实现完整性", "输出完整性", "泛化性"],
  2997. 能力: ["输入完整性", "实现完整性", "输出完整性", "泛化性"],
  2998. 工具: ["能力边界覆盖", "有效比较", "参数/接口具体性", "实操示例", "版本&限制"],
  2999. };
  3000. /* DFS 找到名为 name 的容器节点(工序/能力/工具) */
  3001. function findScoreNode(n, name) {
  3002. if (!n || typeof n !== "object" || Array.isArray(n)) return null;
  3003. if (name in n && n[name] && typeof n[name] === "object" && !Array.isArray(n[name])) return n[name];
  3004. for (const v of Object.values(n)) {
  3005. if (v && typeof v === "object" && !Array.isArray(v)) {
  3006. const r = findScoreNode(v, name);
  3007. if (r) return r;
  3008. }
  3009. }
  3010. return null;
  3011. }
  3012. /* 递归收集子树叶子评分 [name,{得分,理由}],打平中间分组头 */
  3013. function collectLeaves(node) {
  3014. let out = [];
  3015. for (const [k, v] of Object.entries(node || {})) {
  3016. if (v && typeof v === "object" && !Array.isArray(v) && "得分" in v) out.push([k, v]);
  3017. else if (scoreNum(v) !== null) out.push([k, { 得分: v }]);
  3018. else if (v && typeof v === "object" && !Array.isArray(v)) out = out.concat(collectLeaves(v));
  3019. }
  3020. return out;
  3021. }
  3022. function renderQuality(qnode) {
  3023. /* 固定维度/用例 的维度名全局唯一,扁平索引即可取 */
  3024. const flat = {};
  3025. (function collect(n) {
  3026. for (const [k, v] of Object.entries(n || {})) {
  3027. if (v && typeof v === "object" && !Array.isArray(v)) {
  3028. if ("得分" in v) flat[k] = v;
  3029. else collect(v);
  3030. } else if (scoreNum(v) !== null) flat[k] = { 得分: v };
  3031. }
  3032. })(qnode);
  3033. const sub = (t) => `<div class="sc-sub">${esc(t)}</div>`;
  3034. const rows = (pairs) => pairs.map(([n, o]) => scRow(n, o["得分"], o["理由"])).join("");
  3035. const pick = (names) => names.filter((n) => flat[n]).map((n) => [n, flat[n]]);
  3036. let html = "";
  3037. let p = pick(["时效性", "热度性", "评论反馈", "可复现性", "意图可控性"]); // ① 固定维度(置顶)
  3038. if (p.length) html += sub("固定维度") + rows(p);
  3039. p = pick(["真实感", "真实感 (非AI)", "真实感(非AI)", "表现力"]); // ② 用例
  3040. if (p.length) html += sub("用例") + rows(p);
  3041. for (const name of ["工序", "能力", "工具"]) {
  3042. // ③ 动态维度(按方向命名,内部规范排序)
  3043. const node = findScoreNode(qnode, name);
  3044. if (!node) continue;
  3045. const leaves = collectLeaves(node);
  3046. if (!leaves.length) continue;
  3047. const order = QUALITY_ORDER[name] || [];
  3048. leaves.sort((a, b) => (order.indexOf(a[0]) + 1 || 99) - (order.indexOf(b[0]) + 1 || 99));
  3049. html += sub(name) + rows(leaves);
  3050. }
  3051. return html || '<span style="color:var(--ink-faint)">无评分</span>';
  3052. }
  3053. /* ── 判定理由弹层:点击 ⓘ 浮现,符合当前页面样式 ── */
  3054. let _scorePop = null;
  3055. function closeScorePop() {
  3056. if (_scorePop) {
  3057. _scorePop.remove();
  3058. _scorePop = null;
  3059. }
  3060. document.removeEventListener("mousedown", _scorePopOutside, true);
  3061. }
  3062. function _scorePopOutside(e) {
  3063. if (_scorePop && !_scorePop.contains(e.target) && !e.target.classList.contains("info")) closeScorePop();
  3064. }
  3065. function showScorePop(el) {
  3066. const reopen = _scorePop && _scorePop._anchor === el;
  3067. closeScorePop();
  3068. if (reopen) return; // 再次点击同一图标 → 收起
  3069. const score = el.dataset.score;
  3070. const pop = document.createElement("div");
  3071. pop.className = "score-pop";
  3072. pop._anchor = el;
  3073. pop.innerHTML = `<div class="sp-head">
  3074. <span class="sp-tag">判定理由</span>
  3075. <span class="sp-name">${esc(el.dataset.label || "")}</span>
  3076. ${score !== "" && score != null ? `<span class="sp-score">${esc(score)}</span>` : ""}
  3077. </div>
  3078. <div class="sp-body">${esc(el.dataset.reason || "")}</div>`;
  3079. // 挂在 dialog 内,确保位于 showModal 顶层之上
  3080. (document.getElementById("post-dialog") || document.body).appendChild(pop);
  3081. _scorePop = pop;
  3082. // 定位:图标下方右对齐;越界则上翻 / 收边
  3083. const r = el.getBoundingClientRect();
  3084. let top = r.bottom + 8,
  3085. left = r.right - pop.offsetWidth;
  3086. if (left < 12) left = 12;
  3087. if (top + pop.offsetHeight > window.innerHeight - 12) top = r.top - pop.offsetHeight - 8;
  3088. if (top < 12) top = 12;
  3089. pop.style.top = top + "px";
  3090. pop.style.left = left + "px";
  3091. setTimeout(() => document.addEventListener("mousedown", _scorePopOutside, true), 0);
  3092. }
  3093. document.getElementById("post-dialog")?.addEventListener("close", closeScorePop);
  3094. /* ── 图片预览灯箱 ── */
  3095. const lb = { imgs: [], i: 0 };
  3096. function openLightbox(i) {
  3097. if (!lb.imgs.length) return;
  3098. lb.i = (i + lb.imgs.length) % lb.imgs.length;
  3099. renderLightbox();
  3100. const d = $("#lightbox");
  3101. if (!d.open) d.showModal();
  3102. }
  3103. function closeLightbox() {
  3104. const d = $("#lightbox");
  3105. if (d.open) d.close();
  3106. }
  3107. function lbStep(d) {
  3108. if (!lb.imgs.length) return;
  3109. lb.i = (lb.i + d + lb.imgs.length) % lb.imgs.length;
  3110. renderLightbox();
  3111. }
  3112. function renderLightbox() {
  3113. const url = lb.imgs[lb.i];
  3114. const el = $("#lb-img");
  3115. delete el.dataset.fb; // 切换图片前清除上一张的回退标记
  3116. el.onerror = () => imgFallback(el, imgProxy(url));
  3117. el.src = imgDirect(url); // 大图同样优先直连,失败回退代理
  3118. $("#lb-count").textContent = `${lb.i + 1} / ${lb.imgs.length}`;
  3119. const multi = lb.imgs.length > 1;
  3120. document.querySelector(".lb-prev").style.visibility = multi ? "visible" : "hidden";
  3121. document.querySelector(".lb-next").style.visibility = multi ? "visible" : "hidden";
  3122. }
  3123. document.addEventListener("keydown", (e) => {
  3124. if (!$("#lightbox").open) return;
  3125. if (e.key === "ArrowLeft") lbStep(-1);
  3126. else if (e.key === "ArrowRight") lbStep(1);
  3127. // Esc 由 <dialog> 原生处理(触发 close)
  3128. });
  3129. async function openPostDetail(cid) {
  3130. const p = state.posts.find((x) => x.case_id === cid);
  3131. if (!p) return;
  3132. await ensurePostDetail(p); // 列表瘦身,弹框前补全正文/评估
  3133. const e = p.llm_evaluation || {};
  3134. const meta = [];
  3135. meta.push(`${PLAT_LOGO(p.platform)}<span style="font-weight:600">${esc(PLAT_NAME(p.platform))}</span>`);
  3136. meta.push(p.adopted ? '<span class="pill green">采纳/命中</span>' : '<span class="pill">未采纳</span>');
  3137. if (p.publish_time) meta.push(`<span>${esc(String(p.publish_time).slice(0, 16))}</span>`);
  3138. if (p.like_count != null) meta.push(`<span>👍 ${p.like_count}</span>`);
  3139. if (p.quality_grade) meta.push(`<span>质量 ${esc(p.quality_grade)} ${p.quality_score ?? ""}</span>`);
  3140. if (p.url) meta.push(`<a href="${esc(p.url)}" target="_blank">原文 ↗</a>`);
  3141. meta.push(`<span class="pill" title="case_id" style="font-family:'IBM Plex Mono',ui-monospace,monospace">${esc(p.case_id || cid)}</span>`);
  3142. $("#pd-meta").innerHTML = meta.join("");
  3143. $("#pd-title").textContent = p.title || "(无标题)";
  3144. const verdict = e["判定理由"] || e["理由"] || "";
  3145. $("#pd-verdict").innerHTML = verdict ? `<div class="pd-verdict">${esc(verdict)}</div>` : "";
  3146. $("#pd-text").textContent = p.body || "(无正文)";
  3147. const imgs = (p.images || []).filter(Boolean);
  3148. $("#pd-images").innerHTML = imgs.length
  3149. ? imgs
  3150. .map(
  3151. (s, i) => imgHtml(s, { extra: `onclick="openLightbox(${i})"` }),
  3152. )
  3153. .join("")
  3154. : '<p style="color:var(--ink-faint);font-size:12px">搜索详情未返回图片。</p>';
  3155. lb.imgs = imgs;
  3156. // 视频预览:仅当 videos 有值时显示模块
  3157. const vids = (p.videos || []).filter(Boolean);
  3158. const showVids = vids.length > 0;
  3159. $("#pd-videos-title").style.display = showVids ? "" : "none";
  3160. const pdVideos = $("#pd-videos");
  3161. pdVideos.style.display = showVids ? "" : "none";
  3162. pdVideos.innerHTML = showVids
  3163. ? vids
  3164. .map((s) => {
  3165. // YouTube 的 videos[0] 是 watch 页 URL,<video> 播不了 → 用 iframe embed
  3166. const isYt = p.platform === "youtube" || /youtube\.com|youtu\.be/.test(s);
  3167. if (isYt) {
  3168. const id = p.video_id || ytId(s);
  3169. return id
  3170. ? `<iframe src="https://www.youtube.com/embed/${esc(id)}" loading="lazy" allow="accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>`
  3171. : `<a class="vid-fallback" href="${esc(s)}" target="_blank" rel="noopener">在 YouTube 打开视频 ↗</a>`;
  3172. }
  3173. // 其他平台(抖音等)走同源视频代理:补 Referer + Range 流式,失败兜底源站链接
  3174. return `<video src="${esc(vidProxy(s))}" data-src="${esc(s)}" controls preload="metadata" playsinline onerror="vidFallback(this)"></video>`;
  3175. })
  3176. .join("")
  3177. : "";
  3178. $("#pd-tags").innerHTML = [
  3179. ...(p.knowledge_type || []).map((t) => "类型:" + t),
  3180. ...(p.found_by || []).map((q) => "命中:" + q),
  3181. ]
  3182. .map((t) => `<span class="pill">${esc(t)}</span>`)
  3183. .join("");
  3184. $("#pd-overall").innerHTML =
  3185. p.overall_score != null
  3186. ? `${p.overall_score}<span style="font-size:11px;color:var(--ink-faint);font-weight:500"> /10</span>`
  3187. : "—";
  3188. /* 评分卡:相关性 + 质量(均分 + 各维度,ⓘ hover 看理由) */
  3189. $("#pd-scores").innerHTML =
  3190. [
  3191. ["01", "相关性"],
  3192. ["02", "质量"],
  3193. ]
  3194. .map(([no, key], i) => {
  3195. const node = e[key];
  3196. if (!node) return "";
  3197. const vs = collectScores(node);
  3198. const avg = vs.length ? (vs.reduce((a, b) => a + b, 0) / vs.length).toFixed(1) : "N/A";
  3199. return `<div class="sc-card">
  3200. <div class="sc-card-head">
  3201. <span><span class="badge">${no}</span>${esc(key)}</span>
  3202. <span class="avg">均分 <b>${avg}</b>/10</span>
  3203. </div>
  3204. <div class="sc-card-body">${(key === "质量" ? renderQuality(node) : walkScores(node)) || '<span style="color:var(--ink-faint)">无评分</span>'}</div>
  3205. </div>`;
  3206. })
  3207. .join("") || '<div class="empty">无评估数据</div>';
  3208. $("#post-dialog").showModal();
  3209. }
  3210. /* ════ Dataset:右栏解构结果 ════ */
  3211. function renderExtractEmpty() {
  3212. $("#xp-head").innerHTML = '<span class="st">解构结果</span>';
  3213. $("#xp-body").innerHTML = '<div class="empty"><span class="glyph">←</span>选择一个帖子查看解构结果</div>';
  3214. }
  3215. async function selectPost(cid) {
  3216. state.caseId = cid;
  3217. state.version = null;
  3218. state.post = state.posts.find((p) => p.case_id === cid) || null;
  3219. renderPosts();
  3220. await ensurePostDetail(state.post); // 列表瘦身,补全正文/评估再渲染右侧详情
  3221. await loadExtract();
  3222. }
  3223. // 列表是瘦身数据(无 body/llm_evaluation/videos);详情按需取单帖并合并到对象上(合并后再点 0 往返)
  3224. async function ensurePostDetail(p) {
  3225. if (!p || p.body !== undefined) return p;
  3226. try {
  3227. const full = await api(`/api/post?mode=${state.mode}&query_id=`
  3228. + encodeURIComponent(state.queryId) + "&case_id=" + encodeURIComponent(p.case_id));
  3229. if (full) Object.assign(p, full);
  3230. } catch (e) { /* 详情取不到不阻断,正文/评分留空 */ }
  3231. return p;
  3232. }
  3233. /* ── 解构结果:客户端缓存 + 请求竞态守卫(解决「多次点击卡顿 / 残留上一帖」)──
  3234. · _extractCache:解构数据只在「重新解构」时变(由本页 startExtract 触发,届时清缓存),
  3235. 故缓存可长留——再次点开看过的帖 0 往返、瞬时渲染。
  3236. · _extractSeq:每次发起 +1;晚到的旧响应据 seq 丢弃,杜绝快速连点时旧响应覆盖新选中。 */
  3237. const _extractCache = new Map(); // key: mode|case_id|version → {versions,data,missing}
  3238. const _extractKey = (cid, ver) => `${state.mode}|${cid}|${ver || ""}`;
  3239. let _extractSeq = 0;
  3240. function invalidateExtractCache(cid) {
  3241. for (const k of [..._extractCache.keys()]) if (k.includes(`|${cid}|`)) _extractCache.delete(k);
  3242. }
  3243. async function loadExtract() {
  3244. if (!state.caseId) return renderExtractEmpty();
  3245. const isProc = state.mode === "process";
  3246. const seq = ++_extractSeq; // 本次请求序号
  3247. const key = _extractKey(state.caseId, state.version);
  3248. // 1) 命中缓存:瞬时渲染,0 往返
  3249. const cached = _extractCache.get(key);
  3250. if (cached) return paintExtract(cached, seq);
  3251. // 2) 未命中:立即显示「原文 + loading」。关键:重写 #xp-body 会移除上一帖的 <img>,
  3252. // 浏览器随即取消其 /api/img 下载,腾出每域 ~6 条连接额度,新的 /api/extract 不再
  3253. // 排在旧图片请求后面等待——这是「多次点击要等很久」的根因。同时给出加载态,
  3254. // 不再停留在上一帖的解构结果。
  3255. renderExtractHead([], null, false, true);
  3256. $("#xp-body").innerHTML =
  3257. renderSourceBlock() +
  3258. `<div class="empty"><span class="spinner"></span>正在加载${isProc ? "工序" : "工具"}解构…</div>`;
  3259. // 版本列表 + 解构详情合一,一个请求拿全(服务端同连接两查,ETag 命中可走 304)
  3260. const url =
  3261. `/api/extract?mode=${state.mode}&case_id=` +
  3262. encodeURIComponent(state.caseId) +
  3263. (state.version ? "&version=" + encodeURIComponent(state.version) : "");
  3264. let res;
  3265. try {
  3266. res = await api(url);
  3267. } catch (e) {
  3268. if (seq !== _extractSeq) return; // 已切到别的帖,丢弃本响应
  3269. $("#xp-body").innerHTML = renderSourceBlock() + '<div class="empty">解构数据加载失败,请重试</div>';
  3270. return;
  3271. }
  3272. if (seq !== _extractSeq) return; // 晚到的旧响应:不覆盖新选中
  3273. const payload = { versions: res.versions || [], data: res.data, missing: res.missing || !res.data };
  3274. _extractCache.set(key, payload);
  3275. paintExtract(payload, seq);
  3276. }
  3277. function paintExtract({ versions, data, missing }, seq) {
  3278. if (seq !== _extractSeq) return; // 渲染前再校验(缓存命中路径也经此)
  3279. const isProc = state.mode === "process";
  3280. renderExtractHead(versions, data, missing);
  3281. const body = $("#xp-body");
  3282. if (missing || !data) {
  3283. body.innerHTML =
  3284. renderSourceBlock() +
  3285. `<div class="empty">该帖暂无${isProc ? "工序" : "工具"}解构<br><br>
  3286. <button class="btn primary" onclick="startExtract(['${esc(state.caseId)}'])">开始解构</button></div>`;
  3287. return;
  3288. }
  3289. state.version = data.version;
  3290. // 以「具体 version」补一条缓存别名,版本下拉切回时也能命中
  3291. _extractCache.set(_extractKey(state.caseId, data.version), { versions, data, missing });
  3292. syncVersionSelect();
  3293. body.innerHTML = isProc ? renderProcedures(data) : renderTools(data);
  3294. requestAnimationFrame(markSrcTextClamp);
  3295. if (isProc) requestAnimationFrame(markStepClamps);
  3296. else requestAnimationFrame(markClampedCells);
  3297. }
  3298. function renderExtractHead(versions, data, missing, loading) {
  3299. const isProc = state.mode === "process";
  3300. const title = state.post ? esc(state.post.title || state.caseId) : esc(state.caseId || "");
  3301. const opts = versions
  3302. .map(
  3303. (v, i) =>
  3304. `<option value="${esc(v.version)}">${esc(v.version)}${i === 0 ? " (最新)" : ""} · ${v.n}${isProc ? "工序" : "工具"}</option>`,
  3305. )
  3306. .join("");
  3307. const stat = loading ? "加载中…" : missing ? "未提取" : "已提取";
  3308. $("#xp-head").innerHTML = `
  3309. <span class="st">大模型${isProc ? "工序" : "工具"}:<em>${stat}</em></span>
  3310. <span style="font-size:12px;color:var(--ink-faint);max-width:330px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap" title="${title}">${title}</span>
  3311. <span class="spacer"></span>
  3312. ${versions.length ? `<select id="ver-sel">${opts}</select>` : ""}
  3313. <button class="btn sm primary" onclick="openReextractDialog()">${missing ? "提取" : "♻ 重新生成"}</button>
  3314. <button class="btn sm" onclick="showTaskPanel()" title="重新打开任务日志面板">📋 操作日志</button>`;
  3315. const vs = $("#ver-sel");
  3316. if (vs)
  3317. vs.onchange = () => {
  3318. state.version = vs.value;
  3319. loadExtract();
  3320. };
  3321. }
  3322. function syncVersionSelect() {
  3323. const vs = $("#ver-sel");
  3324. if (vs && state.version) vs.value = state.version;
  3325. }
  3326. /* ── 原文卡片:标题 + 图片缩略图(横滑、可灯箱预览)+ 正文(定高可展开),整体可收起 ── */
  3327. let srcOpen = true,
  3328. srcTextOpen = false;
  3329. function renderSourceBlock() {
  3330. const p = state.post;
  3331. if (!p || !(p.title || (p.images || []).length || p.body)) return "";
  3332. const imgs = (p.images || []).filter(Boolean);
  3333. const thumbs = imgs.length
  3334. ? `<div class="src-thumbs">${imgs
  3335. .map(
  3336. (s, i) =>
  3337. imgHtml(s, { extra: `onclick="openSrcLightbox(${i})"` }),
  3338. )
  3339. .join("")}</div>`
  3340. : "";
  3341. const body = p.body
  3342. ? `<div class="src-text${srcTextOpen ? "" : " clamp"}" id="src-text">${esc(p.body)}</div>
  3343. <button class="src-text-toggle" id="src-text-toggle" onclick="toggleSrcText()" hidden>${srcTextOpen ? "收起 ▲" : "展开 ▼"}</button>`
  3344. : "";
  3345. const link = p.url
  3346. ? `<a class="src-link" href="${esc(p.url)}" target="_blank" rel="noreferrer" onclick="event.stopPropagation()">原文 ↗</a>`
  3347. : "";
  3348. return `<div class="src-block${srcOpen ? " open" : ""}" id="src-block">
  3349. <div class="src-head" onclick="toggleSrc()">
  3350. <span class="src-caret">▸</span>
  3351. <span class="src-label">原文</span>
  3352. <span class="src-title">${esc(p.title || "(无标题)")}</span>
  3353. ${link}
  3354. <span class="src-case" title="case_id" onclick="event.stopPropagation()">${esc(p.case_id || "")}</span>
  3355. </div>
  3356. <div class="src-body">${thumbs}${body}</div>
  3357. </div>`;
  3358. }
  3359. function toggleSrc() {
  3360. srcOpen = !srcOpen;
  3361. const b = $("#src-block");
  3362. if (b) b.classList.toggle("open", srcOpen);
  3363. requestAnimationFrame(markSrcTextClamp);
  3364. }
  3365. function toggleSrcText() {
  3366. srcTextOpen = !srcTextOpen;
  3367. const t = $("#src-text"),
  3368. btn = $("#src-text-toggle");
  3369. if (t) t.classList.toggle("clamp", !srcTextOpen);
  3370. if (btn) btn.textContent = srcTextOpen ? "收起 ▲" : "展开 ▼";
  3371. }
  3372. function openSrcLightbox(i) {
  3373. lb.imgs = ((state.post && state.post.images) || []).filter(Boolean);
  3374. openLightbox(i);
  3375. }
  3376. /* 仅当正文在定高下溢出时才显示「展开」按钮(需在可见、未展开态测量) */
  3377. function markSrcTextClamp() {
  3378. const t = $("#src-text"),
  3379. btn = $("#src-text-toggle");
  3380. if (!t || !btn) return;
  3381. if (srcTextOpen) {
  3382. btn.hidden = false;
  3383. return;
  3384. }
  3385. btn.hidden = !(t.scrollHeight > t.clientHeight + 2);
  3386. }
  3387. /* ── 工序渲染 ── */
  3388. function renderProcedures(data) {
  3389. const src = data.source || {};
  3390. return (
  3391. renderSourceBlock() +
  3392. (data.procedures || [])
  3393. .map((p) => {
  3394. const d = p.declarations || {};
  3395. const ins =
  3396. (d.inputs || [])
  3397. .map(
  3398. (x) =>
  3399. `<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>` : ""}`,
  3400. )
  3401. .join("<br>") || '<span style="color:var(--ink-faint)">无</span>';
  3402. const ret = d.returns
  3403. ? `<span class="pill teal">${esc(d.returns.type || "")}</span>`
  3404. : '<span style="color:var(--ink-faint)">无</span>';
  3405. return `<div class="proc">
  3406. <div class="proc-head">
  3407. <div class="nm"><span class="pid">工序 ${esc(p.id || "")}</span>${esc(p.name || "")}</div>
  3408. ${p.purpose ? `<div class="pp">#目的:${esc(p.purpose)}</div>` : ""}
  3409. <div class="meta">
  3410. ${p.category ? `<span class="pill red">类别:${esc(p.category)}</span>` : ""}
  3411. ${src.platform ? `<span class="pill">#平台:${esc(src.platform)}</span>` : ""}
  3412. ${src.author ? `<span class="pill">#作者:${esc(src.author)}</span>` : ""}
  3413. <span class="pill">case:${esc(data.case_id)}</span>
  3414. ${(p.tools_used || []).map((t) => `<span class="pill teal">${esc(t)}</span>`).join("")}
  3415. </div>
  3416. </div>
  3417. <div class="decl">
  3418. <div><div class="dl">输入</div><div class="di">${ins}</div></div>
  3419. <div><div class="dl">返回</div><div class="di">${ret}</div></div>
  3420. </div>
  3421. ${renderSteps(p.steps || [])}
  3422. </div>`;
  3423. })
  3424. .join("") || '<div class="empty">本版本无工序</div>'
  3425. );
  3426. }
  3427. function renderSteps(steps) {
  3428. if (!steps.length) return '<div class="empty">无步骤</div>';
  3429. let rows = "";
  3430. for (const s of steps) {
  3431. const ins = s.inputs && s.inputs.length ? s.inputs : [null];
  3432. const outs = s.outputs && s.outputs.length ? s.outputs : [null];
  3433. const n = Math.max(ins.length, outs.length);
  3434. for (let i = 0; i < n; i++) {
  3435. rows += "<tr>";
  3436. if (i === 0) {
  3437. rows += `<td rowspan="${n}" class="sid">${esc(s.id || "")}</td>
  3438. <td rowspan="${n}"><div class="intent-text">${renderIntent(s.intent || s.directive || "")}</div></td>
  3439. <td rowspan="${n}">${s.effect ? `<span class="pill navy">${esc(s.effect)}</span>` : ""}</td>
  3440. <td rowspan="${n}">${esc(fmtSF(s.substance))}</td>
  3441. <td rowspan="${n}">${esc(fmtSF(s.form))}</td>`;
  3442. }
  3443. rows += ioCell(ins[i], "in");
  3444. if (i === 0) {
  3445. rows += `<td rowspan="${n}">${s.via ? `<span class="pill teal">${esc(s.via)}</span>` : ""}</td>
  3446. <td rowspan="${n}" class="vtxt">${esc(s.action || "")}</td>`;
  3447. }
  3448. rows += ioCell(outs[i], "out");
  3449. rows += "</tr>";
  3450. }
  3451. }
  3452. return `<div style="overflow-x:auto"><table class="steps">
  3453. <colgroup>
  3454. <col style="width:44px"><col style="width:200px"><col style="width:92px">
  3455. <col style="width:112px"><col style="width:100px">
  3456. <col style="width:112px"><col style="width:330px"><col style="width:92px">
  3457. <col style="width:118px"><col style="width:130px">
  3458. <col style="width:112px"><col style="width:360px"><col style="width:110px">
  3459. </colgroup>
  3460. <thead>
  3461. <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>
  3462. <tr>
  3463. <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>
  3464. <th class="h-in2">类型</th><th class="h-in2">值</th><th class="h-in2">来源</th>
  3465. <th class="h-im2">外部工具</th><th class="h-im2">动作</th>
  3466. <th class="h-out2">类型</th><th class="h-out2">值</th><th class="h-out2">去处</th>
  3467. </tr>
  3468. </thead><tbody>${rows}</tbody></table></div>`;
  3469. }
  3470. function fmtSF(v) {
  3471. return v == null ? "" : Array.isArray(v) ? v.join("、") : v;
  3472. }
  3473. function ioCell(x, kind) {
  3474. const cls = kind === "in" ? "c-in" : "c-out";
  3475. if (!x) return `<td class="${cls}"></td><td class="${cls}"></td><td class="${cls}"></td>`;
  3476. const inf = x.inferred ? ` inf" title="推断理由:${esc(x.inferred_reason || "模型推断补全")}` : "";
  3477. const badge = x.inferred ? '<span class="ib">推</span>' : "";
  3478. return `<td class="${cls}"><span class="pill ${kind === "in" ? "amber" : "blue"}">${esc(x.type || "")}</span></td>
  3479. <td class="${cls}${inf}">${badge}<div class="clamp-val" onclick="toggleClampVal(this)"><span class="vtxt">${esc(x.value || "")}</span></div></td>
  3480. <td class="${cls}"><span class="anchor">${esc(x.anchor || "")}</span></td>`;
  3481. }
  3482. /* 点击「值」单元格展开/收起(仅在内容溢出、已标记 clampable 时生效) */
  3483. function toggleClampVal(el) {
  3484. if (!el.classList.contains("clampable") && !el.classList.contains("open")) return;
  3485. el.classList.toggle("open");
  3486. }
  3487. /* 渲染后标记真正溢出 4 行的「值」单元格:先套限高再测量,溢出才保留 clampable */
  3488. function markStepClamps() {
  3489. document.querySelectorAll("#xp-body .steps .clamp-val").forEach((el) => {
  3490. if (el.classList.contains("open")) return;
  3491. el.classList.add("clampable");
  3492. if (el.scrollHeight <= el.clientHeight + 2) el.classList.remove("clampable");
  3493. });
  3494. }
  3495. /* ── 工具渲染(表格,移植自 fixed_query_eval renderToolTable)── */
  3496. const DASH = '<span class="dash">—</span>';
  3497. function _toolCell(v) {
  3498. if (v === null || v === undefined || v === "" || (Array.isArray(v) && !v.length)) return DASH;
  3499. if (Array.isArray(v)) return "<ul>" + v.map((x) => `<li>${esc(String(x))}</li>`).join("") + "</ul>";
  3500. return esc(String(v));
  3501. }
  3502. function _scopeCell(v) {
  3503. /* 作用域是 JSON 数组:按「、」拼接成短语,不出列表 */
  3504. if (v === null || v === undefined || (Array.isArray(v) && !v.length) || v === "") return DASH;
  3505. return esc(Array.isArray(v) ? v.join("、") : String(v));
  3506. }
  3507. function _ttCell(inner, clampable) {
  3508. return clampable ? `<div class="tcell" onclick="this.classList.toggle('open')">${inner}</div>` : inner;
  3509. }
  3510. function _toolCellContent(c, t) {
  3511. let inner,
  3512. cls = "",
  3513. clampable = true,
  3514. style = "";
  3515. if (c === "工具名称") {
  3516. cls = "col-tool";
  3517. clampable = false;
  3518. inner = `🔧 ${esc(t[c] || "(未命名)")}`;
  3519. } else if (c === "来源链接") {
  3520. clampable = false;
  3521. inner = t[c]
  3522. ? `<a href="${esc(t[c])}" target="_blank" style="color:#176d64;font-weight:600;">🔗 打开</a>`
  3523. : DASH;
  3524. } else if (c === "创作层级") {
  3525. clampable = false;
  3526. inner = t[c]
  3527. ? `<span class="layer-badge ${t[c] === "制作层" ? "make" : "create"}">${esc(t[c])}</span>`
  3528. : DASH;
  3529. } else if (c === "实质作用域" || c === "形式作用域") {
  3530. inner = _scopeCell(t[c]);
  3531. } else {
  3532. inner = _toolCell(t[c]);
  3533. }
  3534. if (["输入", "输出", "用法", "缺点"].includes(c)) style = "max-width:240px;";
  3535. else if (c === "实质作用域" || c === "形式作用域") style = "max-width:170px;";
  3536. else if (!clampable) style = "white-space:nowrap;";
  3537. return { inner, cls, clampable, style };
  3538. }
  3539. function _td(c, t, rowspan) {
  3540. const { inner, cls, clampable, style } = _toolCellContent(c, t);
  3541. const rs = rowspan > 1 ? ` rowspan="${rowspan}"` : "";
  3542. return `<td class="${cls}" style="${style}"${rs}>${_ttCell(inner, clampable)}</td>`;
  3543. }
  3544. function _caseTd(cse, key) {
  3545. const v = cse && cse[key] != null && cse[key] !== "" ? esc(String(cse[key])) : DASH;
  3546. return `<td class="col-case" style="max-width:210px;">${_ttCell(v, true)}</td>`;
  3547. }
  3548. function renderTools(data) {
  3549. const tools = data.tools || [];
  3550. if (!tools.length) return renderSourceBlock() + '<div class="empty">本版本无工具</div>';
  3551. /* 案例 group(输入/输出/效果)放在 用法 后、缺点 前;用 colspan/rowspan 做两层表头 */
  3552. const before = ["工具名称", "创作层级", "实质作用域", "形式作用域", "输入", "输出", "用法"];
  3553. const after = ["缺点", "来源链接", "最新更新时间"];
  3554. const thead = `<thead>
  3555. <tr>
  3556. ${before.map((c) => `<th rowspan="2">${c}</th>`).join("")}
  3557. <th colspan="3" class="th-group">案例</th>
  3558. ${after.map((c) => `<th rowspan="2">${c}</th>`).join("")}
  3559. </tr>
  3560. <tr>${["输入", "输出", "效果"].map((c) => `<th class="th-sub">${c}</th>`).join("")}</tr>
  3561. </thead>`;
  3562. const rows = tools
  3563. .map((t, ti) => {
  3564. const cases = Array.isArray(t["案例"]) && t["案例"].length ? t["案例"] : [null];
  3565. const K = cases.length;
  3566. const par = ti % 2 ? "tr-b" : "tr-a";
  3567. return cases
  3568. .map((cse, i) => {
  3569. const caseTds = `${_caseTd(cse, "输入")}${_caseTd(cse, "输出")}${_caseTd(cse, "效果")}`;
  3570. if (i === 0) {
  3571. return `<tr class="${par}">${before.map((c) => _td(c, t, K)).join("")}${caseTds}${after.map((c) => _td(c, t, K)).join("")}</tr>`;
  3572. }
  3573. return `<tr class="${par}">${caseTds}</tr>`;
  3574. })
  3575. .join("");
  3576. })
  3577. .join("");
  3578. return (
  3579. renderSourceBlock() +
  3580. `<div class="mw-ttwrap"><table class="mw-tt">${thead}<tbody>${rows}</tbody></table></div>`
  3581. );
  3582. }
  3583. /* 渲染后标记真正溢出的单元格(才显示蒙版+可点击) */
  3584. function markClampedCells() {
  3585. document.querySelectorAll("#xp-body .mw-tt .tcell").forEach((el) => {
  3586. if (!el.classList.contains("open") && el.scrollHeight > el.clientHeight + 2) el.classList.add("clamped");
  3587. else if (el.scrollHeight <= el.clientHeight + 2) el.classList.remove("clamped");
  3588. });
  3589. }
  3590. /* ════ 重新解构 · 编辑 Prompt 弹框 ════ */
  3591. async function openReextractDialog() {
  3592. if (!state.caseId) {
  3593. toast("请先选择帖子", "info");
  3594. return;
  3595. }
  3596. const isProc = state.mode === "process";
  3597. const dlg = $("#reextract-dlg"),
  3598. sel = $("#rx-model"),
  3599. ta = $("#rx-prompt"),
  3600. save = $("#rx-save");
  3601. sel.innerHTML = (isProc ? MODELS_PROC : MODELS_TOOL)
  3602. .map((m) => `<option>${m}</option>`)
  3603. .join("");
  3604. ta.value = "加载中…";
  3605. ta.disabled = save.disabled = true;
  3606. dlg.showModal();
  3607. try {
  3608. const r = await api(`/api/extract_prompt?mode=${state.mode}`);
  3609. ta.value = r.prompt || "";
  3610. } catch (e) {
  3611. ta.value = "";
  3612. toast("加载 Prompt 失败:" + (e.body?.error || e.status), "error");
  3613. } finally {
  3614. ta.disabled = save.disabled = false;
  3615. }
  3616. }
  3617. async function saveReextract() {
  3618. const cid = state.caseId;
  3619. if (!cid) return;
  3620. const model = $("#rx-model").value,
  3621. prompt = $("#rx-prompt").value;
  3622. $("#reextract-dlg").close();
  3623. // 临时 prompt 覆盖 + force 重解构(仅本次生效,不改默认 Prompt)
  3624. await startExtract([cid], { model, prompt, force: true });
  3625. }
  3626. /* ════ 解构任务 ════ */
  3627. async function startExtract(caseIds, opts = {}) {
  3628. if (!state.queryId || !caseIds.length) return;
  3629. const isProc = state.mode === "process";
  3630. const model = opts.model || (isProc ? MODELS_PROC[0] : MODELS_TOOL[0]);
  3631. try {
  3632. const body = { query_id: state.queryId, case_ids: caseIds, model };
  3633. if (opts.prompt != null) body.prompt = opts.prompt; // 临时 prompt 覆盖(仅本次)
  3634. if (opts.force) body.force = true; // 换 prompt/模型重解构需跳过去重
  3635. const r = await api(`/api/extract_${isProc ? "process" : "tools"}`, {
  3636. method: "POST",
  3637. body: JSON.stringify(body),
  3638. });
  3639. // 全部正在解构中(被认领跳过):没有 task_id,提示一下即可,别去轮询空任务
  3640. if (!r.task_id) {
  3641. toast(r.note || "所选帖子正在解构中,已跳过", "info");
  3642. return;
  3643. }
  3644. if ((r.skipped || []).length) toast(`${r.skipped.length} 帖正在解构中,已跳过`, "info");
  3645. showTask(`${isProc ? "工序" : "工具"}解构 · ${caseIds.length} 帖`, r.task_id, async () => {
  3646. state.selected.clear();
  3647. caseIds.forEach(invalidateExtractCache); // 重新解构后数据已变,清这些帖的缓存
  3648. await selectQuery(state.queryId);
  3649. if (caseIds.includes(state.caseId)) {
  3650. /* selectQuery 清了 caseId,恢复选中 */
  3651. }
  3652. if (caseIds.length === 1) {
  3653. state.caseId = caseIds[0];
  3654. state.version = null;
  3655. renderPosts();
  3656. await loadExtract();
  3657. }
  3658. });
  3659. } catch (e) {
  3660. toast("任务启动失败:" + (e.body?.error || e.status), "error");
  3661. }
  3662. }
  3663. /* ════ 任务面板(✕ 只隐藏;「操作日志」按钮可随时唤回)════ */
  3664. let pollTimer = null,
  3665. hasTask = false;
  3666. // 自建确认弹框(替代浏览器原生 confirm):返回 Promise<bool>。Enter=确定 / Esc=取消 / 点遮罩=取消
  3667. function uiConfirm(message, opt = {}) {
  3668. const { okText = "确定", cancelText = "取消" } = opt;
  3669. return new Promise((resolve) => {
  3670. const bg = document.createElement("div");
  3671. bg.className = "ui-confirm-bg";
  3672. bg.innerHTML =
  3673. '<div class="ui-confirm"><div class="ui-confirm-msg"></div>'
  3674. + '<div class="ui-confirm-acts">'
  3675. + '<button class="btn" data-act="cancel"></button>'
  3676. + '<button class="btn seal" data-act="ok"></button></div></div>';
  3677. bg.querySelector(".ui-confirm-msg").textContent = message;
  3678. bg.querySelector('[data-act="cancel"]').textContent = cancelText;
  3679. bg.querySelector('[data-act="ok"]').textContent = okText;
  3680. document.body.appendChild(bg);
  3681. const done = (v) => { bg.remove(); document.removeEventListener("keydown", onKey, true); resolve(v); };
  3682. bg.addEventListener("click", (e) => {
  3683. if (e.target === bg) return done(false);
  3684. const a = e.target.closest("[data-act]");
  3685. if (a) done(a.dataset.act === "ok");
  3686. });
  3687. const onKey = (e) => {
  3688. if (e.key === "Escape") { e.preventDefault(); done(false); }
  3689. else if (e.key === "Enter") { e.preventDefault(); done(true); }
  3690. };
  3691. document.addEventListener("keydown", onKey, true);
  3692. bg.querySelector('[data-act="ok"]').focus();
  3693. });
  3694. }
  3695. function showTask(title, taskId, onDone, onSettled) {
  3696. hasTask = true;
  3697. $("#task-panel").hidden = false;
  3698. $("#task-title").textContent = title;
  3699. $("#task-dot").className = "dot";
  3700. $("#task-log").textContent = "启动中…";
  3701. clearTimeout(pollTimer);
  3702. const poll = async () => {
  3703. let t;
  3704. try {
  3705. t = await api("/api/task_status?task_id=" + encodeURIComponent(taskId));
  3706. } catch (e) {
  3707. $("#task-log").textContent = "状态查询失败";
  3708. if (onSettled) onSettled("error"); // 轮询出错也算结束,让调用方恢复按钮等
  3709. return;
  3710. }
  3711. const log = $("#task-log");
  3712. log.textContent = t.log_tail || "(暂无日志)";
  3713. log.scrollTop = log.scrollHeight;
  3714. if (t.status === "running") {
  3715. pollTimer = setTimeout(poll, 2000);
  3716. return;
  3717. }
  3718. $("#task-dot").className = "dot " + t.status;
  3719. $("#task-title").textContent = title + (t.status === "done" ? " · 完成" : " · 失败");
  3720. if (t.status === "done" && onDone) onDone();
  3721. if (onSettled) onSettled(t.status); // done / failed 都触发
  3722. };
  3723. poll();
  3724. }
  3725. /* ✕ 只隐藏面板,轮询照跑(任务完成后回调依然触发) */
  3726. function hideTask() {
  3727. $("#task-panel").hidden = true;
  3728. }
  3729. function showTaskPanel() {
  3730. if (!hasTask) return toast("本次会话还没有任务日志", "warn");
  3731. $("#task-panel").hidden = false;
  3732. const log = $("#task-log");
  3733. log.scrollTop = log.scrollHeight;
  3734. }
  3735. /* ════ Query 规则组织器 ════ */
  3736. // 扁平维度词表(移植自 query-builder.html DIMS);实质/形式 改为接口下钻,不在此。
  3737. const QR_FLAT = [
  3738. { id: "tool_type", label: "工具类型", items: ["AI", "桌面 APP", "云端 Web", "API·CLI", "插件扩展"] },
  3739. { id: "modality", label: "模态", items: ["图片", "视频"] },
  3740. { id: "suffix", label: "后缀", items: ["怎么做"] },
  3741. ];
  3742. const QR_TREE = [
  3743. { id: "substance", label: "实质", source: "实质" },
  3744. { id: "form", label: "形式", source: "形式" },
  3745. ];
  3746. const qrState = {
  3747. flat: { tool_type: null, modality: null, suffix: null },
  3748. treePath: { substance: [], form: [] }, // 实质/形式 选中 name 路径(仅作 Sonnet 上下文)
  3749. treeData: { substance: null, form: null },
  3750. axisPath: { action: [], type: [] }, // 动作/类型 筛选路径(l1/l2/叶子,来自 matrix,筛表显示)
  3751. matrix: null, // /api/query_matrix
  3752. scores: null, // 最近一次评分结果 cells
  3753. threshold: 7, // 达标 = keep 且 综合分≥此值(可在弹层调)
  3754. lastCost: null,
  3755. };
  3756. function qrChip(label, active, on, cls) {
  3757. const b = document.createElement("button");
  3758. b.className = "chip" + (cls ? " " + cls : "") + (active ? " on" : "");
  3759. b.textContent = label;
  3760. b.onclick = on;
  3761. return b;
  3762. }
  3763. function qrRow(root, labtxt) {
  3764. const row = document.createElement("div");
  3765. row.className = "qr-row";
  3766. row.innerHTML = `<span class="qr-lab">${labtxt}</span>`;
  3767. const wrap = document.createElement("span");
  3768. wrap.className = "qr-chips";
  3769. row.appendChild(wrap);
  3770. root.appendChild(row);
  3771. return wrap;
  3772. }
  3773. // 动作/类型 三级(l1/l2/叶子)取自 matrix items 的 l1/l2/name
  3774. function qrAxisLevelOptions(items, prefix) {
  3775. if (prefix.length === 0) return [...new Set(items.map((x) => x.l1))];
  3776. if (prefix.length === 1) return [...new Set(items.filter((x) => x.l1 === prefix[0]).map((x) => x.l2))];
  3777. return items.filter((x) => x.l1 === prefix[0] && x.l2 === prefix[1]).map((x) => x.name);
  3778. }
  3779. function qrAxisMatch(item, path) {
  3780. if (path[0] && item.l1 !== path[0]) return false;
  3781. if (path[1] && item.l2 !== path[1]) return false;
  3782. if (path[2] && item.name !== path[2]) return false;
  3783. return true;
  3784. }
  3785. function renderQrDims() {
  3786. const root = $("#qr-dims");
  3787. root.innerHTML = "";
  3788. // 扁平维度(工具类型/模态/后缀):拼词上下文
  3789. QR_FLAT.forEach((d) => {
  3790. const wrap = qrRow(root, `· ${d.label}`);
  3791. wrap.appendChild(qrChip("无", qrState.flat[d.id] == null, () => { qrState.flat[d.id] = null; renderQrDims(); renderQrTable(); }));
  3792. d.items.forEach((it) =>
  3793. wrap.appendChild(qrChip(it, qrState.flat[d.id] === it, () => { qrState.flat[d.id] = it; renderQrDims(); renderQrTable(); })));
  3794. });
  3795. // 实质/形式 接口下钻:仅作 Sonnet 上下文,不拼词、不筛表
  3796. QR_TREE.forEach((d) => {
  3797. const path = qrState.treePath[d.id];
  3798. let level = qrState.treeData[d.id] ? qrState.treeData[d.id].tree : [];
  3799. for (let depth = 0; ; depth++) {
  3800. const wrap = qrRow(root, depth === 0 ? `· ${d.label}` : "");
  3801. wrap.appendChild(qrChip("无", path.length === depth, () => { qrState.treePath[d.id] = path.slice(0, depth); renderQrDims(); }));
  3802. (level || []).forEach((node) =>
  3803. wrap.appendChild(qrChip(node.name, path[depth] === node.name,
  3804. () => { qrState.treePath[d.id] = [...path.slice(0, depth), node.name]; renderQrDims(); })));
  3805. const sel = (level || []).find((n) => n.name === path[depth]);
  3806. if (!sel || !(sel.children && sel.children.length)) break;
  3807. level = sel.children;
  3808. }
  3809. });
  3810. // 动作/类型 下钻(来自 matrix l1/l2):筛选表格显示
  3811. if (qrState.matrix) {
  3812. [{ id: "action", label: "动作", items: qrState.matrix.actions },
  3813. { id: "type", label: "类型", items: qrState.matrix.types }].forEach((d) => {
  3814. const path = qrState.axisPath[d.id];
  3815. for (let depth = 0; depth <= 2; depth++) {
  3816. const opts = qrAxisLevelOptions(d.items, path.slice(0, depth));
  3817. if (!opts.length) break;
  3818. const wrap = qrRow(root, depth === 0 ? `· ${d.label}` : "");
  3819. wrap.appendChild(qrChip("无", path.length === depth,
  3820. () => { qrState.axisPath[d.id] = path.slice(0, depth); renderQrDims(); renderQrTable(); }, "axis"));
  3821. opts.forEach((name) =>
  3822. wrap.appendChild(qrChip(name, path[depth] === name,
  3823. () => { qrState.axisPath[d.id] = [...path.slice(0, depth), name]; renderQrDims(); renderQrTable(); }, "axis")));
  3824. if (path[depth] == null) break; // 未选中本层 → 不展开下一层
  3825. }
  3826. });
  3827. }
  3828. }
  3829. async function qrOpen() {
  3830. qrClosePop();
  3831. renderQrDims();
  3832. // 并行拉矩阵 + 两棵分类树(接口挂则该维度降级:提示不可选)
  3833. try { qrState.matrix = qrState.matrix || await api("/api/query_matrix"); }
  3834. catch (e) { return toast("内容树矩阵加载失败", "error"); }
  3835. for (const d of QR_TREE) {
  3836. if (qrState.treeData[d.id]) continue;
  3837. try { qrState.treeData[d.id] = await api("/api/category_tree?source_type=" + encodeURIComponent(d.source)); }
  3838. catch (e) { toast(`${d.label} 接口不可达,该维度暂不可选`, "warn"); }
  3839. }
  3840. renderQrDims();
  3841. renderQrTable();
  3842. }
  3843. // 单格 query = [工具类型] 动作叶 类型叶 [模态] [后缀](与后端 query_score._build_cells 一致)
  3844. function qrCellQuery(action, type) {
  3845. const f = qrState.flat;
  3846. return [f.tool_type, action, type, f.modality, f.suffix].filter((x) => x && x !== "无").join(" ");
  3847. }
  3848. function renderQrTable() {
  3849. const m = qrState.matrix;
  3850. if (!m) return;
  3851. const { actions, types, matrix } = m;
  3852. const sc = qrState.scores; // {"ai_ti":{keep,score,rewrite,...}}
  3853. // 按 动作/类型 筛选路径过滤可见行列(保留原始索引 ai/ti 供评分键 ai_ti)
  3854. const aIdx = actions.map((_, i) => i).filter((i) => qrAxisMatch(actions[i], qrState.axisPath.action));
  3855. const tIdx = types.map((_, i) => i).filter((i) => qrAxisMatch(types[i], qrState.axisPath.type));
  3856. let html = '<table class="qr-tab"><thead>';
  3857. html += '<tr><th class="qr-corner" rowspan="2">类型 \\ 动作</th>';
  3858. const groups = [];
  3859. aIdx.forEach((ai) => {
  3860. const l1 = actions[ai].l1;
  3861. const last = groups[groups.length - 1];
  3862. if (last && last.l1 === l1) last.span++;
  3863. else groups.push({ l1, span: 1 });
  3864. });
  3865. groups.forEach((g) => { html += `<th colspan="${g.span}" class="qr-gh">${g.l1}</th>`; });
  3866. html += "</tr><tr>";
  3867. aIdx.forEach((ai) => { html += `<th class="qr-ah">${actions[ai].name}</th>`; });
  3868. html += "</tr></thead><tbody>";
  3869. let curL1 = null;
  3870. tIdx.forEach((ti) => {
  3871. const t = types[ti];
  3872. if (t.l1 !== curL1) {
  3873. curL1 = t.l1;
  3874. html += `<tr><td class="qr-tl1" colspan="${aIdx.length + 1}">${t.l1}</td></tr>`;
  3875. }
  3876. html += `<tr><th class="qr-th">${t.name}</th>`;
  3877. aIdx.forEach((ai) => {
  3878. const tier = (matrix[ai][ti] || {}).tier || 0;
  3879. const q = qrCellQuery(actions[ai].name, t.name);
  3880. const v = sc ? sc[`${ai}_${ti}`] : null;
  3881. const keep = qrKeep(v);
  3882. const cls = `qr-c t${tier}` + (tier === 0 ? " dead" : "") + (keep ? " keep" : "");
  3883. const badge = keep && v.score != null ? `<i class="qr-bd">${v.score}</i>` : "";
  3884. html += `<td class="${cls}" data-ai="${ai}" data-ti="${ti}">${q}${badge}</td>`;
  3885. });
  3886. html += "</tr>";
  3887. });
  3888. html += "</tbody></table>";
  3889. $("#qr-table-wrap").innerHTML = html;
  3890. }
  3891. function qrSelBody() {
  3892. return {
  3893. tool_type: qrState.flat.tool_type || "",
  3894. modality: qrState.flat.modality || "",
  3895. suffix: qrState.flat.suffix || "",
  3896. substance_path: qrState.treePath.substance,
  3897. form_path: qrState.treePath.form,
  3898. };
  3899. }
  3900. async function qrLoadScores(sel) {
  3901. const r = await api("/api/query_score?sel=" + encodeURIComponent(sel));
  3902. if (r && r.pending) return false;
  3903. qrState.scores = r.cells || {};
  3904. qrState.lastCost = r.cost_usd;
  3905. renderQrTable();
  3906. qrRefreshKeep();
  3907. return true;
  3908. }
  3909. // 达标 = Sonnet keep 且 综合分≥阈值;高亮/计数/搜全部达标 统一口径
  3910. function qrKeep(v) { return !!(v && v.keep && v.score != null && v.score >= qrState.threshold); }
  3911. function qrRefreshKeep() {
  3912. if (!qrState.scores) return;
  3913. const k = Object.values(qrState.scores).filter(qrKeep).length;
  3914. $("#qr-hint").textContent = `达标(keep 且 ≥${qrState.threshold}):${k} 格`
  3915. + (qrState.lastCost != null ? ` · 评分 $${qrState.lastCost}` : "");
  3916. $("#qr-search-all").hidden = k === 0;
  3917. }
  3918. $("#qr-thr").addEventListener("input", () => {
  3919. const x = parseFloat($("#qr-thr").value);
  3920. qrState.threshold = isNaN(x) ? 0 : x;
  3921. if (qrState.scores) { qrClosePop(); renderQrTable(); qrRefreshKeep(); }
  3922. });
  3923. $("#qr-score").onclick = async () => {
  3924. const btn = $("#qr-score");
  3925. if (btn.disabled) return; // 评分进行中:防重复点击(避免重复起任务/花钱)
  3926. const orig = btn.textContent;
  3927. btn.disabled = true; btn.textContent = "评估中…";
  3928. const restore = () => { btn.disabled = false; btn.textContent = orig; };
  3929. renderQrTable(); // 先按当前 chips 刷新拼词
  3930. $("#qr-hint").textContent = "提交评分…";
  3931. let r;
  3932. try { r = await api("/api/query_score", { method: "POST", body: JSON.stringify(qrSelBody()) }); }
  3933. catch (e) { toast("评分启动失败:" + (e.body?.error || e.status), "error"); return restore(); }
  3934. if (r.cached) { try { await qrLoadScores(r.sel); } finally { restore(); } return; }
  3935. // 后台任务:完成→载入结果;成功/失败/查询出错 都恢复按钮(onSettled)
  3936. showTask("Query 评分 · 643 格", r.task_id,
  3937. async () => { await qrLoadScores(r.sel); },
  3938. (status) => { if (status !== "done") toast("评分任务" + (status === "failed" ? "失败" : "状态异常") + ",可重试", "warn"); restore(); });
  3939. };
  3940. async function qrRunSearch(query, label) {
  3941. const body = { query, platforms: "xhs,gzh", max_count: 20 }; // 用改写词搜索,方向无关
  3942. if (label && label !== query) body.query_text = label; // query 列表存原始组合词
  3943. const r = await api("/api/run_search", { method: "POST", body: JSON.stringify(body) });
  3944. return r; // {task_id, query_id}
  3945. }
  3946. // 点高亮格 → 气泡显示评分/理由 + 发起搜索/复制(不再用浏览器原生 confirm)
  3947. function qrClosePop() { $("#qr-pop").hidden = true; }
  3948. function qrShowPop(td, v) {
  3949. const pop = $("#qr-pop");
  3950. const query = v.rewrite || v.query;
  3951. const orig = v.rewrite && v.rewrite !== v.query ? `<div class="orig">原: ${v.query}</div>` : "";
  3952. const tier = td.classList.contains("t3") ? 3 : td.classList.contains("t2") ? 2 : td.classList.contains("t1") ? 1 : 0;
  3953. pop.innerHTML =
  3954. `<div class="q">${query}</div>${orig}` +
  3955. `<div class="sc"><b>${v.score ?? "?"}</b><span class="dim">综合分 = 人话 ${v.natural ?? "?"}×.4 + 可搜 ${v.findable ?? "?"}×.3 + 价值 ${v.useful ?? "?"}×.3</span></div>` +
  3956. `<div class="dim" style="margin:0 0 7px">内容树 tier ${tier}(人工预判可检索度,仅参考,不计入综合分)</div>` +
  3957. `<div class="rsn">${v.reason || "(无理由)"}</div>` +
  3958. `<div class="acts"><button class="btn seal" id="qr-pop-go">发起搜索</button><button class="btn" id="qr-pop-copy">复制</button></div>`;
  3959. pop.hidden = false;
  3960. const r = td.getBoundingClientRect(), pw = 300, ph = pop.offsetHeight || 150;
  3961. let left = r.left, top = r.bottom + 6;
  3962. if (left + pw > window.innerWidth - 10) left = window.innerWidth - pw - 10;
  3963. if (top + ph > window.innerHeight - 10) top = r.top - ph - 6;
  3964. pop.style.left = Math.max(10, left) + "px";
  3965. pop.style.top = Math.max(10, top) + "px";
  3966. $("#qr-pop-go").onclick = async () => {
  3967. qrClosePop();
  3968. try { const rr = await qrRunSearch(query, v.query); showTask(`搜索 · ${rr.query_id} ${query}`, rr.task_id, null); }
  3969. catch (err) { toast("搜索启动失败:" + (err.body?.error || err.status), "error"); }
  3970. };
  3971. $("#qr-pop-copy").onclick = () => { navigator.clipboard && navigator.clipboard.writeText(query); toast("已复制", "info", 1200); };
  3972. }
  3973. $("#qr-table-wrap").onclick = (e) => {
  3974. const td = e.target.closest("td.qr-c.keep");
  3975. if (!td) return;
  3976. const v = qrState.scores && qrState.scores[`${td.dataset.ai}_${td.dataset.ti}`];
  3977. if (v) qrShowPop(td, v);
  3978. };
  3979. // 点气泡外/表格空白处 关闭气泡
  3980. $("#qr-modal").addEventListener("click", (e) => {
  3981. if (!e.target.closest("#qr-pop") && !e.target.closest("td.qr-c.keep")) qrClosePop();
  3982. });
  3983. // 搜全部达标:逐格起任务(朴素循环,失败不阻断)
  3984. // 批量进度面板:任务面板里列出每个搜索的实时状态(轮询各 task_id)
  3985. function showQrBatch(items) {
  3986. hasTask = true;
  3987. $("#task-panel").hidden = false;
  3988. $("#task-title").textContent = `搜全部达标 · ${items.length} 个`;
  3989. $("#task-dot").className = "dot";
  3990. clearTimeout(pollTimer);
  3991. const st = {};
  3992. const poll = async () => {
  3993. await Promise.all(items.map(async (it) => {
  3994. if (st[it.task_id] && st[it.task_id] !== "running") return;
  3995. try { const t = await api("/api/task_status?task_id=" + encodeURIComponent(it.task_id)); st[it.task_id] = t.status; }
  3996. catch (e) { st[it.task_id] = st[it.task_id] || "running"; }
  3997. }));
  3998. const done = items.filter((it) => st[it.task_id] && st[it.task_id] !== "running").length;
  3999. $("#task-title").textContent = `搜全部达标 · ${done}/${items.length} 完成`;
  4000. $("#task-log").textContent = items.map((it) => {
  4001. const s = st[it.task_id] || "running";
  4002. return `${s === "done" ? "✅" : s === "failed" ? "❌" : "⏳"} ${it.query_id} ${it.query}`;
  4003. }).join("\n");
  4004. if (done < items.length) pollTimer = setTimeout(poll, 2000);
  4005. else $("#task-dot").className = "dot done";
  4006. };
  4007. poll();
  4008. }
  4009. $("#qr-search-all").onclick = async () => {
  4010. const keeps = Object.entries(qrState.scores || {}).filter(([, v]) => qrKeep(v));
  4011. if (!keeps.length) return;
  4012. if (!(await uiConfirm(`将对 ${keeps.length} 个达标 query 各起一次搜索(小红书+公众号 各20),确认?`))) return;
  4013. qrClosePop();
  4014. const items = [];
  4015. for (const [, v] of keeps) {
  4016. const q = v.rewrite || v.query;
  4017. try { const r = await qrRunSearch(q, v.query); if (r.task_id) items.push({ query: q, query_id: r.query_id, task_id: r.task_id }); }
  4018. catch (e) { /* 单格失败不阻断 */ }
  4019. }
  4020. if (!items.length) return toast("全部发起失败", "error");
  4021. toast(`已发起 ${items.length}/${keeps.length} 个搜索`, "info");
  4022. showQrBatch(items);
  4023. };
  4024. /* ════ 新建搜索 ════ */
  4025. /* 渠道下拉多选(选项同 search_eval:小红书/知乎/公众号/抖音/视频号/YouTube) */
  4026. const CHANNELS = [
  4027. { key: "xhs", name: "小红书", on: true },
  4028. { key: "zhihu", name: "知乎", on: true },
  4029. { key: "gzh", name: "公众号" },
  4030. { key: "douyin", name: "抖音" },
  4031. { key: "sph", name: "视频号" },
  4032. { key: "youtube", name: "YouTube" },
  4033. ];
  4034. $("#s-plat-panel").innerHTML = CHANNELS.map(
  4035. (c) => `
  4036. <label class="dd-opt ${c.on ? "sel" : ""}">
  4037. <input type="checkbox" value="${c.key}" ${c.on ? "checked" : ""}>${c.name}
  4038. </label>`,
  4039. ).join("");
  4040. function selectedPlatforms() {
  4041. return [...document.querySelectorAll("#s-plat-panel input:checked")].map((x) => x.value);
  4042. }
  4043. function syncPlatBtn() {
  4044. const names = [...document.querySelectorAll("#s-plat-panel input:checked")].map(
  4045. (x) => CHANNELS.find((c) => c.key === x.value).name,
  4046. );
  4047. $("#s-plat-btn").innerHTML =
  4048. `<span>${names.length ? esc(names.join("、")) : "选择渠道"}</span><span class="dd-arrow">▾</span>`;
  4049. }
  4050. $("#s-plat-btn").onclick = (e) => {
  4051. e.stopPropagation();
  4052. $("#s-plat-panel").hidden = !$("#s-plat-panel").hidden;
  4053. };
  4054. $("#s-plat-panel").onclick = (e) => e.stopPropagation();
  4055. $("#s-plat-panel").addEventListener("change", (e) => {
  4056. e.target.closest(".dd-opt").classList.toggle("sel", e.target.checked);
  4057. syncPlatBtn();
  4058. });
  4059. document.addEventListener("click", () => {
  4060. $("#s-plat-panel").hidden = true;
  4061. });
  4062. syncPlatBtn();
  4063. $("#btn-new-search").onclick = () => {
  4064. $("#s-mode").value = state.mode === "process" ? "工序" : "工具"; // 默认跟随当前子模式
  4065. $("#search-modal").hidden = false;
  4066. $("#s-query").focus();
  4067. };
  4068. $("#search-modal").onclick = (e) => {
  4069. if (e.target === $("#search-modal")) $("#search-modal").hidden = true;
  4070. };
  4071. $("#s-go").onclick = async () => {
  4072. const query = $("#s-query").value.trim();
  4073. if (!query) return toast("请填写 query", "warn");
  4074. const plats = selectedPlatforms();
  4075. if (!plats.length) return toast("请至少选择一个检索渠道", "warn");
  4076. const body = {
  4077. query,
  4078. synonyms: $("#s-syn").value.trim(),
  4079. mode_type: $("#s-mode").value,
  4080. platforms: plats.join(","),
  4081. max_count: parseInt($("#s-max").value) || 10,
  4082. };
  4083. try {
  4084. const r = await api("/api/run_search", { method: "POST", body: JSON.stringify(body) });
  4085. $("#search-modal").hidden = true;
  4086. showTask(`搜索 · ${r.query_id} ${query}`, r.task_id, async () => {
  4087. /* 搜索结果落在 s-mode 对应的表,完成后切到对应子模式再选中 */
  4088. const m = body.mode_type === "工具" ? "tools" : "process";
  4089. if (state.mode !== m) {
  4090. state.mode = m;
  4091. $("#m-process").classList.toggle("on", m === "process");
  4092. $("#m-tools").classList.toggle("on", m === "tools");
  4093. }
  4094. await loadQueries();
  4095. selectQuery(r.query_id);
  4096. });
  4097. } catch (e) {
  4098. toast("搜索启动失败:" + (e.body?.error || e.status), "error");
  4099. }
  4100. };
  4101. /* ════ 工序/工具子模式 ════ */
  4102. $("#m-process").onclick = () => setMode("process");
  4103. $("#m-tools").onclick = () => setMode("tools");
  4104. function setMode(m) {
  4105. if (state.mode === m) return;
  4106. state.mode = m;
  4107. state.version = null;
  4108. /* 工序/工具是两张独立搜索表,切换时整体重置三栏 */
  4109. state.queryId = null;
  4110. state.caseId = null;
  4111. state.post = null;
  4112. state.posts = [];
  4113. state.selected.clear();
  4114. state.platFilter = "all";
  4115. $("#m-process").classList.toggle("on", m === "process");
  4116. $("#m-tools").classList.toggle("on", m === "tools");
  4117. $("#plat-tabs").hidden = true;
  4118. $("#p-count").textContent = "";
  4119. $("#post-list").innerHTML = '<div class="empty"><span class="glyph">←</span>先选择左侧 query</div>';
  4120. renderExtractEmpty();
  4121. loadQueries();
  4122. }
  4123. $("#btn-query-rule").onclick = () => { $("#qr-modal").hidden = false; qrOpen(); };
  4124. $("#qr-close").onclick = () => { $("#qr-modal").hidden = true; };
  4125. $("#qr-modal").onclick = (e) => { if (e.target === $("#qr-modal")) $("#qr-modal").hidden = true; };
  4126. window.addEventListener("resize", () => chartRefs.forEach((c) => c.resize()));
  4127. route();
  4128. </script>
  4129. </body>
  4130. </html>