index.html 165 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571
  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. /* query 列表筛选按钮 + 下拉 */
  549. .qf-btn {
  550. font-size: 11px;
  551. font-weight: 600;
  552. color: var(--ink-faint);
  553. background: #f3f4f6;
  554. border: 1px solid var(--line);
  555. border-radius: 6px;
  556. padding: 2px 8px;
  557. cursor: pointer;
  558. letter-spacing: 0;
  559. }
  560. .qf-btn:hover { color: var(--ink); }
  561. .qf-btn.active {
  562. color: #2563eb;
  563. border-color: #b6cdf7;
  564. background: #eef3fe;
  565. }
  566. .qf-pop {
  567. position: absolute;
  568. top: 100%;
  569. right: 10px;
  570. z-index: 30;
  571. margin-top: 4px;
  572. background: #fff;
  573. border: 1px solid var(--line);
  574. border-radius: 8px;
  575. box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
  576. padding: 10px 12px;
  577. display: flex;
  578. flex-direction: column;
  579. gap: 10px;
  580. min-width: 178px;
  581. }
  582. .qf-pop label {
  583. display: flex;
  584. align-items: center;
  585. justify-content: space-between;
  586. gap: 10px;
  587. font-size: 12px;
  588. font-weight: 500;
  589. color: var(--ink);
  590. letter-spacing: 0;
  591. }
  592. .qf-pop select {
  593. font-size: 12px;
  594. padding: 3px 6px;
  595. border: 1px solid var(--line);
  596. border-radius: 6px;
  597. background: #fff;
  598. cursor: pointer;
  599. }
  600. /* 帖子列头:标题一行、操作按钮另起一行(按钮不和「帖子 N/M」挤一行) */
  601. .col-head.posts-head {
  602. flex-direction: column;
  603. align-items: stretch;
  604. gap: 8px;
  605. }
  606. .posts-head .ph-title {
  607. display: flex;
  608. align-items: center;
  609. gap: 8px;
  610. }
  611. .posts-head .ph-actions {
  612. display: flex;
  613. flex-wrap: wrap;
  614. gap: 8px;
  615. }
  616. /* 按钮内计数:未做数(灰) / 已采纳总数(绿) */
  617. .ph-actions .cnt-rest {
  618. color: #9aa0a6;
  619. font-weight: 700;
  620. }
  621. .ph-actions .cnt-total {
  622. color: #2e9e5b;
  623. font-weight: 700;
  624. }
  625. .qlist {
  626. flex: 1;
  627. min-height: 0;
  628. overflow: auto;
  629. }
  630. .qitem {
  631. padding: 12px 14px;
  632. border-bottom: 1px solid var(--line);
  633. cursor: pointer;
  634. transition: 0.12s;
  635. }
  636. .qitem:hover {
  637. background: #f8f8f4;
  638. }
  639. .qitem.on {
  640. background: var(--blue-bg);
  641. box-shadow: inset 3px 0 0 var(--blue);
  642. }
  643. .qitem .qid {
  644. font-size: 10px;
  645. letter-spacing: 1px;
  646. color: var(--ink-faint);
  647. display: flex;
  648. gap: 6px;
  649. align-items: center;
  650. }
  651. .qitem .qt {
  652. font-weight: 500;
  653. margin: 4px 0 7px;
  654. line-height: 1.45;
  655. }
  656. .qitem .qm {
  657. font-size: 11px;
  658. color: var(--ink-soft);
  659. display: flex;
  660. gap: 10px;
  661. flex-wrap: wrap;
  662. align-items: center;
  663. }
  664. .qitem .qm b.hit {
  665. color: var(--blue);
  666. font-size: 13px;
  667. }
  668. /* 渠道 tab */
  669. .plat-tabs {
  670. display: flex;
  671. gap: 4px;
  672. padding: 8px 10px;
  673. border-bottom: 1px solid var(--line);
  674. overflow-x: auto;
  675. background: #fbfbf8;
  676. border-radius: 0;
  677. }
  678. .plat-tabs button {
  679. border: 1px solid transparent;
  680. background: transparent;
  681. color: var(--ink-soft);
  682. padding: 3px 11px;
  683. border-radius: 99px;
  684. font-size: 12px;
  685. font-weight: 500;
  686. white-space: nowrap;
  687. transition: 0.15s;
  688. }
  689. .plat-tabs button:hover {
  690. background: #efeee8;
  691. color: var(--ink);
  692. }
  693. .plat-tabs button.on {
  694. background: var(--navy);
  695. color: #fff;
  696. font-weight: 700;
  697. }
  698. .plat-tabs button .c {
  699. font-size: 10px;
  700. opacity: 0.75;
  701. margin-left: 3px;
  702. }
  703. /* 已解构筛选按钮:靠右,激活态用 teal 呼应「已解构」 */
  704. .plat-tabs .done-filter {
  705. margin-left: auto;
  706. flex: none;
  707. border: 1px solid var(--line);
  708. display: inline-flex;
  709. align-items: center;
  710. gap: 4px;
  711. color: var(--ink-soft);
  712. }
  713. .plat-tabs .done-filter:hover {
  714. background: #efeee8;
  715. color: var(--ink);
  716. }
  717. .plat-tabs .done-filter.on {
  718. background: var(--teal-bg, #e3f1ec);
  719. border-color: #a9d6c8;
  720. color: var(--teal);
  721. font-weight: 700;
  722. }
  723. .plat-tabs .done-filter .dot {
  724. font-size: 8px;
  725. }
  726. .plist {
  727. flex: 1;
  728. min-height: 0;
  729. overflow: auto;
  730. }
  731. .post {
  732. padding: 12px 13px;
  733. border-bottom: 1px solid var(--line);
  734. cursor: pointer;
  735. display: flex;
  736. gap: 10px;
  737. transition: 0.12s;
  738. align-items: flex-start;
  739. }
  740. .post:hover {
  741. background: #f8f8f4;
  742. }
  743. .post.on {
  744. background: var(--blue-bg);
  745. box-shadow: inset 3px 0 0 var(--blue);
  746. }
  747. .post input {
  748. margin-top: 4px;
  749. accent-color: var(--blue);
  750. }
  751. .post .pt {
  752. font-weight: 500;
  753. line-height: 1.45;
  754. font-size: 13px;
  755. }
  756. .post .pm {
  757. display: flex;
  758. flex-wrap: wrap;
  759. gap: 5px;
  760. margin-top: 7px;
  761. align-items: center;
  762. }
  763. .plat {
  764. display: inline-block;
  765. padding: 1px 7px;
  766. border-radius: 4px;
  767. font-size: 10px;
  768. font-weight: 700;
  769. color: #fff;
  770. }
  771. .plat.xhs {
  772. background: #d63a2f;
  773. }
  774. .plat.gzh {
  775. background: #2e9939;
  776. }
  777. .plat.zhihu {
  778. background: #1772f6;
  779. }
  780. .plat.douyin {
  781. background: #170b1a;
  782. }
  783. .plat.sph {
  784. background: #fa6d20;
  785. }
  786. .plat.youtube {
  787. background: #c00;
  788. }
  789. .plat.x {
  790. background: #15202b;
  791. }
  792. .plat.other {
  793. background: #777;
  794. }
  795. .plat-logo {
  796. display: inline-flex;
  797. line-height: 0;
  798. flex: none;
  799. }
  800. .plat-logo svg,
  801. .plat-logo img {
  802. display: block;
  803. }
  804. .done-dot {
  805. font-size: 10px;
  806. color: var(--teal);
  807. font-weight: 700;
  808. }
  809. /* 评分徽章:大、亮、可点 */
  810. .score-badge {
  811. flex: none;
  812. position: relative;
  813. font-family: "IBM Plex Mono", monospace;
  814. font-weight: 700;
  815. font-size: 16.5px;
  816. line-height: 1;
  817. padding: 8px 10px;
  818. border-radius: 9px;
  819. cursor: pointer;
  820. transition: 0.15s;
  821. align-self: center;
  822. border: 1px solid transparent;
  823. }
  824. .score-badge.s9 {
  825. color: #fff;
  826. background: linear-gradient(135deg, #16a34a, #15803d);
  827. box-shadow: 0 3px 10px rgba(22, 163, 74, 0.35);
  828. }
  829. .score-badge.s8 {
  830. color: #fff;
  831. background: linear-gradient(135deg, #3b82f6, #2563eb);
  832. box-shadow: 0 3px 10px rgba(37, 99, 235, 0.35);
  833. }
  834. .score-badge.s6 {
  835. color: #fff;
  836. background: linear-gradient(135deg, #f59e0b, #d97706);
  837. box-shadow: 0 3px 10px rgba(217, 119, 6, 0.32);
  838. }
  839. .score-badge.s0 {
  840. color: var(--ink-soft);
  841. background: #eceae4;
  842. border-color: var(--line-dark);
  843. }
  844. .score-badge:hover {
  845. transform: translateY(-2px) scale(1.06);
  846. }
  847. .score-badge::after {
  848. content: "查看详情";
  849. position: absolute;
  850. left: 50%;
  851. bottom: calc(100% + 6px);
  852. transform: translateX(-50%) scale(0.92);
  853. background: var(--ink);
  854. color: #fff;
  855. font-family: "Noto Sans SC", sans-serif;
  856. font-size: 10px;
  857. font-weight: 500;
  858. padding: 3px 8px;
  859. border-radius: 5px;
  860. white-space: nowrap;
  861. opacity: 0;
  862. pointer-events: none;
  863. transition: 0.15s;
  864. z-index: 5;
  865. }
  866. .score-badge:hover::after {
  867. opacity: 1;
  868. transform: translateX(-50%) scale(1);
  869. }
  870. .xp {
  871. min-height: 60vh;
  872. }
  873. .xp-head {
  874. display: flex;
  875. align-items: center;
  876. gap: 10px;
  877. padding: 12px 16px;
  878. border-bottom: 1px solid var(--line);
  879. flex-wrap: wrap;
  880. }
  881. .xp-head .st {
  882. font-family: "Noto Serif SC", serif;
  883. font-weight: 900;
  884. font-size: 15px;
  885. }
  886. .xp-head .st em {
  887. color: var(--seal);
  888. font-style: normal;
  889. }
  890. .xp-head .spacer {
  891. flex: 1;
  892. }
  893. .xp-body {
  894. padding: 16px;
  895. flex: 1;
  896. min-height: 0;
  897. overflow: auto;
  898. }
  899. /* 工序卡 */
  900. .proc {
  901. border: 1px solid var(--line);
  902. border-radius: 10px;
  903. margin-bottom: 22px;
  904. overflow: hidden;
  905. background: #fff;
  906. box-shadow: var(--shadow);
  907. }
  908. .proc-head {
  909. padding: 14px 16px;
  910. border-bottom: 1px solid var(--line);
  911. background: #fafaf6;
  912. }
  913. .proc-head .nm {
  914. font-family: "Noto Serif SC", serif;
  915. font-weight: 900;
  916. font-size: 15px;
  917. }
  918. .proc-head .nm .pid {
  919. color: var(--seal);
  920. margin-right: 6px;
  921. font-size: 13px;
  922. }
  923. .proc-head .pp {
  924. font-size: 12px;
  925. color: var(--ink-soft);
  926. margin-top: 5px;
  927. line-height: 1.6;
  928. }
  929. .proc-head .meta {
  930. display: flex;
  931. gap: 6px;
  932. flex-wrap: wrap;
  933. margin-top: 8px;
  934. }
  935. .decl {
  936. display: grid;
  937. grid-template-columns: 1fr 1fr;
  938. gap: 0;
  939. border-bottom: 1px solid var(--line);
  940. }
  941. .decl > div {
  942. padding: 10px 16px;
  943. }
  944. .decl > div + div {
  945. border-left: 1px solid var(--line);
  946. }
  947. .decl .dl {
  948. font-size: 10px;
  949. letter-spacing: 2px;
  950. color: var(--ink-faint);
  951. margin-bottom: 6px;
  952. }
  953. .decl .di {
  954. font-size: 12px;
  955. line-height: 1.7;
  956. }
  957. .decl .di b {
  958. font-weight: 700;
  959. }
  960. /* 步骤表:固定列宽撑开,宿主容器 overflow-x 滚动 */
  961. .steps {
  962. width: 100%;
  963. min-width: 1760px;
  964. table-layout: fixed;
  965. border-collapse: collapse;
  966. font-size: 12px;
  967. }
  968. .steps th {
  969. padding: 6px 8px;
  970. font-size: 11px;
  971. font-weight: 700;
  972. letter-spacing: 1px;
  973. color: #fff;
  974. text-align: left;
  975. }
  976. .steps thead tr:first-child th {
  977. text-align: center;
  978. font-size: 12px;
  979. letter-spacing: 4px;
  980. padding: 7px 4px;
  981. }
  982. .steps .h-req {
  983. background: var(--navy);
  984. }
  985. .steps .h-req2 {
  986. background: #33547a;
  987. }
  988. .steps .h-in {
  989. background: var(--amber);
  990. }
  991. .steps .h-in2 {
  992. background: #cd7522;
  993. }
  994. .steps .h-im {
  995. background: var(--teal);
  996. }
  997. .steps .h-im2 {
  998. background: #2d8273;
  999. }
  1000. .steps .h-out {
  1001. background: var(--blue);
  1002. }
  1003. .steps .h-out2 {
  1004. background: #4f7fe6;
  1005. }
  1006. .steps td {
  1007. padding: 8px 9px;
  1008. border: 1px solid var(--line);
  1009. vertical-align: top;
  1010. line-height: 1.6;
  1011. }
  1012. .steps tbody tr:nth-child(odd) td {
  1013. background: #fdfdf9;
  1014. }
  1015. .steps td.c-in {
  1016. background: var(--amber-bg) !important;
  1017. }
  1018. .steps td.c-out {
  1019. background: var(--blue-bg) !important;
  1020. }
  1021. .steps .sid {
  1022. font-family: "IBM Plex Mono", monospace;
  1023. font-weight: 700;
  1024. color: var(--navy);
  1025. white-space: nowrap;
  1026. }
  1027. .steps .vtxt {
  1028. color: var(--ink-soft);
  1029. font-size: 11.5px;
  1030. word-break: break-all;
  1031. }
  1032. /* 归类命中(实质/形式):原值 → 命中值 逐行配对 */
  1033. .steps .sf-map {
  1034. display: flex;
  1035. flex-direction: column;
  1036. gap: 4px;
  1037. }
  1038. .steps .sf-pair {
  1039. display: flex;
  1040. align-items: center;
  1041. gap: 4px;
  1042. flex-wrap: wrap;
  1043. line-height: 1.5;
  1044. }
  1045. .steps .sf-old {
  1046. color: #9aa0a6;
  1047. text-decoration: line-through;
  1048. }
  1049. .steps .sf-plain {
  1050. color: var(--ink);
  1051. }
  1052. .steps .sf-arrow {
  1053. color: #2e9e5b;
  1054. flex: none;
  1055. }
  1056. .steps .sf-new {
  1057. display: inline-block;
  1058. padding: 1px 7px;
  1059. border-radius: 10px;
  1060. background: #e3f3e8;
  1061. color: #2e6b45;
  1062. border: 1px solid #bfe3cb;
  1063. font-weight: 600;
  1064. white-space: nowrap;
  1065. }
  1066. .inf {
  1067. background: var(--infer) !important;
  1068. position: relative;
  1069. outline: 1px dashed var(--infer-edge);
  1070. outline-offset: -2px;
  1071. }
  1072. .inf .ib {
  1073. position: absolute;
  1074. top: -1px;
  1075. right: -1px;
  1076. background: var(--infer-edge);
  1077. color: #fff;
  1078. font-size: 9px;
  1079. padding: 0 4px;
  1080. border-radius: 0 0 0 4px;
  1081. font-weight: 700;
  1082. }
  1083. .anchor {
  1084. font-family: "IBM Plex Mono", monospace;
  1085. font-size: 10.5px;
  1086. color: var(--ink-faint);
  1087. word-break: break-all;
  1088. }
  1089. /* 输入/输出「值」单元格:超过 4 行加蒙版,点击展开/收起 */
  1090. .clamp-val {
  1091. position: relative;
  1092. }
  1093. .clamp-val.clampable {
  1094. max-height: 6.6em;
  1095. overflow: hidden;
  1096. cursor: zoom-in;
  1097. }
  1098. .clamp-val.clampable::after {
  1099. content: "";
  1100. position: absolute;
  1101. left: 0;
  1102. right: 0;
  1103. bottom: 0;
  1104. height: 2.4em;
  1105. pointer-events: none;
  1106. }
  1107. .steps td.c-in .clamp-val.clampable::after {
  1108. background: linear-gradient(180deg, rgba(255, 247, 232, 0), rgba(255, 247, 232, 1));
  1109. }
  1110. .steps td.c-out .clamp-val.clampable::after {
  1111. background: linear-gradient(180deg, rgba(238, 243, 254, 0), rgba(238, 243, 254, 1));
  1112. }
  1113. .clamp-val.open {
  1114. max-height: none;
  1115. overflow: visible;
  1116. cursor: zoom-out;
  1117. }
  1118. .clamp-val.open::after {
  1119. display: none;
  1120. }
  1121. /* 工具表格(移植自 fixed_query_eval:案例逐行 rowspan + 限高展开) */
  1122. .mw-ttwrap {
  1123. overflow-x: auto;
  1124. border: 1px solid var(--line);
  1125. border-radius: 10px;
  1126. box-shadow: var(--shadow);
  1127. }
  1128. .mw-tt {
  1129. border-collapse: separate;
  1130. border-spacing: 0;
  1131. width: 100%;
  1132. min-width: 640px;
  1133. table-layout: fixed;
  1134. background: #fff;
  1135. font-size: 12.5px;
  1136. }
  1137. .mw-tt thead th {
  1138. position: sticky;
  1139. top: 0;
  1140. z-index: 2;
  1141. text-align: left;
  1142. white-space: nowrap;
  1143. background: linear-gradient(180deg, #2aa79b, #1c8076);
  1144. color: #fff;
  1145. font-weight: 700;
  1146. padding: 10px 12px;
  1147. letter-spacing: 0.3px;
  1148. border-right: 1px solid rgba(255, 255, 255, 0.18);
  1149. }
  1150. .mw-tt thead th:last-child {
  1151. border-right: none;
  1152. }
  1153. .mw-tt thead tr:first-child th {
  1154. top: 0;
  1155. }
  1156. .mw-tt thead tr:nth-child(2) th {
  1157. top: 38px;
  1158. }
  1159. .mw-tt .th-group {
  1160. text-align: center;
  1161. }
  1162. .mw-tt .th-sub {
  1163. background: linear-gradient(180deg, #36bdb0, #23897f);
  1164. font-weight: 600;
  1165. }
  1166. .mw-tt tbody td {
  1167. padding: 9px 12px;
  1168. vertical-align: top;
  1169. line-height: 1.6;
  1170. border-bottom: 1px solid #f0eee8;
  1171. border-right: 1px solid #f5f3ee;
  1172. color: #3a3a3a;
  1173. }
  1174. .mw-tt tbody td:last-child {
  1175. border-right: none;
  1176. }
  1177. .mw-tt td.col-case {
  1178. background: #fafdfc;
  1179. }
  1180. .mw-tt tbody tr.tr-b td {
  1181. background: #fbfaf6;
  1182. }
  1183. .mw-tt tbody tr.tr-b td.col-case {
  1184. background: #f6fbfa;
  1185. }
  1186. .mw-tt tbody td.col-tool {
  1187. font-weight: 700;
  1188. color: #176d64;
  1189. white-space: nowrap;
  1190. border-left: 3px solid #2aa79b;
  1191. background: #f3faf8;
  1192. }
  1193. .mw-tt tbody tr:hover td.col-tool {
  1194. background: #e3f4f0;
  1195. }
  1196. .mw-tt ul {
  1197. margin: 0;
  1198. padding-left: 17px;
  1199. }
  1200. .mw-tt ul li {
  1201. margin: 3px 0;
  1202. }
  1203. .mw-tt ul li::marker {
  1204. color: #2aa79b;
  1205. }
  1206. .mw-tt .layer-badge {
  1207. display: inline-block;
  1208. font-weight: 700;
  1209. font-size: 11px;
  1210. padding: 2px 10px;
  1211. border-radius: 20px;
  1212. white-space: nowrap;
  1213. }
  1214. .mw-tt .layer-badge.make {
  1215. color: #0e7490;
  1216. background: #d6f0ee;
  1217. }
  1218. .mw-tt .layer-badge.create {
  1219. color: #b8731a;
  1220. background: #fef0db;
  1221. }
  1222. .mw-tt .dash {
  1223. color: #c9c2b6;
  1224. }
  1225. .mw-tt .tcell {
  1226. position: relative;
  1227. max-height: 7.8em;
  1228. overflow: hidden;
  1229. transition: max-height 0.15s;
  1230. }
  1231. .mw-tt .tcell.clamped {
  1232. cursor: zoom-in;
  1233. }
  1234. .mw-tt .tcell.clamped::after {
  1235. content: "▾ 展开";
  1236. position: absolute;
  1237. left: 0;
  1238. right: 0;
  1239. bottom: 0;
  1240. height: 2.6em;
  1241. display: flex;
  1242. align-items: flex-end;
  1243. justify-content: center;
  1244. padding-bottom: 2px;
  1245. font-size: 11px;
  1246. font-weight: 700;
  1247. color: #176d64;
  1248. background: linear-gradient(rgba(255, 255, 255, 0), #fff 72%);
  1249. pointer-events: none;
  1250. }
  1251. .mw-tt tbody tr.tr-b .tcell.clamped::after {
  1252. background: linear-gradient(rgba(251, 250, 246, 0), #fbfaf6 72%);
  1253. }
  1254. .mw-tt td.col-case .tcell.clamped::after {
  1255. background: linear-gradient(rgba(250, 253, 252, 0), #fafdfc 72%);
  1256. }
  1257. .mw-tt tbody tr.tr-b td.col-case .tcell.clamped::after {
  1258. background: linear-gradient(rgba(246, 251, 250, 0), #f6fbfa 72%);
  1259. }
  1260. .mw-tt .tcell.open {
  1261. max-height: none;
  1262. cursor: zoom-out;
  1263. }
  1264. .mw-tt .tcell.open::after {
  1265. content: "";
  1266. height: 0;
  1267. }
  1268. /* ── 帖子详情弹层 ── */
  1269. dialog#post-dialog {
  1270. width: min(1100px, 94vw);
  1271. max-height: calc(100vh - 40px);
  1272. border: none;
  1273. border-radius: 14px;
  1274. padding: 0;
  1275. box-shadow: var(--shadow-lg);
  1276. overflow: hidden;
  1277. margin: auto; /* 全局 reset 清掉了 dialog 默认 margin:auto,这里补回才能居中 */
  1278. }
  1279. dialog#post-dialog::backdrop {
  1280. background: rgba(19, 30, 46, 0.5);
  1281. backdrop-filter: blur(2px);
  1282. }
  1283. /* 重新解构·编辑 Prompt 弹框 */
  1284. dialog#reextract-dlg {
  1285. border: none;
  1286. border-radius: 14px;
  1287. padding: 0;
  1288. width: min(680px, 94vw);
  1289. box-shadow: var(--shadow-lg);
  1290. margin: auto;
  1291. }
  1292. dialog#reextract-dlg::backdrop {
  1293. background: rgba(19, 30, 46, 0.42);
  1294. backdrop-filter: blur(2px);
  1295. }
  1296. .rx-wrap {
  1297. display: flex;
  1298. flex-direction: column;
  1299. max-height: calc(100vh - 48px);
  1300. }
  1301. .rx-head {
  1302. display: flex;
  1303. align-items: center;
  1304. justify-content: space-between;
  1305. padding: 14px 18px 12px;
  1306. border-bottom: 1px solid var(--line);
  1307. }
  1308. .rx-title {
  1309. font-weight: 700;
  1310. font-size: 15px;
  1311. color: var(--navy-deep);
  1312. }
  1313. .rx-sub {
  1314. padding: 12px 18px 0;
  1315. font-size: 12px;
  1316. color: var(--ink-faint);
  1317. line-height: 1.6;
  1318. }
  1319. .rx-model {
  1320. padding: 12px 18px 0;
  1321. display: flex;
  1322. align-items: center;
  1323. gap: 8px;
  1324. font-size: 13px;
  1325. }
  1326. .rx-model label {
  1327. font-weight: 600;
  1328. color: var(--ink);
  1329. }
  1330. .rx-prompt {
  1331. margin: 12px 18px;
  1332. flex: 1;
  1333. min-height: 300px;
  1334. resize: vertical;
  1335. font-family: "IBM Plex Mono", ui-monospace, monospace;
  1336. font-size: 12px;
  1337. line-height: 1.6;
  1338. color: var(--ink);
  1339. border: 1px solid var(--line-dark);
  1340. border-radius: 8px;
  1341. padding: 12px;
  1342. background: #fbfaf6;
  1343. }
  1344. .rx-foot {
  1345. display: flex;
  1346. justify-content: flex-end;
  1347. gap: 10px;
  1348. padding: 12px 18px 16px;
  1349. border-top: 1px solid var(--line);
  1350. }
  1351. #rx-save {
  1352. background: var(--green);
  1353. border-color: var(--green);
  1354. color: #fff;
  1355. }
  1356. #rx-save:hover {
  1357. background: #126b33;
  1358. color: #fff;
  1359. box-shadow: 0 4px 12px rgba(21, 128, 61, 0.3);
  1360. }
  1361. .pd-wrap {
  1362. display: flex;
  1363. flex-direction: column;
  1364. max-height: calc(100vh - 40px);
  1365. }
  1366. .pd-head {
  1367. display: flex;
  1368. justify-content: space-between;
  1369. gap: 14px;
  1370. align-items: flex-start;
  1371. padding: 16px 20px;
  1372. border-bottom: 1px solid var(--line);
  1373. background: #fff;
  1374. flex: none;
  1375. }
  1376. .pd-head h3 {
  1377. font-family: "Noto Serif SC", serif;
  1378. font-size: 18px;
  1379. line-height: 1.35;
  1380. margin-top: 6px;
  1381. }
  1382. .pd-meta {
  1383. display: flex;
  1384. gap: 8px;
  1385. flex-wrap: wrap;
  1386. align-items: center;
  1387. font-size: 12px;
  1388. color: var(--ink-soft);
  1389. }
  1390. .pd-close {
  1391. border: none;
  1392. background: #f1f0ea;
  1393. width: 30px;
  1394. height: 30px;
  1395. border-radius: 8px;
  1396. font-size: 14px;
  1397. color: var(--ink-soft);
  1398. flex: none;
  1399. transition: 0.15s;
  1400. }
  1401. .pd-close:hover {
  1402. background: var(--seal);
  1403. color: #fff;
  1404. }
  1405. .pd-body {
  1406. display: grid;
  1407. grid-template-columns: 1.05fr 0.95fr;
  1408. gap: 20px;
  1409. padding: 18px 20px;
  1410. overflow: auto;
  1411. }
  1412. @media (max-width: 920px) {
  1413. .pd-body {
  1414. grid-template-columns: 1fr;
  1415. }
  1416. }
  1417. .pd-body > section,
  1418. .pd-body > aside {
  1419. min-width: 0;
  1420. }
  1421. .pd-sec-title {
  1422. font-weight: 800;
  1423. margin: 16px 0 8px;
  1424. font-size: 13px;
  1425. }
  1426. .pd-sec-title:first-child {
  1427. margin-top: 0;
  1428. }
  1429. .pd-verdict {
  1430. background: #eaf6fb;
  1431. border-left: 4px solid #2c9ec7;
  1432. padding: 10px 12px;
  1433. color: #22566b;
  1434. border-radius: 6px;
  1435. font-size: 13px;
  1436. line-height: 1.6;
  1437. }
  1438. .pd-raw {
  1439. white-space: pre-wrap;
  1440. background: #faf9f5;
  1441. border: 1px solid var(--line);
  1442. border-radius: 10px;
  1443. padding: 12px;
  1444. max-height: 320px;
  1445. overflow: auto;
  1446. color: #3d3f44;
  1447. font-size: 13px;
  1448. line-height: 1.7;
  1449. }
  1450. .pd-images {
  1451. display: grid;
  1452. grid-template-columns: repeat(2, minmax(0, 1fr));
  1453. gap: 8px;
  1454. }
  1455. .pd-images img {
  1456. width: 100%;
  1457. max-height: 250px;
  1458. object-fit: contain;
  1459. border: 1px solid var(--line);
  1460. border-radius: 10px;
  1461. background: #f3f2ed;
  1462. cursor: zoom-in;
  1463. }
  1464. .pd-videos {
  1465. display: grid;
  1466. grid-template-columns: 1fr;
  1467. gap: 8px;
  1468. }
  1469. .pd-videos video {
  1470. width: 100%;
  1471. max-height: 320px;
  1472. border: 1px solid var(--line);
  1473. border-radius: 10px;
  1474. background: #000;
  1475. }
  1476. .pd-videos iframe {
  1477. width: 100%;
  1478. aspect-ratio: 16 / 9;
  1479. border: 1px solid var(--line);
  1480. border-radius: 10px;
  1481. background: #000;
  1482. }
  1483. .pd-videos .vid-fallback {
  1484. display: block;
  1485. padding: 10px 12px;
  1486. font-size: 12px;
  1487. color: var(--accent, #2d6cdf);
  1488. border: 1px dashed var(--line);
  1489. border-radius: 10px;
  1490. text-decoration: none;
  1491. }
  1492. /* ── 图片预览灯箱 ── */
  1493. dialog.lightbox {
  1494. position: fixed;
  1495. inset: 0;
  1496. width: 100%;
  1497. height: 100%;
  1498. max-width: 100%;
  1499. max-height: 100%;
  1500. margin: 0;
  1501. padding: 40px 72px;
  1502. border: none;
  1503. gap: 18px;
  1504. align-items: center;
  1505. justify-content: center;
  1506. background: rgba(20, 20, 22, 0.86);
  1507. backdrop-filter: blur(2px);
  1508. overflow: hidden;
  1509. }
  1510. dialog.lightbox[open] {
  1511. display: flex;
  1512. }
  1513. dialog.lightbox::backdrop {
  1514. background: rgba(20, 20, 22, 0.5);
  1515. }
  1516. .lb-stage {
  1517. margin: 0;
  1518. max-width: 100%;
  1519. max-height: 100%;
  1520. display: flex;
  1521. flex-direction: column;
  1522. align-items: center;
  1523. gap: 12px;
  1524. }
  1525. .lb-stage img {
  1526. max-width: min(1100px, 86vw);
  1527. max-height: 82vh;
  1528. object-fit: contain;
  1529. border-radius: 8px;
  1530. box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
  1531. background: #2a2a2c;
  1532. }
  1533. .lb-stage figcaption {
  1534. color: rgba(255, 255, 255, 0.78);
  1535. font-size: 13px;
  1536. letter-spacing: 0.5px;
  1537. }
  1538. .lb-nav {
  1539. flex: 0 0 auto;
  1540. width: 46px;
  1541. height: 46px;
  1542. border-radius: 50%;
  1543. border: none;
  1544. background: rgba(255, 255, 255, 0.12);
  1545. color: #fff;
  1546. font-size: 28px;
  1547. line-height: 1;
  1548. cursor: pointer;
  1549. transition: 0.15s;
  1550. }
  1551. .lb-nav:hover {
  1552. background: rgba(255, 255, 255, 0.26);
  1553. }
  1554. .lb-close {
  1555. position: absolute;
  1556. top: 20px;
  1557. right: 24px;
  1558. width: 38px;
  1559. height: 38px;
  1560. border-radius: 50%;
  1561. border: none;
  1562. background: rgba(255, 255, 255, 0.12);
  1563. color: #fff;
  1564. font-size: 18px;
  1565. cursor: pointer;
  1566. transition: 0.15s;
  1567. }
  1568. .lb-close:hover {
  1569. background: rgba(255, 255, 255, 0.26);
  1570. }
  1571. /* ── 帖子列表缩略图 ── */
  1572. .post .thumb {
  1573. flex: 0 0 auto;
  1574. width: 44px;
  1575. height: 44px;
  1576. border-radius: 7px;
  1577. object-fit: cover;
  1578. background: #f0efe9;
  1579. border: 1px solid var(--line);
  1580. }
  1581. .post .thumb-ph {
  1582. flex: 0 0 auto;
  1583. width: 44px;
  1584. height: 44px;
  1585. border-radius: 7px;
  1586. background: #f0efe9;
  1587. border: 1px solid var(--line);
  1588. display: flex;
  1589. align-items: center;
  1590. justify-content: center;
  1591. color: var(--ink-faint);
  1592. font-size: 16px;
  1593. }
  1594. /* ── 原文卡片(可整体展开/收起;含标题、图片缩略图、正文) ── */
  1595. .src-block {
  1596. border: 1px solid var(--line);
  1597. border-radius: 10px;
  1598. margin-bottom: 14px;
  1599. background: #faf9f5;
  1600. overflow: hidden;
  1601. }
  1602. .src-head {
  1603. display: flex;
  1604. align-items: center;
  1605. gap: 8px;
  1606. padding: 9px 12px;
  1607. cursor: pointer;
  1608. user-select: none;
  1609. }
  1610. .src-head:hover {
  1611. background: #f3f2ed;
  1612. }
  1613. .src-caret {
  1614. flex: 0 0 auto;
  1615. color: var(--ink-faint);
  1616. font-size: 11px;
  1617. transition: transform 0.15s;
  1618. }
  1619. .src-block.open .src-caret {
  1620. transform: rotate(90deg);
  1621. }
  1622. .src-label {
  1623. flex: 0 0 auto;
  1624. font-size: 11px;
  1625. font-weight: 700;
  1626. color: var(--blue);
  1627. background: var(--blue-bg);
  1628. padding: 1px 7px;
  1629. border-radius: 4px;
  1630. }
  1631. .src-title {
  1632. flex: 1;
  1633. min-width: 0;
  1634. font-weight: 600;
  1635. font-size: 13px;
  1636. white-space: nowrap;
  1637. overflow: hidden;
  1638. text-overflow: ellipsis;
  1639. }
  1640. .src-link {
  1641. flex: 0 0 auto;
  1642. font-size: 12px;
  1643. color: var(--blue);
  1644. text-decoration: none;
  1645. }
  1646. .src-case {
  1647. flex: 0 0 auto;
  1648. font-size: 11px;
  1649. font-family: "IBM Plex Mono", ui-monospace, monospace;
  1650. color: var(--ink-faint);
  1651. background: var(--paper, #f3f2ed);
  1652. border: 1px solid var(--line);
  1653. padding: 1px 7px;
  1654. border-radius: 4px;
  1655. white-space: nowrap;
  1656. }
  1657. .src-body {
  1658. padding: 0 12px 12px;
  1659. }
  1660. .src-block:not(.open) .src-body {
  1661. display: none;
  1662. }
  1663. .src-thumbs {
  1664. display: flex;
  1665. gap: 8px;
  1666. overflow-x: auto;
  1667. padding: 4px 2px 10px;
  1668. scrollbar-width: thin;
  1669. }
  1670. .src-thumbs img {
  1671. flex: 0 0 auto;
  1672. height: 96px;
  1673. width: auto;
  1674. max-width: 150px;
  1675. border-radius: 8px;
  1676. border: 1px solid var(--line);
  1677. object-fit: cover;
  1678. background: #f0efe9;
  1679. cursor: zoom-in;
  1680. }
  1681. .src-text {
  1682. font-size: 13px;
  1683. line-height: 1.7;
  1684. color: #3d3f44;
  1685. white-space: pre-wrap;
  1686. }
  1687. .src-text.clamp {
  1688. max-height: 88px;
  1689. overflow: hidden;
  1690. -webkit-mask-image: linear-gradient(180deg, #000 62%, transparent);
  1691. mask-image: linear-gradient(180deg, #000 62%, transparent);
  1692. }
  1693. .src-text-toggle {
  1694. margin-top: 4px;
  1695. background: none;
  1696. border: none;
  1697. color: var(--blue);
  1698. cursor: pointer;
  1699. font-size: 12px;
  1700. padding: 2px 0;
  1701. }
  1702. .pd-tags {
  1703. display: flex;
  1704. gap: 6px;
  1705. flex-wrap: wrap;
  1706. margin-top: 12px;
  1707. }
  1708. .pd-score-head {
  1709. display: flex;
  1710. justify-content: space-between;
  1711. align-items: center;
  1712. margin-bottom: 10px;
  1713. }
  1714. .pd-score-head .t {
  1715. font-weight: 800;
  1716. font-size: 14px;
  1717. }
  1718. .pd-overall {
  1719. display: flex;
  1720. align-items: center;
  1721. gap: 6px;
  1722. font-size: 12.5px;
  1723. font-weight: 700;
  1724. color: var(--ink-soft);
  1725. background: #faf9f5;
  1726. border: 1px solid var(--line);
  1727. padding: 4px 12px;
  1728. border-radius: 8px;
  1729. }
  1730. .pd-overall b {
  1731. font-size: 20px;
  1732. color: var(--blue);
  1733. font-weight: 900;
  1734. line-height: 1;
  1735. }
  1736. .sc-card {
  1737. border: 1px solid var(--line);
  1738. border-radius: 10px;
  1739. background: #fff;
  1740. overflow: hidden;
  1741. margin-bottom: 12px;
  1742. }
  1743. .sc-card-head {
  1744. display: flex;
  1745. justify-content: space-between;
  1746. align-items: center;
  1747. gap: 10px;
  1748. padding: 10px 12px;
  1749. background: #faf9f5;
  1750. border-bottom: 1px solid var(--line);
  1751. font-size: 13px;
  1752. font-weight: 800;
  1753. }
  1754. .sc-card-head .badge {
  1755. display: inline-grid;
  1756. place-items: center;
  1757. width: 20px;
  1758. height: 20px;
  1759. border-radius: 5px;
  1760. background: var(--navy);
  1761. color: #fff;
  1762. font-size: 10px;
  1763. font-weight: 700;
  1764. margin-right: 7px;
  1765. }
  1766. .sc-card-head .avg {
  1767. font-size: 12px;
  1768. color: var(--ink-faint);
  1769. font-weight: 600;
  1770. }
  1771. .sc-card-head .avg b {
  1772. font-size: 17px;
  1773. color: var(--blue);
  1774. font-weight: 900;
  1775. }
  1776. .sc-card-body {
  1777. display: grid;
  1778. gap: 8px;
  1779. padding: 11px 12px;
  1780. }
  1781. /* 维度分组小标题:参考 mode_procedure —— 一级虚线大写,二级点线常规 */
  1782. .sc-sub {
  1783. font-size: 11px;
  1784. font-weight: 800;
  1785. letter-spacing: 0.8px;
  1786. color: var(--ink-faint);
  1787. text-transform: uppercase;
  1788. margin: 14px 0 8px;
  1789. padding-bottom: 5px;
  1790. border-bottom: 1px dashed var(--line-dark);
  1791. }
  1792. .sc-card-body > .sc-sub:first-child {
  1793. margin-top: 2px;
  1794. }
  1795. .sc-sub.lv2 {
  1796. font-size: 11px;
  1797. font-weight: 700;
  1798. letter-spacing: 0.3px;
  1799. text-transform: none;
  1800. color: var(--ink-soft);
  1801. margin: 11px 0 6px;
  1802. padding-bottom: 4px;
  1803. border-bottom: 1px dotted var(--line);
  1804. }
  1805. .sc-row {
  1806. display: grid;
  1807. grid-template-columns: 118px 1fr 30px 16px;
  1808. gap: 9px;
  1809. align-items: center;
  1810. font-size: 12.5px;
  1811. }
  1812. .sc-row .meter {
  1813. height: 8px;
  1814. border-radius: 99px;
  1815. background: #edebe4;
  1816. overflow: hidden;
  1817. }
  1818. .sc-row .meter span {
  1819. display: block;
  1820. height: 100%;
  1821. border-radius: 99px;
  1822. background: linear-gradient(90deg, #60a5fa, #2563eb);
  1823. }
  1824. .sc-row b {
  1825. font-weight: 700;
  1826. text-align: right;
  1827. }
  1828. .sc-row .info {
  1829. color: var(--ink-faint);
  1830. cursor: pointer;
  1831. font-size: 12px;
  1832. opacity: 0.75;
  1833. user-select: none;
  1834. }
  1835. .sc-row .info:hover {
  1836. color: var(--blue);
  1837. opacity: 1;
  1838. }
  1839. /* 判定理由弹层:点击 ⓘ 时浮现,挂在 dialog 顶层 */
  1840. .score-pop {
  1841. position: fixed;
  1842. z-index: 90;
  1843. width: 288px;
  1844. max-width: calc(100vw - 24px);
  1845. background: var(--card);
  1846. border: 1px solid var(--line-dark);
  1847. border-radius: 10px;
  1848. box-shadow: var(--shadow-lg);
  1849. padding: 12px 14px;
  1850. font-size: 12.5px;
  1851. line-height: 1.65;
  1852. color: var(--ink-soft);
  1853. animation: popIn 0.12s ease;
  1854. }
  1855. .score-pop .sp-head {
  1856. display: flex;
  1857. align-items: center;
  1858. gap: 8px;
  1859. margin-bottom: 8px;
  1860. padding-bottom: 8px;
  1861. border-bottom: 1px solid var(--line);
  1862. }
  1863. .score-pop .sp-tag {
  1864. font-size: 9px;
  1865. letter-spacing: 1.5px;
  1866. color: var(--ink-faint);
  1867. font-weight: 700;
  1868. border: 1px solid var(--line-dark);
  1869. border-radius: 5px;
  1870. padding: 2px 6px;
  1871. white-space: nowrap;
  1872. }
  1873. .score-pop .sp-name {
  1874. font-weight: 800;
  1875. font-size: 13px;
  1876. color: var(--ink);
  1877. }
  1878. .score-pop .sp-score {
  1879. margin-left: auto;
  1880. font-size: 16px;
  1881. font-weight: 900;
  1882. color: var(--blue);
  1883. }
  1884. .score-pop .sp-body {
  1885. white-space: pre-wrap;
  1886. }
  1887. @keyframes popIn {
  1888. from {
  1889. opacity: 0;
  1890. transform: translateY(-4px);
  1891. }
  1892. to {
  1893. opacity: 1;
  1894. transform: none;
  1895. }
  1896. }
  1897. /* 任务面板 */
  1898. #task-panel {
  1899. position: fixed;
  1900. right: 22px;
  1901. bottom: 22px;
  1902. width: 440px;
  1903. max-height: 55vh;
  1904. z-index: 130; /* 高于弹层(modal-bg 70/dialog 120),搜索进度日志始终可见 */
  1905. display: flex;
  1906. flex-direction: column;
  1907. border: 1px solid var(--line-dark);
  1908. border-radius: 12px;
  1909. background: var(--card);
  1910. box-shadow: var(--shadow-lg);
  1911. overflow: hidden;
  1912. }
  1913. #task-panel header {
  1914. all: unset;
  1915. display: flex;
  1916. align-items: center;
  1917. gap: 9px;
  1918. padding: 11px 14px;
  1919. background: var(--navy-deep);
  1920. color: #fff;
  1921. font-size: 13px;
  1922. font-weight: 700;
  1923. }
  1924. #task-panel header .dot {
  1925. width: 8px;
  1926. height: 8px;
  1927. border-radius: 50%;
  1928. background: #f5b942;
  1929. animation: blink 1s infinite;
  1930. }
  1931. #task-panel header .dot.done {
  1932. background: #3fb27f;
  1933. animation: none;
  1934. }
  1935. #task-panel header .dot.failed {
  1936. background: #e0492f;
  1937. animation: none;
  1938. }
  1939. @keyframes blink {
  1940. 50% {
  1941. opacity: 0.3;
  1942. }
  1943. }
  1944. #task-panel header button {
  1945. margin-left: auto;
  1946. background: none;
  1947. border: 0;
  1948. color: #9eb0c5;
  1949. font-size: 15px;
  1950. }
  1951. #task-panel header button:hover {
  1952. color: #fff;
  1953. }
  1954. #task-log {
  1955. font-family: "IBM Plex Mono", monospace;
  1956. font-size: 11px;
  1957. line-height: 1.65;
  1958. color: var(--ink-soft);
  1959. white-space: pre-wrap;
  1960. overflow: auto;
  1961. padding: 12px 14px;
  1962. background: #fafaf6;
  1963. flex: 1;
  1964. }
  1965. /* 弹窗(新建搜索) */
  1966. .modal-bg {
  1967. position: fixed;
  1968. inset: 0;
  1969. background: rgba(19, 30, 46, 0.5);
  1970. z-index: 70;
  1971. display: grid;
  1972. place-items: center;
  1973. backdrop-filter: blur(2px);
  1974. }
  1975. /* 不能 overflow:hidden,否则渠道下拉面板会被裁掉 */
  1976. .modal {
  1977. width: 460px;
  1978. background: var(--card);
  1979. border-radius: 14px;
  1980. box-shadow: var(--shadow-lg);
  1981. }
  1982. .modal h2 {
  1983. padding: 14px 18px;
  1984. background: var(--navy-deep);
  1985. color: #fff;
  1986. font-size: 15px;
  1987. letter-spacing: 2px;
  1988. border-radius: 14px 14px 0 0;
  1989. }
  1990. .modal .mb {
  1991. padding: 18px;
  1992. display: grid;
  1993. gap: 12px;
  1994. }
  1995. .modal label {
  1996. font-size: 12px;
  1997. color: var(--ink-soft);
  1998. display: grid;
  1999. gap: 5px;
  2000. }
  2001. .modal .mf {
  2002. display: flex;
  2003. justify-content: flex-end;
  2004. gap: 10px;
  2005. padding: 0 18px 18px;
  2006. }
  2007. /* 渠道下拉多选 */
  2008. .dd {
  2009. position: relative;
  2010. }
  2011. .dd-btn {
  2012. width: 100%;
  2013. display: flex;
  2014. justify-content: space-between;
  2015. align-items: center;
  2016. gap: 8px;
  2017. text-align: left;
  2018. padding: 7px 10px;
  2019. border: 1px solid var(--line-dark);
  2020. border-radius: 8px;
  2021. background: #fff;
  2022. font-size: 13px;
  2023. color: var(--ink);
  2024. }
  2025. .dd-btn .dd-arrow {
  2026. color: var(--ink-faint);
  2027. flex: none;
  2028. }
  2029. .dd-btn:focus {
  2030. border-color: var(--blue);
  2031. }
  2032. .dd-panel {
  2033. position: absolute;
  2034. left: 0;
  2035. right: 0;
  2036. top: calc(100% + 4px);
  2037. z-index: 10;
  2038. background: #fff;
  2039. border: 1px solid var(--line-dark);
  2040. border-radius: 10px;
  2041. box-shadow: var(--shadow-lg);
  2042. padding: 6px;
  2043. max-height: 220px;
  2044. overflow: auto;
  2045. }
  2046. .modal label.dd-opt {
  2047. display: flex;
  2048. flex-direction: row;
  2049. align-items: center;
  2050. gap: 8px;
  2051. padding: 7px 9px;
  2052. border-radius: 6px;
  2053. font-size: 13px;
  2054. color: var(--ink);
  2055. cursor: pointer;
  2056. }
  2057. .dd-opt:hover {
  2058. background: #f4f3ee;
  2059. }
  2060. .dd-opt input {
  2061. accent-color: var(--blue);
  2062. margin: 0;
  2063. cursor: pointer;
  2064. }
  2065. .dd-opt.sel {
  2066. background: var(--blue-bg);
  2067. font-weight: 500;
  2068. }
  2069. /* 聚类库占位 */
  2070. .cluster-empty {
  2071. display: grid;
  2072. place-items: center;
  2073. min-height: 60vh;
  2074. }
  2075. .cluster-empty .inner {
  2076. text-align: center;
  2077. color: var(--ink-faint);
  2078. }
  2079. .cluster-empty .stamp {
  2080. width: 120px;
  2081. height: 120px;
  2082. margin: 0 auto 18px;
  2083. border: 3px solid var(--line-dark);
  2084. border-radius: 50%;
  2085. display: grid;
  2086. place-items: center;
  2087. font-family: "Noto Serif SC", serif;
  2088. font-size: 30px;
  2089. font-weight: 900;
  2090. color: var(--line-dark);
  2091. transform: rotate(-8deg);
  2092. letter-spacing: 4px;
  2093. }
  2094. [hidden] {
  2095. display: none !important;
  2096. }
  2097. /* ── 页内提示(替代浏览器原生 alert) ── */
  2098. #toast-wrap {
  2099. position: fixed;
  2100. top: 18px;
  2101. left: 50%;
  2102. transform: translateX(-50%);
  2103. z-index: 120;
  2104. display: flex;
  2105. flex-direction: column;
  2106. align-items: center;
  2107. gap: 10px;
  2108. pointer-events: none;
  2109. }
  2110. .toast {
  2111. pointer-events: auto;
  2112. display: flex;
  2113. align-items: flex-start;
  2114. gap: 10px;
  2115. min-width: 240px;
  2116. max-width: min(440px, calc(100vw - 32px));
  2117. padding: 12px 14px 12px 13px;
  2118. background: var(--card);
  2119. color: var(--ink);
  2120. border: 1px solid var(--line-dark);
  2121. border-left: 4px solid var(--navy);
  2122. border-radius: 10px;
  2123. box-shadow: var(--shadow-lg);
  2124. font-size: 13px;
  2125. line-height: 1.55;
  2126. animation: toastIn 0.18s ease;
  2127. }
  2128. .toast.out {
  2129. animation: toastOut 0.16s ease forwards;
  2130. }
  2131. .toast .ic {
  2132. flex: none;
  2133. width: 18px;
  2134. height: 18px;
  2135. margin-top: 1px;
  2136. display: grid;
  2137. place-items: center;
  2138. border-radius: 50%;
  2139. font-size: 12px;
  2140. font-weight: 900;
  2141. color: #fff;
  2142. background: var(--navy);
  2143. }
  2144. .toast .msg {
  2145. flex: 1;
  2146. word-break: break-word;
  2147. }
  2148. .toast.error {
  2149. border-left-color: var(--seal);
  2150. }
  2151. .toast.error .ic {
  2152. background: var(--seal);
  2153. }
  2154. .toast.success {
  2155. border-left-color: var(--green);
  2156. }
  2157. .toast.success .ic {
  2158. background: var(--green);
  2159. }
  2160. .toast.warn {
  2161. border-left-color: var(--amber);
  2162. }
  2163. .toast.warn .ic {
  2164. background: var(--amber);
  2165. }
  2166. @keyframes toastIn {
  2167. from {
  2168. opacity: 0;
  2169. transform: translateY(-10px);
  2170. }
  2171. to {
  2172. opacity: 1;
  2173. transform: none;
  2174. }
  2175. }
  2176. @keyframes toastOut {
  2177. to {
  2178. opacity: 0;
  2179. transform: translateY(-8px);
  2180. }
  2181. }
  2182. /* Query 规则弹层 */
  2183. .qr-box { background:#fff; border-radius:14px; box-shadow:0 10px 44px rgba(0,0,0,.18);
  2184. width:96vw; max-width:1200px; max-height:92vh; display:flex; flex-direction:column; overflow:hidden; }
  2185. .qr-head { display:flex; align-items:center; padding:15px 20px; border-bottom:1px solid #eee; }
  2186. .qr-title { font-size:15px; font-weight:600; color:#1a1a1a; }
  2187. .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; }
  2188. .qr-x:hover { background:#f2f2f2; color:#333; }
  2189. .qr-bar { display:flex; align-items:center; gap:10px; padding:11px 20px; border-bottom:1px solid #f0f0f0; background:#fcfcfc; }
  2190. .qr-hint { color:#888; font-size:12px; margin-left:4px; }
  2191. .qr-thr-lab { color:#666; font-size:12px; }
  2192. .qr-thr { width:46px; padding:3px 5px; border:1px solid #ddd; border-radius:6px; font-size:12px; }
  2193. #qr-score:disabled { opacity:.6; cursor:wait; }
  2194. .ui-confirm-bg { position:fixed; inset:0; background:rgba(0,0,0,.38); z-index:200; display:flex; align-items:center; justify-content:center; }
  2195. .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; }
  2196. .ui-confirm-msg { font-size:14px; color:#1a1a1a; line-height:1.6; white-space:pre-line; margin-bottom:18px; }
  2197. .ui-confirm-acts { display:flex; justify-content:flex-end; gap:10px; }
  2198. .qr-dims { padding:8px 20px 10px; max-height:32vh; overflow:auto; border-bottom:1px solid #f0f0f0; }
  2199. .qr-row { display:flex; align-items:flex-start; gap:10px; padding:4px 0; }
  2200. .qr-row + .qr-row { border-top:1px solid #f6f6f6; }
  2201. .qr-lab { min-width:64px; color:#999; font-size:12.5px; padding-top:5px; flex-shrink:0; }
  2202. .qr-chips { display:flex; flex-wrap:wrap; gap:6px; flex:1; }
  2203. .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; }
  2204. .chip:hover { border-color:#bbb; color:#222; }
  2205. .chip.on { background:#1a1a1a; border-color:#1a1a1a; color:#fff; font-weight:500; }
  2206. .chip.axis.on { background:#2563eb; border-color:#2563eb; }
  2207. .qr-table-wrap { overflow:auto; flex:1; }
  2208. .qr-tab { border-collapse:collapse; font-size:11px; }
  2209. .qr-tab th, .qr-tab td { border:1px solid #eee; padding:3px 7px; white-space:nowrap; }
  2210. .qr-tab thead th { position:sticky; top:0; background:#f7f7f7; z-index:2; }
  2211. .qr-corner { position:sticky; left:0; z-index:3; background:#eef0f3; font-weight:600; color:#555; }
  2212. .qr-th { position:sticky; left:0; background:#fafafa; z-index:1; text-align:left; color:#444; }
  2213. .qr-tl1 { background:#eef0f3; font-weight:600; color:#444; }
  2214. .qr-gh { background:#e8ebef; font-weight:600; color:#333; text-align:center; }
  2215. .qr-ah { background:#f3f4f6; color:#555; text-align:center; }
  2216. .qr-c.t0 { background:#fafafa; color:#bbb; } .qr-c.t1 { background:#f1f8f1; }
  2217. .qr-c.t2 { background:#d8ecd8; } .qr-c.t3 { background:#b9ddb9; }
  2218. .qr-c.dead { color:#ccc; }
  2219. .qr-c.keep { background:#fff3bf !important; box-shadow:inset 0 0 0 2px #f59e0b; color:#111; font-weight:700; cursor:pointer; }
  2220. .qr-c.keep:hover { background:#ffe066 !important; }
  2221. .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; }
  2222. .qr-pop { position:fixed; z-index:60; width:300px; background:#fff; border:1px solid #e2e2e2;
  2223. border-radius:11px; box-shadow:0 8px 30px rgba(0,0,0,.18); padding:13px 15px; font-size:12.5px; color:#333; }
  2224. .qr-pop .q { font-size:13.5px; font-weight:600; color:#1a1a1a; margin-bottom:2px; word-break:break-all; }
  2225. .qr-pop .orig { font-size:11px; color:#aaa; margin-bottom:8px; }
  2226. .qr-pop .sc { display:flex; align-items:baseline; gap:8px; margin:6px 0; }
  2227. .qr-pop .sc b { font-size:22px; color:#2563eb; }
  2228. .qr-pop .dim { color:#888; font-size:11.5px; }
  2229. .qr-pop .rsn { color:#555; margin:7px 0 10px; line-height:1.5; }
  2230. .qr-pop .acts { display:flex; gap:8px; }
  2231. </style>
  2232. </head>
  2233. <body>
  2234. <div id="toast-wrap" aria-live="polite"></div>
  2235. <header>
  2236. <div class="logo">
  2237. <div class="seal">解</div>
  2238. <div><b>mode_workflow</b><small>解构工作台 · MODE WORKBENCH</small></div>
  2239. </div>
  2240. <nav id="nav">
  2241. <a
  2242. href="#dashboard"
  2243. data-tab="dashboard"
  2244. >Dashboard</a
  2245. >
  2246. <a
  2247. href="#dataset"
  2248. data-tab="dataset"
  2249. >Dataset</a
  2250. >
  2251. <a
  2252. href="#cluster"
  2253. data-tab="cluster"
  2254. >知识库</a
  2255. >
  2256. </nav>
  2257. <div class="spacer"></div>
  2258. <div class="hint">SEARCH · EXTRACT · ARCHIVE</div>
  2259. </header>
  2260. <main id="view-dashboard"></main>
  2261. <main id="view-dataset">
  2262. <div class="ds-top">
  2263. <div class="mode-switch">
  2264. <button
  2265. id="m-process"
  2266. class="on"
  2267. >
  2268. 工序
  2269. </button>
  2270. <button id="m-tools">工具</button>
  2271. </div>
  2272. <div style="flex: 1"></div>
  2273. <button
  2274. class="btn seal"
  2275. id="btn-new-search"
  2276. >
  2277. + 新建搜索
  2278. </button>
  2279. <button class="btn" id="btn-query-rule" style="margin-left:8px">Query 规则</button>
  2280. </div>
  2281. <div class="ds-grid">
  2282. <div class="card">
  2283. <div class="col-head" style="position:relative">
  2284. QUERY
  2285. <div style="display:flex;align-items:center;gap:8px">
  2286. <span
  2287. class="n"
  2288. id="q-count"
  2289. ></span>
  2290. <button class="qf-btn" id="qf-btn" title="筛选 query 列表">筛选 ▾</button>
  2291. </div>
  2292. <div class="qf-pop" id="qf-pop" hidden>
  2293. <label>排序
  2294. <select id="qf-time">
  2295. <option value="desc">最新在前</option>
  2296. <option value="asc">最早在前</option>
  2297. </select>
  2298. </label>
  2299. <label>是否搜索
  2300. <select id="qf-searched">
  2301. <option value="all">全部</option>
  2302. <option value="yes">已搜索</option>
  2303. <option value="no">未搜索</option>
  2304. </select>
  2305. </label>
  2306. </div>
  2307. </div>
  2308. <div
  2309. class="qlist"
  2310. id="query-list"
  2311. >
  2312. <div class="empty">暂无 query</div>
  2313. </div>
  2314. </div>
  2315. <div class="card">
  2316. <div class="col-head posts-head">
  2317. <div class="ph-title">帖子 <span class="n" id="p-count"></span></div>
  2318. <div class="ph-actions">
  2319. <button class="btn sm" id="btn-batch" disabled hidden>批量解构</button>
  2320. <button class="btn sm" id="btn-extract-adopted" hidden>解构全部已采纳</button>
  2321. <button class="btn sm" id="btn-cat-adopted" hidden>归类全部已采纳</button>
  2322. </div>
  2323. </div>
  2324. <div
  2325. class="plat-tabs"
  2326. id="plat-tabs"
  2327. hidden
  2328. ></div>
  2329. <div
  2330. class="plist"
  2331. id="post-list"
  2332. >
  2333. <div class="empty"><span class="glyph">←</span>先选择左侧 query</div>
  2334. </div>
  2335. </div>
  2336. <div class="card xp">
  2337. <div
  2338. class="xp-head"
  2339. id="xp-head"
  2340. >
  2341. <span class="st">解构结果</span>
  2342. </div>
  2343. <div
  2344. class="xp-body"
  2345. id="xp-body"
  2346. >
  2347. <div class="empty"><span class="glyph">←</span>选择一个帖子查看解构结果</div>
  2348. </div>
  2349. </div>
  2350. </div>
  2351. </main>
  2352. <main id="view-cluster">
  2353. <iframe
  2354. id="cluster-frame"
  2355. title="知识检索"
  2356. loading="lazy"
  2357. ></iframe>
  2358. </main>
  2359. <div
  2360. id="task-panel"
  2361. hidden
  2362. >
  2363. <header>
  2364. <span
  2365. class="dot"
  2366. id="task-dot"
  2367. ></span
  2368. ><span id="task-title">任务</span> <button onclick="hideTask()">✕</button>
  2369. </header>
  2370. <div id="task-log"></div>
  2371. </div>
  2372. <!-- 帖子详情弹层(评分详情参考 fixed_query_eval) -->
  2373. <dialog id="post-dialog">
  2374. <div class="pd-wrap">
  2375. <div class="pd-head">
  2376. <div style="min-width: 0">
  2377. <div
  2378. class="pd-meta"
  2379. id="pd-meta"
  2380. ></div>
  2381. <h3 id="pd-title"></h3>
  2382. </div>
  2383. <button
  2384. class="pd-close"
  2385. onclick="document.getElementById('post-dialog').close()"
  2386. >
  2387. </button>
  2388. </div>
  2389. <div class="pd-body">
  2390. <section>
  2391. <div id="pd-verdict"></div>
  2392. <div class="pd-sec-title">抓取文本节选</div>
  2393. <div
  2394. class="pd-raw"
  2395. id="pd-text"
  2396. ></div>
  2397. <div class="pd-sec-title">图片预览</div>
  2398. <div
  2399. class="pd-images"
  2400. id="pd-images"
  2401. ></div>
  2402. <div
  2403. class="pd-sec-title"
  2404. id="pd-videos-title"
  2405. style="display: none"
  2406. >
  2407. 视频预览
  2408. </div>
  2409. <div
  2410. class="pd-videos"
  2411. id="pd-videos"
  2412. style="display: none"
  2413. ></div>
  2414. <div
  2415. class="pd-tags"
  2416. id="pd-tags"
  2417. ></div>
  2418. </section>
  2419. <aside>
  2420. <div class="pd-score-head">
  2421. <span class="t">评分详情</span>
  2422. <span class="pd-overall">综合评分 <b id="pd-overall">—</b></span>
  2423. </div>
  2424. <div id="pd-scores"></div>
  2425. </aside>
  2426. </div>
  2427. </div>
  2428. </dialog>
  2429. <!-- 重新解构 · 编辑解构 Prompt -->
  2430. <dialog id="reextract-dlg">
  2431. <div class="rx-wrap">
  2432. <div class="rx-head">
  2433. <div class="rx-title">重新解构 · 编辑解构 Prompt</div>
  2434. <button
  2435. class="btn sm"
  2436. onclick="document.getElementById('reextract-dlg').close()"
  2437. >
  2438. 关闭
  2439. </button>
  2440. </div>
  2441. <div class="rx-sub">
  2442. 修改下面的解构 Prompt 后,点「保存修改」将按最新 Prompt
  2443. 重新解构本帖(生成新版本,旧版本保留)。改动仅本次生效,不会改写默认 Prompt。
  2444. </div>
  2445. <div class="rx-model">
  2446. <label>模型:</label>
  2447. <select id="rx-model"></select>
  2448. </div>
  2449. <textarea
  2450. id="rx-prompt"
  2451. class="rx-prompt"
  2452. spellcheck="false"
  2453. ></textarea>
  2454. <div class="rx-foot">
  2455. <button
  2456. class="btn"
  2457. onclick="document.getElementById('reextract-dlg').close()"
  2458. >
  2459. 取消
  2460. </button>
  2461. <button
  2462. class="btn primary"
  2463. id="rx-save"
  2464. onclick="saveReextract()"
  2465. >
  2466. 保存修改
  2467. </button>
  2468. </div>
  2469. </div>
  2470. </dialog>
  2471. <!-- 图片预览灯箱(支持左右切换) -->
  2472. <dialog
  2473. class="lightbox"
  2474. id="lightbox"
  2475. onclick="if (event.target === this) closeLightbox();"
  2476. >
  2477. <button
  2478. class="lb-close"
  2479. onclick="closeLightbox()"
  2480. title="关闭 (Esc)"
  2481. >
  2482. </button>
  2483. <button
  2484. class="lb-nav lb-prev"
  2485. onclick="lbStep(-1)"
  2486. title="上一张 (←)"
  2487. >
  2488. </button>
  2489. <figure class="lb-stage">
  2490. <img
  2491. id="lb-img"
  2492. src=""
  2493. alt=""
  2494. />
  2495. <figcaption id="lb-count"></figcaption>
  2496. </figure>
  2497. <button
  2498. class="lb-nav lb-next"
  2499. onclick="lbStep(1)"
  2500. title="下一张 (→)"
  2501. >
  2502. </button>
  2503. </dialog>
  2504. <div
  2505. class="modal-bg"
  2506. id="search-modal"
  2507. hidden
  2508. >
  2509. <div class="modal">
  2510. <h2>新建搜索</h2>
  2511. <div class="mb">
  2512. <label
  2513. >Query(评估锚点,必填)<input
  2514. type="text"
  2515. id="s-query"
  2516. placeholder="如:AI 人像 图片 生成 怎么做"
  2517. /></label>
  2518. <label
  2519. >解构方向<select id="s-mode">
  2520. <option value="工序">工序</option>
  2521. <option value="工具">工具</option>
  2522. </select></label
  2523. >
  2524. <label
  2525. >同义措辞(可选,逗号分隔)<input
  2526. type="text"
  2527. id="s-syn"
  2528. placeholder="如:AI 人像生成 教程,AI 写真 怎么做"
  2529. /></label>
  2530. <label
  2531. >检索渠道(下拉多选)
  2532. <div
  2533. class="dd"
  2534. id="s-plat-dd"
  2535. >
  2536. <button
  2537. type="button"
  2538. class="dd-btn"
  2539. id="s-plat-btn"
  2540. >
  2541. 选择渠道 ▾
  2542. </button>
  2543. <div
  2544. class="dd-panel"
  2545. id="s-plat-panel"
  2546. hidden
  2547. ></div>
  2548. </div>
  2549. </label>
  2550. <label
  2551. >每措辞每渠道上限<input
  2552. type="number"
  2553. id="s-max"
  2554. value="10"
  2555. min="1"
  2556. max="50"
  2557. /></label>
  2558. </div>
  2559. <div class="mf">
  2560. <button
  2561. class="btn"
  2562. onclick="document.getElementById('search-modal').hidden = true"
  2563. >
  2564. 取消
  2565. </button>
  2566. <button
  2567. class="btn primary"
  2568. id="s-go"
  2569. >
  2570. 开始搜索
  2571. </button>
  2572. </div>
  2573. </div>
  2574. </div>
  2575. <!-- Query 规则组织器 弹层 -->
  2576. <div class="modal-bg" id="qr-modal" hidden>
  2577. <div class="qr-box">
  2578. <div class="qr-head">
  2579. <span class="qr-title">Query 词组织器</span>
  2580. <button class="qr-x" id="qr-close" title="关闭">✕</button>
  2581. </div>
  2582. <div class="qr-bar">
  2583. <button class="btn seal" id="qr-score">生成正交表</button>
  2584. <button class="btn" id="qr-search-all" hidden>搜全部达标</button>
  2585. <label class="qr-thr-lab">达标分 ≥ <input id="qr-thr" class="qr-thr" type="number" min="0" max="10" step="0.5" value="7"></label>
  2586. <span id="qr-hint" class="qr-hint"></span>
  2587. </div>
  2588. <div id="qr-dims" class="qr-dims"></div>
  2589. <div id="qr-table-wrap" class="qr-table-wrap"></div>
  2590. </div>
  2591. <div id="qr-pop" class="qr-pop" hidden></div>
  2592. </div>
  2593. <script>
  2594. /* ════ 基础 ════ */
  2595. const $ = (s) => document.querySelector(s);
  2596. /* 页内提示,替代浏览器原生 alert();type: info|error|success|warn */
  2597. function toast(msg, type = "info", ms = 3200) {
  2598. const wrap = $("#toast-wrap");
  2599. if (!wrap) return;
  2600. const ic = { info: "i", error: "!", success: "✓", warn: "!" }[type] || "i";
  2601. const el = document.createElement("div");
  2602. el.className = "toast " + type;
  2603. el.innerHTML = `<span class="ic">${ic}</span><span class="msg">${esc(msg)}</span>`;
  2604. const dismiss = () => {
  2605. el.classList.add("out");
  2606. el.addEventListener("animationend", () => el.remove(), { once: true });
  2607. };
  2608. el.addEventListener("click", dismiss);
  2609. wrap.appendChild(el);
  2610. setTimeout(dismiss, ms);
  2611. }
  2612. const api = (p, opt) =>
  2613. fetch(p, opt).then(async (r) => {
  2614. if (!r.ok)
  2615. throw Object.assign(new Error("api"), { status: r.status, body: await r.json().catch(() => ({})) });
  2616. return r.json();
  2617. });
  2618. const esc = (s) =>
  2619. String(s ?? "").replace(
  2620. /[&<>"']/g,
  2621. (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[c],
  2622. );
  2623. /* 目的列: 把 intent 里的 {类别:值} 标记渲染成彩色胶囊 (口径同 procedure-dsl renderer.py:render_intent)。
  2624. 合法类别 5 个: effect/via/act/in-type/out-type; 其余落 ik-other(红删除线,当 lint 警告)。
  2625. 标记外的字面文字与值都做 HTML 转义。 */
  2626. const INTENT_KIND = {
  2627. effect: "ik-effect", via: "ik-via", act: "ik-act",
  2628. "in-type": "ik-in-type", "out-type": "ik-out-type",
  2629. };
  2630. const renderIntent = (text) => {
  2631. const s = String(text ?? "");
  2632. const re = /\{([\w-]+):([^}]+)\}/g;
  2633. let out = "", last = 0, m;
  2634. while ((m = re.exec(s))) {
  2635. out += esc(s.slice(last, m.index).replace(/`/g, ""));
  2636. const kc = INTENT_KIND[m[1]] || "ik-other";
  2637. out += `<span class="intent-tok ${kc}">${esc(m[2])}</span>`;
  2638. last = m.index + m[0].length;
  2639. }
  2640. return out + esc(s.slice(last).replace(/`/g, ""));
  2641. };
  2642. /* 外链图片走本服务同源反代,绕过公众号(mmbiz.qpic.cn)等防盗链 */
  2643. const imgProxy = (u) => (/^https?:\/\//.test(u || "") ? "/api/img?u=" + encodeURIComponent(u) : u || "");
  2644. /* 图片加载策略:优先「浏览器直连 CDN」(referrerpolicy=no-referrer 多数能绕防盗链),
  2645. 直连失败再回退到同源代理 /api/img。
  2646. 为什么:公网走 Cloudflare 快速隧道(trycloudflare),所有经 /api/img 的图片字节都要
  2647. 「上游CDN → 本机 → 隧道(受本机上行带宽限制)→ 客户」,一帖十几张图(每张 100~180KB)
  2648. 就把本机上行打满,于是「本地快、公网慢」。改为浏览器直连后,绝大多数图片字节不再过本机/
  2649. 隧道,只有少数仍被防盗链拦截的才回退代理。 */
  2650. const imgDirect = (u) => (/^https?:\/\//.test(u || "") ? u : imgProxy(u));
  2651. /* 视频走专用同源反代 /api/video:服务端按平台补 Referer(抖音 aweme/play 等必需)
  2652. + 透传 Range 头做边下边播/拖拽。不像 /api/img 那样整文件缓冲,避免慢 + BrokenPipe。 */
  2653. const vidProxy = (u) => (/^https?:\/\//.test(u || "") ? "/api/video?u=" + encodeURIComponent(u) : u || "");
  2654. /* 从各种 YouTube 链接里抠出 video_id(watch?v= / youtu.be/ / embed/) */
  2655. const ytId = (u) => {
  2656. const m =
  2657. (u || "").match(/[?&]v=([\w-]{6,})/) ||
  2658. (u || "").match(/youtu\.be\/([\w-]{6,})/) ||
  2659. (u || "").match(/embed\/([\w-]{6,})/);
  2660. return m ? m[1] : "";
  2661. };
  2662. /* 视频代理也失败时,把 <video> 换成「源站打开」链接(data-src 存原始 URL) */
  2663. function vidFallback(el) {
  2664. el.onerror = null;
  2665. const u = el.dataset.src || "";
  2666. if (u)
  2667. el.outerHTML =
  2668. '<a class="vid-fallback" href="' + u.replace(/"/g, "&quot;") +
  2669. '" target="_blank" rel="noopener">源站打开视频 ↗</a>';
  2670. }
  2671. function imgFallback(el, proxy) {
  2672. el.onerror = null; // 防止回调里再次触发自身造成死循环
  2673. if (!el.dataset.fb) {
  2674. el.dataset.fb = "1"; // 直连失败 → 回退同源代理(防盗链兜底)
  2675. el.onerror = () => imgFallback(el, proxy);
  2676. el.src = proxy;
  2677. return;
  2678. }
  2679. if (el.dataset.ph)
  2680. el.outerHTML = el.dataset.ph; // 代理也失败:换占位元素
  2681. else el.style.opacity = 0.25; // 无占位:淡化
  2682. }
  2683. function imgHtml(u, { cls = "", extra = "", ph = "" } = {}) {
  2684. const phAttr = ph ? ` data-ph="${esc(ph)}"` : "";
  2685. return `<img ${cls ? `class="${cls}" ` : ""}src="${esc(imgDirect(u))}" referrerpolicy="no-referrer" loading="lazy"${phAttr} ${extra} onerror="imgFallback(this,'${esc(imgProxy(u))}')">`;
  2686. }
  2687. const state = {
  2688. tab: "dashboard",
  2689. mode: "process",
  2690. queryId: null,
  2691. caseId: null,
  2692. post: null,
  2693. version: null,
  2694. platFilter: "all",
  2695. doneFilter: true,
  2696. selected: new Set(),
  2697. queries: [],
  2698. posts: [],
  2699. };
  2700. const PLAT_CLS = (p) =>
  2701. ({ xhs: "xhs", gzh: "gzh", zhihu: "zhihu", douyin: "douyin", sph: "sph", youtube: "youtube", x: "x" })[p] ||
  2702. "other";
  2703. const PLAT_NAME = (p) =>
  2704. ({
  2705. xhs: "小红书",
  2706. gzh: "公众号",
  2707. sph: "视频号",
  2708. github: "GitHub",
  2709. toutiao: "头条",
  2710. douyin: "抖音",
  2711. bili: "哔哩哔哩",
  2712. zhihu: "知乎",
  2713. weibo: "微博",
  2714. youtube: "YouTube",
  2715. x: "X",
  2716. })[p] ||
  2717. p ||
  2718. "?";
  2719. /* 渠道 logo 徽标(品牌色圆角方块,hover 显示渠道名) */
  2720. /* 有对应 SVG 图标的渠道(文件位于 /icons/<key>.svg) */
  2721. const PLAT_ICONS = new Set(["xhs", "gzh", "sph", "github", "douyin", "bili", "zhihu", "weibo", "youtube"]);
  2722. const PLAT_LOGO = (p, size = 18) =>
  2723. PLAT_ICONS.has(p)
  2724. ? `<span class="plat-logo" title="${PLAT_NAME(p)}"><img src="/icons/${p}.svg" width="${size}" height="${size}" alt="${PLAT_NAME(p)}" loading="lazy"></span>`
  2725. : `<span class="plat other">${esc(PLAT_NAME(p))}</span>`;
  2726. const MODELS_PROC = ["anthropic/claude-sonnet-4-6", "google/gemini-3.1-flash-lite"];
  2727. const MODELS_TOOL = ["google/gemini-3.1-flash-lite", "anthropic/claude-sonnet-4-6"];
  2728. const scoreCls = (v) => (v == null ? "s0" : v >= 9 ? "s9" : v >= 8 ? "s8" : v >= 6 ? "s6" : "s0");
  2729. /* ════ 路由 ════ */
  2730. function route() {
  2731. state.tab = (location.hash || "#dashboard").slice(1);
  2732. if (!["dashboard", "dataset", "cluster"].includes(state.tab)) state.tab = "dashboard";
  2733. document.querySelectorAll("nav a").forEach((a) => a.classList.toggle("on", a.dataset.tab === state.tab));
  2734. document.querySelectorAll("main").forEach((m) => m.classList.toggle("on", m.id === "view-" + state.tab));
  2735. if (state.tab === "dashboard") renderDashboard();
  2736. if (state.tab === "dataset" && !state.queries.length) loadQueries();
  2737. if (state.tab === "cluster") {
  2738. // 首次打开聚类库才加载内嵌检索页
  2739. const f = $("#cluster-frame");
  2740. if (f && !f.src) f.src = "/search.html";
  2741. }
  2742. }
  2743. window.addEventListener("hashchange", route);
  2744. /* ════ Dashboard ════ */
  2745. let chartRefs = [];
  2746. async function renderDashboard() {
  2747. const v = $("#view-dashboard");
  2748. let d;
  2749. try {
  2750. d = await api("/api/dashboard");
  2751. } catch (e) {
  2752. v.innerHTML = `<div class="card empty"><span class="glyph">!</span>Dashboard 加载失败:${esc(e.body?.error || e.status)}</div>`;
  2753. return;
  2754. }
  2755. const r = d.result,
  2756. p = d.process_data;
  2757. // 进度百分比向下取整:200/201=99.5% 显示 99%,未真正做完不会显示 100%
  2758. const pct = (a, b) => (b ? Math.floor((a / b) * 100) : 0);
  2759. const platBreak = (arr) =>
  2760. (arr || [])
  2761. .map(
  2762. ([k, n]) =>
  2763. `<span class="pb-item">${PLAT_LOGO(k, 15)}<b class="num">${n}</b></span>`,
  2764. )
  2765. .join("") || "—";
  2766. v.innerHTML = `
  2767. <div class="dash-section"><h2>结果数据</h2><div class="rule"></div><span class="tag">RESULTS</span></div>
  2768. <div class="cards">
  2769. <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>
  2770. <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>
  2771. <div class="card stat a"><div class="lbl">工具数量</div><div class="val num">${r.tool_count}</div><div class="sub">mode_tools 去重工具名</div></div>
  2772. <div class="card stat r"><div class="lbl">内容树覆盖节点</div><div class="val num">0</div>
  2773. <div class="sub">0%</div></div>
  2774. <div class="card stat"><div class="lbl">实质数量</div><div class="val num">${r.substance_count}</div><div class="sub">去重实质条目数</div></div>
  2775. <div class="card stat"><div class="lbl">形式数量</div><div class="val num">${r.form_count}</div><div class="sub">去重形式条目数</div></div>
  2776. </div>
  2777. <div class="dash-section"><h2>过程数据</h2><div class="rule"></div><span class="tag">PROCESS</span></div>
  2778. <div class="cards">
  2779. <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>
  2780. <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>
  2781. <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>
  2782. <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>
  2783. <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>
  2784. <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>
  2785. </div>
  2786. <div class="charts">
  2787. <div class="card chart-card span6"><h3>工序提及工具 TOP10</h3><div class="chart" id="ch-via" style="height:300px"></div></div>
  2788. <div class="card chart-card span6"><h3>解构成本趋势</h3><div class="chart" id="ch-cost" style="height:300px"></div></div>
  2789. <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>
  2790. <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>
  2791. <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>
  2792. </div>`;
  2793. chartRefs.forEach((c) => c.dispose());
  2794. chartRefs = [];
  2795. const mk = (id, opt) => {
  2796. const c = echarts.init($(id));
  2797. c.setOption(opt);
  2798. chartRefs.push(c);
  2799. return c;
  2800. };
  2801. const ink = "#1c2433",
  2802. faint = "#9aa3b0",
  2803. grid = { left: 8, right: 16, top: 8, bottom: 8, containLabel: true };
  2804. /* 热力图 */
  2805. mk("#ch-matrix", {
  2806. tooltip: { formatter: (pr) => `${r.matrix_actions[pr.value[1]]} × ${r.matrix_types[pr.value[0]]}` },
  2807. grid: { left: 8, right: 16, top: 8, bottom: 60, containLabel: true },
  2808. xAxis: {
  2809. type: "category",
  2810. data: r.matrix_types,
  2811. axisLabel: { rotate: 60, fontSize: 9, color: faint },
  2812. splitArea: { show: true, areaStyle: { color: ["#fcfcf9", "#f5f4ef"] } },
  2813. },
  2814. yAxis: {
  2815. type: "category",
  2816. data: r.matrix_actions,
  2817. axisLabel: { fontSize: 10, color: ink },
  2818. splitArea: { show: true },
  2819. },
  2820. visualMap: { show: false, min: 0, max: 1, inRange: { color: ["#f0efe8", "#bb3a22"] } },
  2821. series: [
  2822. {
  2823. type: "heatmap",
  2824. data: r.matrix_cells.map(([a, t]) => [t, a, 1]),
  2825. itemStyle: { borderColor: "#fff", borderWidth: 1 },
  2826. },
  2827. ],
  2828. });
  2829. const bar = (data, color) => ({
  2830. tooltip: {},
  2831. grid,
  2832. xAxis: { type: "value", axisLabel: { color: faint } },
  2833. yAxis: {
  2834. type: "category",
  2835. data: data.map((x) => x[0]).reverse(),
  2836. axisLabel: { color: ink, fontSize: 11, width: 130, overflow: "truncate" },
  2837. },
  2838. series: [
  2839. {
  2840. type: "bar",
  2841. data: data.map((x) => x[1]).reverse(),
  2842. itemStyle: { color, borderRadius: [0, 3, 3, 0] },
  2843. barMaxWidth: 16,
  2844. label: { show: true, position: "right", color: faint, fontSize: 10 },
  2845. },
  2846. ],
  2847. });
  2848. mk("#ch-via", r.via_top10.length ? bar(r.via_top10, "#1e3a5f") : emptyOpt());
  2849. mk("#ch-sub", r.substance_top.length ? bar(r.substance_top, "#b45309") : emptyOpt());
  2850. mk("#ch-form", r.form_top.length ? bar(r.form_top, "#0f6b5c") : emptyOpt());
  2851. mk(
  2852. "#ch-cost",
  2853. p.cost_trend.length
  2854. ? {
  2855. tooltip: { trigger: "axis" },
  2856. grid,
  2857. xAxis: { type: "category", data: p.cost_trend.map((x) => x.date), axisLabel: { color: faint } },
  2858. yAxis: { type: "value", axisLabel: { color: faint, formatter: "${value}" } },
  2859. series: [
  2860. {
  2861. type: "line",
  2862. data: p.cost_trend.map((x) => x.cost),
  2863. smooth: true,
  2864. symbolSize: 7,
  2865. lineStyle: { color: "#bb3a22", width: 2.5 },
  2866. itemStyle: { color: "#bb3a22" },
  2867. areaStyle: { color: "rgba(187,58,34,.08)" },
  2868. },
  2869. ],
  2870. }
  2871. : emptyOpt(),
  2872. );
  2873. function emptyOpt() {
  2874. return {
  2875. title: {
  2876. text: "暂无数据",
  2877. left: "center",
  2878. top: "middle",
  2879. textStyle: { color: faint, fontSize: 12, fontWeight: 400 },
  2880. },
  2881. xAxis: { show: false },
  2882. yAxis: { show: false },
  2883. };
  2884. }
  2885. }
  2886. /* ════ Dataset:query 列表 ════ */
  2887. async function loadQueries() {
  2888. /* 工序/工具各自一张搜索表,query 列表按当前子模式拉取 */
  2889. try {
  2890. /* 接口按 query_id 升序返回;列表倒序显示(最新在上) */
  2891. state.queries = (await api("/api/queries?mode=" + state.mode)).reverse();
  2892. } catch (e) {
  2893. state.queries = [];
  2894. }
  2895. renderQueries();
  2896. /* 进入/切换子模式时默认选中第一个(即最新)query(进而联动第一帖与解构结果) */
  2897. if (!state.queryId && state.queries.length) await selectQuery(state.queries[0].query_id);
  2898. }
  2899. /* query 列表筛选/排序状态:time(按时间,用 query_id 数字序代理)+ searched(是否已搜索,post_count>0) */
  2900. const qFilter = { time: "desc", searched: "all" };
  2901. function applyQueryFilter(queries) {
  2902. let list = queries.slice();
  2903. if (qFilter.searched === "yes") list = list.filter((q) => (q.post_count || 0) > 0);
  2904. else if (qFilter.searched === "no") list = list.filter((q) => !(q.post_count || 0));
  2905. const num = (q) => {
  2906. const n = parseInt(String(q.query_id || "").replace(/^q/, ""), 10);
  2907. return isNaN(n) ? -1 : n;
  2908. };
  2909. list.sort((a, b) => (qFilter.time === "asc" ? num(a) - num(b) : num(b) - num(a)));
  2910. return list;
  2911. }
  2912. function renderQueries() {
  2913. const total = state.queries.length;
  2914. const list = applyQueryFilter(state.queries);
  2915. $("#q-count").textContent = total
  2916. ? list.length === total
  2917. ? total + " 组"
  2918. : list.length + " / " + total + " 组"
  2919. : "";
  2920. if (!total) {
  2921. $("#query-list").innerHTML = '<div class="empty">暂无 query<br>点右上「新建搜索」开始</div>';
  2922. return;
  2923. }
  2924. if (!list.length) {
  2925. $("#query-list").innerHTML = '<div class="empty">该筛选下无 query</div>';
  2926. return;
  2927. }
  2928. $("#query-list").innerHTML = list
  2929. .map((q) => {
  2930. const done = state.mode === "process" ? q.process_done : q.tools_done;
  2931. return `<div class="qitem ${q.query_id === state.queryId ? "on" : ""}" onclick="selectQuery('${q.query_id}')">
  2932. <div class="qid">${q.query_id}</div>
  2933. <div class="qt">${esc(q.query_text || "(未命名)")}</div>
  2934. <div class="qm">
  2935. <span>采纳/命中 <b class="num hit">${q.hit_count ?? 0}</b></span>
  2936. <span>总帖数 <b class="num">${q.post_count}</b></span>
  2937. <span>已解构 <b class="num">${done}</b></span>
  2938. </div>
  2939. </div>`;
  2940. })
  2941. .join("");
  2942. }
  2943. async function selectQuery(qid) {
  2944. state.queryId = qid;
  2945. state.caseId = null;
  2946. state.post = null;
  2947. state.platFilter = "all";
  2948. state.selected.clear();
  2949. renderQueries();
  2950. renderExtractEmpty();
  2951. $("#post-list").innerHTML = '<div class="empty">加载中…</div>';
  2952. try {
  2953. state.posts = await api("/api/posts?mode=" + state.mode + "&query_id=" + encodeURIComponent(qid));
  2954. } catch (e) {
  2955. state.posts = [];
  2956. }
  2957. renderPosts();
  2958. /* 默认选中「可见列表」第一帖(已解构筛选下即第一个已解构帖),无可见帖则退回全部第一帖 */
  2959. if (state.posts.length) {
  2960. const vis = visiblePosts();
  2961. await selectPost((vis[0] || state.posts[0]).case_id);
  2962. }
  2963. }
  2964. /* 空态「搜索该 query」:对当前选中 query 直接发起搜索(小红书+公众号 各20,含评估),
  2965. 复用 run_search;传当前 query_id,使结果落在同一占位 query 下(占位行被各读取点过滤,
  2966. 真帖填进来后该 query 自然从「未搜索」变「已搜索」)。完成后刷新计数与帖子列表。 */
  2967. async function searchCurrentQuery(btn) {
  2968. const q = state.queries.find((x) => x.query_id === state.queryId);
  2969. if (!q) return toast("请先选择一个 query", "warn");
  2970. const body = {
  2971. query: q.query_text,
  2972. query_id: q.query_id,
  2973. mode_type: state.mode === "process" ? "工序" : "工具",
  2974. platforms: "xhs,gzh",
  2975. max_count: 20,
  2976. };
  2977. if (btn) {
  2978. btn.disabled = true;
  2979. btn.textContent = "搜索启动中…";
  2980. }
  2981. try {
  2982. const r = await api("/api/run_search", { method: "POST", body: JSON.stringify(body) });
  2983. showTask(`搜索 · ${r.query_id} ${q.query_text}`, r.task_id, async () => {
  2984. await loadQueries();
  2985. await selectQuery(q.query_id);
  2986. });
  2987. } catch (e) {
  2988. toast("搜索启动失败:" + (e.body?.error || e.status), "error");
  2989. if (btn) {
  2990. btn.disabled = false;
  2991. btn.textContent = "🔍 搜索该 query(小红书·公众号 各20)";
  2992. }
  2993. }
  2994. }
  2995. /* ════ Dataset:帖子列表(按渠道分 tab)════ */
  2996. function setPlatFilter(p) {
  2997. state.platFilter = p;
  2998. renderPosts();
  2999. }
  3000. function toggleDoneFilter() {
  3001. state.doneFilter = !state.doneFilter;
  3002. renderPosts();
  3003. renderPostsAutoSelect();
  3004. }
  3005. /* 当前可见帖(渠道 + 已解构筛选后),供列表渲染与「默认选中」共用 */
  3006. function visiblePosts() {
  3007. const isDone = (p) => (state.mode === "process" ? p.has_process : p.has_tools);
  3008. let list =
  3009. state.platFilter === "all"
  3010. ? state.posts
  3011. : state.posts.filter((p) => (p.platform || "other") === state.platFilter);
  3012. if (state.doneFilter) list = list.filter(isDone);
  3013. return list;
  3014. }
  3015. /* 切换筛选后,若当前选中帖已被筛掉,则改选可见列表的第一帖 */
  3016. async function renderPostsAutoSelect() {
  3017. const vis = visiblePosts();
  3018. if (vis.length && !vis.some((p) => p.case_id === state.caseId)) await selectPost(vis[0].case_id);
  3019. }
  3020. function renderPosts() {
  3021. const all = state.posts;
  3022. updateBatchBtn();
  3023. /* 渠道 tab + 已解构筛选 */
  3024. const counts = {};
  3025. all.forEach((p) => {
  3026. const k = p.platform || "other";
  3027. counts[k] = (counts[k] || 0) + 1;
  3028. });
  3029. const plats = Object.keys(counts);
  3030. if (state.platFilter !== "all" && !counts[state.platFilter]) state.platFilter = "all";
  3031. const isDone = (p) => (state.mode === "process" ? p.has_process : p.has_tools);
  3032. const platScoped =
  3033. state.platFilter === "all" ? all : all.filter((p) => (p.platform || "other") === state.platFilter);
  3034. const doneN = platScoped.filter(isDone).length;
  3035. const tabs = $("#plat-tabs");
  3036. if (all.length) {
  3037. tabs.hidden = false;
  3038. const btns =
  3039. plats.length > 1
  3040. ? [
  3041. `<button class="${state.platFilter === "all" ? "on" : ""}" onclick="setPlatFilter('all')">全部<span class="c">${all.length}</span></button>`,
  3042. ].concat(
  3043. plats.map(
  3044. (k) =>
  3045. `<button class="${state.platFilter === k ? "on" : ""}" onclick="setPlatFilter('${esc(k)}')">${PLAT_NAME(k)}<span class="c">${counts[k]}</span></button>`,
  3046. ),
  3047. )
  3048. : [];
  3049. btns.push(`<button class="done-filter ${state.doneFilter ? "on" : ""}" onclick="toggleDoneFilter()"
  3050. title="${state.doneFilter ? "当前只看已解构,点击显示全部" : "点击只看已解构"}"><span class="dot">●</span>已解构<span class="c">${doneN}</span></button>`);
  3051. tabs.innerHTML = btns.join("");
  3052. } else {
  3053. tabs.hidden = true;
  3054. }
  3055. const list = visiblePosts();
  3056. $("#p-count").textContent = all.length
  3057. ? state.platFilter === "all" && !state.doneFilter
  3058. ? `${all.length} 帖`
  3059. : `${list.length} / ${all.length} 帖`
  3060. : "";
  3061. if (!all.length) {
  3062. $("#post-list").innerHTML =
  3063. `<div class="empty">该 query 暂无帖子<br>
  3064. <button class="btn seal" id="btn-search-query" style="margin-top:12px"
  3065. onclick="searchCurrentQuery(this)">🔍 搜索该 query(小红书·公众号 各20)</button>
  3066. </div>`;
  3067. return;
  3068. }
  3069. if (!list.length) {
  3070. $("#post-list").innerHTML =
  3071. `<div class="empty">${state.doneFilter ? "该筛选下暂无已解构帖子" : "该渠道暂无帖子"}</div>`;
  3072. return;
  3073. }
  3074. $("#post-list").innerHTML = list
  3075. .map((p) => {
  3076. const done = state.mode === "process" ? p.has_process : p.has_tools;
  3077. const kt = (p.knowledge_type || []).map((k) => `<span class="pill">${esc(k)}</span>`).join("");
  3078. const sb =
  3079. p.overall_score != null
  3080. ? `<span class="score-badge ${scoreCls(p.overall_score)} num"
  3081. onclick="event.stopPropagation();openPostDetail('${esc(p.case_id)}')">${p.overall_score}</span>`
  3082. : "";
  3083. const thumbSrc = (p.images || []).filter(Boolean)[0];
  3084. const thumb = thumbSrc
  3085. ? imgHtml(thumbSrc, { cls: "thumb", ph: "<div class='thumb-ph'>🖼️</div>" })
  3086. : `<div class="thumb-ph" title="暂无图片">🖼️</div>`;
  3087. return `<div class="post ${p.case_id === state.caseId ? "on" : ""}" onclick="selectPost('${esc(p.case_id)}')">
  3088. ${thumb}
  3089. <div style="flex:1;min-width:0">
  3090. <div class="pt">${esc(p.title || "(无标题)")}</div>
  3091. <div class="pm">
  3092. ${PLAT_LOGO(p.platform)}
  3093. ${p.adopted ? '<span class="pill green">采纳</span>' : ""}
  3094. ${kt}
  3095. ${done ? '<span class="done-dot">● 已解构</span>' : ""}
  3096. </div>
  3097. </div>
  3098. ${sb}
  3099. </div>`;
  3100. })
  3101. .join("");
  3102. }
  3103. function toggleSel(cid, on) {
  3104. on ? state.selected.add(cid) : state.selected.delete(cid);
  3105. updateBatchBtn();
  3106. }
  3107. function updateBatchBtn() {
  3108. const b = $("#btn-batch");
  3109. b.disabled = !state.selected.size;
  3110. b.textContent = state.selected.size ? `批量解构(${state.selected.size})` : "批量解构";
  3111. // 解构全部(未解构/已采纳总数):未解构=已采纳但本方向未解构;A 灰 B 绿
  3112. const adopted = (state.posts || []).filter((p) => p.adopted);
  3113. const adoptedN = adopted.length;
  3114. const doneKey = state.mode === "process" ? "has_process" : "has_tools";
  3115. const undoneN = adopted.filter((p) => !p[doneKey]).length;
  3116. const ea = $("#btn-extract-adopted");
  3117. ea.hidden = !adoptedN;
  3118. ea.innerHTML = `解构全部(<span class="cnt-rest">${undoneN}</span>/<span class="cnt-total">${adoptedN}</span>)`;
  3119. // 归类全部(未归类/已采纳总数):仅工序方向 + 有已采纳已解构帖才显示;未归类=已采纳未归类
  3120. const hasCatTarget = adopted.some((p) => p.has_process);
  3121. const unCatN = adopted.filter((p) => !p.has_category).length;
  3122. const ca = $("#btn-cat-adopted");
  3123. ca.hidden = state.mode !== "process" || !hasCatTarget;
  3124. ca.innerHTML = `归类全部(<span class="cnt-rest">${unCatN}</span>/<span class="cnt-total">${adoptedN}</span>)`;
  3125. }
  3126. $("#btn-batch").onclick = () => state.selected.size && startExtract([...state.selected]);
  3127. $("#btn-extract-adopted").onclick = async () => {
  3128. const adopted = (state.posts || []).filter((p) => p.adopted);
  3129. const cids = adopted.map((p) => p.case_id);
  3130. if (!cids.length) return toast("当前 query 下没有已采纳的帖子", "warn");
  3131. const dir = state.mode === "process" ? "工序" : "工具";
  3132. const doneKey = state.mode === "process" ? "has_process" : "has_tools";
  3133. const undoneN = adopted.filter((p) => !p[doneKey]).length;
  3134. const allDone = undoneN === 0; // 已采纳帖全部已解构
  3135. const msg = allDone
  3136. ? `这 ${cids.length} 个已采纳帖都已${dir}解构。是否重新解构?\n重新解构会消耗 LLM、生成新版本并覆盖当前展示。`
  3137. : `对该 query 下全部 ${cids.length} 个已采纳帖做${dir}解构(其中 ${undoneN} 个未解构)。\n已解构过的会自动跳过/复用,不重复花钱。`;
  3138. if (!(await uiConfirm(msg))) return;
  3139. // 全部已解构时,确认重做须 force(否则按 case 去重会全部跳过、白点一次)
  3140. startExtract(cids, allDone ? { force: true } : {});
  3141. };
  3142. $("#btn-cat-adopted").onclick = async () => {
  3143. // 只归类「已采纳且已解构」的帖(只有已解构才有 steps 可归类);has_category 来自 fetch_posts
  3144. const adoptedProc = (state.posts || []).filter((p) => p.adopted && p.has_process);
  3145. const cids = adoptedProc.map((p) => p.case_id);
  3146. if (!cids.length) return toast("当前 query 下没有「已采纳且已解构」的帖子", "warn");
  3147. const rest = adoptedProc.filter((p) => !p.has_category).map((p) => p.case_id); // 未归类
  3148. const catN = cids.length - rest.length;
  3149. let action; // "all"=归类全部(覆盖) / "rest"=只归类剩余 / null=取消
  3150. if (rest.length === 0) {
  3151. // 全部已归类:只能重新归类全部
  3152. action = (await uiConfirm(`这 ${cids.length} 个帖的工序都已归类。是否重新归类?\n重新归类会用最新分类结果覆盖原有实质/形式 tag。`)) ? "all" : null;
  3153. } else if (catN === 0) {
  3154. // 都没归类:归类全部 = 归类剩余,两按钮即可
  3155. action = (await uiConfirm(`对该 query 下 ${cids.length} 个已采纳且已解构的帖做工序归类?\n将把命中的分类回写进各工序的实质/形式。`)) ? "all" : null;
  3156. } else {
  3157. // 部分已归类:归类剩余(只处理未归类) / 归类全部(覆盖) / 取消
  3158. action = await uiChoose(
  3159. `该 query 下 ${cids.length} 个已采纳且已解构的帖,其中 ${catN} 个已归类、${rest.length} 个未归类。\n「归类剩余」只处理未归类的 ${rest.length} 个;「归类全部」会重跑并覆盖已归类的。`,
  3160. [
  3161. { key: "rest", text: `归类剩余(${rest.length})` },
  3162. { key: "all", text: "归类全部(覆盖)", primary: true },
  3163. ]);
  3164. }
  3165. if (!action) return;
  3166. startCategorize(action === "rest" ? rest : cids); // 归类即覆盖写,无需 force
  3167. };
  3168. /* ════ 帖子详情弹层 ════ */
  3169. /* 得分可能是字符串("1")或数字(10),统一解析;非数值返回 null */
  3170. const scoreNum = (v) => {
  3171. const n = typeof v === "number" || (typeof v === "string" && v.trim() !== "") ? Number(v) : NaN;
  3172. return Number.isFinite(n) ? n : null;
  3173. };
  3174. function collectScores(node) {
  3175. let out = [];
  3176. if (Array.isArray(node)) node.forEach((v) => (out = out.concat(collectScores(v))));
  3177. else if (node && typeof node === "object") {
  3178. for (const [k, v] of Object.entries(node)) {
  3179. if (k === "得分") {
  3180. const n = scoreNum(v);
  3181. if (n !== null) out.push(n);
  3182. } else out = out.concat(collectScores(v));
  3183. }
  3184. }
  3185. return out;
  3186. }
  3187. function scRow(label, v, reason) {
  3188. const n = scoreNum(v);
  3189. const has = n !== null;
  3190. return `<div class="sc-row">
  3191. <span style="color:${has ? "inherit" : "var(--ink-faint)"}">${esc(label)}</span>
  3192. <div class="meter"><span style="width:${has ? Math.min(n, 10) * 10 : 0}%"></span></div>
  3193. <b class="num">${has ? n : "—"}</b>
  3194. ${reason ? `<span class="info" data-label="${esc(label)}" data-reason="${esc(reason)}" data-score="${has ? n : ""}" onclick="showScorePop(this)">ⓘ</span>` : "<span></span>"}
  3195. </div>`;
  3196. }
  3197. /* 递归渲染评分;depth>0 的分组标题用二级样式,形成层级 */
  3198. function walkScores(node, depth) {
  3199. depth = depth || 0;
  3200. let html = "";
  3201. for (const [k, v] of Object.entries(node || {})) {
  3202. if (v && typeof v === "object" && !Array.isArray(v) && "得分" in v) {
  3203. html += scRow(k, v["得分"], v["理由"]);
  3204. } else if (scoreNum(v) !== null) {
  3205. html += scRow(k, v);
  3206. } else if (v && typeof v === "object" && !Array.isArray(v)) {
  3207. const inner = walkScores(v, depth + 1);
  3208. if (inner) html += `<div class="sc-sub${depth > 0 ? " lv2" : ""}">${esc(k)}</div>` + inner;
  3209. }
  3210. }
  3211. return html;
  3212. }
  3213. /* ── 质量评分:不跟随原始 JSON 嵌套,改用 mode_procedure 的规范分组与顺序 ──
  3214. 固定维度 → 用例 → 工序 → 能力 → 工具;丢弃「字段完整性」「动态维度」等中间表头 */
  3215. const QUALITY_ORDER = {
  3216. 工序: ["流程完整性", "输入完整性", "实现完整性", "输出完整性", "泛化性"],
  3217. 能力: ["输入完整性", "实现完整性", "输出完整性", "泛化性"],
  3218. 工具: ["能力边界覆盖", "有效比较", "参数/接口具体性", "实操示例", "版本&限制"],
  3219. };
  3220. /* DFS 找到名为 name 的容器节点(工序/能力/工具) */
  3221. function findScoreNode(n, name) {
  3222. if (!n || typeof n !== "object" || Array.isArray(n)) return null;
  3223. if (name in n && n[name] && typeof n[name] === "object" && !Array.isArray(n[name])) return n[name];
  3224. for (const v of Object.values(n)) {
  3225. if (v && typeof v === "object" && !Array.isArray(v)) {
  3226. const r = findScoreNode(v, name);
  3227. if (r) return r;
  3228. }
  3229. }
  3230. return null;
  3231. }
  3232. /* 递归收集子树叶子评分 [name,{得分,理由}],打平中间分组头 */
  3233. function collectLeaves(node) {
  3234. let out = [];
  3235. for (const [k, v] of Object.entries(node || {})) {
  3236. if (v && typeof v === "object" && !Array.isArray(v) && "得分" in v) out.push([k, v]);
  3237. else if (scoreNum(v) !== null) out.push([k, { 得分: v }]);
  3238. else if (v && typeof v === "object" && !Array.isArray(v)) out = out.concat(collectLeaves(v));
  3239. }
  3240. return out;
  3241. }
  3242. function renderQuality(qnode) {
  3243. /* 固定维度/用例 的维度名全局唯一,扁平索引即可取 */
  3244. const flat = {};
  3245. (function collect(n) {
  3246. for (const [k, v] of Object.entries(n || {})) {
  3247. if (v && typeof v === "object" && !Array.isArray(v)) {
  3248. if ("得分" in v) flat[k] = v;
  3249. else collect(v);
  3250. } else if (scoreNum(v) !== null) flat[k] = { 得分: v };
  3251. }
  3252. })(qnode);
  3253. const sub = (t) => `<div class="sc-sub">${esc(t)}</div>`;
  3254. const rows = (pairs) => pairs.map(([n, o]) => scRow(n, o["得分"], o["理由"])).join("");
  3255. const pick = (names) => names.filter((n) => flat[n]).map((n) => [n, flat[n]]);
  3256. let html = "";
  3257. let p = pick(["时效性", "热度性", "评论反馈", "可复现性", "意图可控性"]); // ① 固定维度(置顶)
  3258. if (p.length) html += sub("固定维度") + rows(p);
  3259. p = pick(["真实感", "真实感 (非AI)", "真实感(非AI)", "表现力"]); // ② 用例
  3260. if (p.length) html += sub("用例") + rows(p);
  3261. for (const name of ["工序", "能力", "工具"]) {
  3262. // ③ 动态维度(按方向命名,内部规范排序)
  3263. const node = findScoreNode(qnode, name);
  3264. if (!node) continue;
  3265. const leaves = collectLeaves(node);
  3266. if (!leaves.length) continue;
  3267. const order = QUALITY_ORDER[name] || [];
  3268. leaves.sort((a, b) => (order.indexOf(a[0]) + 1 || 99) - (order.indexOf(b[0]) + 1 || 99));
  3269. html += sub(name) + rows(leaves);
  3270. }
  3271. return html || '<span style="color:var(--ink-faint)">无评分</span>';
  3272. }
  3273. /* ── 判定理由弹层:点击 ⓘ 浮现,符合当前页面样式 ── */
  3274. let _scorePop = null;
  3275. function closeScorePop() {
  3276. if (_scorePop) {
  3277. _scorePop.remove();
  3278. _scorePop = null;
  3279. }
  3280. document.removeEventListener("mousedown", _scorePopOutside, true);
  3281. }
  3282. function _scorePopOutside(e) {
  3283. if (_scorePop && !_scorePop.contains(e.target) && !e.target.classList.contains("info")) closeScorePop();
  3284. }
  3285. function showScorePop(el) {
  3286. const reopen = _scorePop && _scorePop._anchor === el;
  3287. closeScorePop();
  3288. if (reopen) return; // 再次点击同一图标 → 收起
  3289. const score = el.dataset.score;
  3290. const pop = document.createElement("div");
  3291. pop.className = "score-pop";
  3292. pop._anchor = el;
  3293. pop.innerHTML = `<div class="sp-head">
  3294. <span class="sp-tag">判定理由</span>
  3295. <span class="sp-name">${esc(el.dataset.label || "")}</span>
  3296. ${score !== "" && score != null ? `<span class="sp-score">${esc(score)}</span>` : ""}
  3297. </div>
  3298. <div class="sp-body">${esc(el.dataset.reason || "")}</div>`;
  3299. // 挂在 dialog 内,确保位于 showModal 顶层之上
  3300. (document.getElementById("post-dialog") || document.body).appendChild(pop);
  3301. _scorePop = pop;
  3302. // 定位:图标下方右对齐;越界则上翻 / 收边
  3303. const r = el.getBoundingClientRect();
  3304. let top = r.bottom + 8,
  3305. left = r.right - pop.offsetWidth;
  3306. if (left < 12) left = 12;
  3307. if (top + pop.offsetHeight > window.innerHeight - 12) top = r.top - pop.offsetHeight - 8;
  3308. if (top < 12) top = 12;
  3309. pop.style.top = top + "px";
  3310. pop.style.left = left + "px";
  3311. setTimeout(() => document.addEventListener("mousedown", _scorePopOutside, true), 0);
  3312. }
  3313. document.getElementById("post-dialog")?.addEventListener("close", closeScorePop);
  3314. /* ── 图片预览灯箱 ── */
  3315. const lb = { imgs: [], i: 0 };
  3316. function openLightbox(i) {
  3317. if (!lb.imgs.length) return;
  3318. lb.i = (i + lb.imgs.length) % lb.imgs.length;
  3319. renderLightbox();
  3320. const d = $("#lightbox");
  3321. if (!d.open) d.showModal();
  3322. }
  3323. function closeLightbox() {
  3324. const d = $("#lightbox");
  3325. if (d.open) d.close();
  3326. }
  3327. function lbStep(d) {
  3328. if (!lb.imgs.length) return;
  3329. lb.i = (lb.i + d + lb.imgs.length) % lb.imgs.length;
  3330. renderLightbox();
  3331. }
  3332. function renderLightbox() {
  3333. const url = lb.imgs[lb.i];
  3334. const el = $("#lb-img");
  3335. delete el.dataset.fb; // 切换图片前清除上一张的回退标记
  3336. el.onerror = () => imgFallback(el, imgProxy(url));
  3337. el.src = imgDirect(url); // 大图同样优先直连,失败回退代理
  3338. $("#lb-count").textContent = `${lb.i + 1} / ${lb.imgs.length}`;
  3339. const multi = lb.imgs.length > 1;
  3340. document.querySelector(".lb-prev").style.visibility = multi ? "visible" : "hidden";
  3341. document.querySelector(".lb-next").style.visibility = multi ? "visible" : "hidden";
  3342. }
  3343. document.addEventListener("keydown", (e) => {
  3344. if (!$("#lightbox").open) return;
  3345. if (e.key === "ArrowLeft") lbStep(-1);
  3346. else if (e.key === "ArrowRight") lbStep(1);
  3347. // Esc 由 <dialog> 原生处理(触发 close)
  3348. });
  3349. async function openPostDetail(cid) {
  3350. const p = state.posts.find((x) => x.case_id === cid);
  3351. if (!p) return;
  3352. await ensurePostDetail(p); // 列表瘦身,弹框前补全正文/评估
  3353. const e = p.llm_evaluation || {};
  3354. const meta = [];
  3355. meta.push(`${PLAT_LOGO(p.platform)}<span style="font-weight:600">${esc(PLAT_NAME(p.platform))}</span>`);
  3356. meta.push(p.adopted ? '<span class="pill green">采纳/命中</span>' : '<span class="pill">未采纳</span>');
  3357. if (p.publish_time) meta.push(`<span>${esc(String(p.publish_time).slice(0, 16))}</span>`);
  3358. if (p.like_count != null) meta.push(`<span>👍 ${p.like_count}</span>`);
  3359. if (p.quality_grade) meta.push(`<span>质量 ${esc(p.quality_grade)} ${p.quality_score ?? ""}</span>`);
  3360. if (p.url) meta.push(`<a href="${esc(p.url)}" target="_blank">原文 ↗</a>`);
  3361. meta.push(`<span class="pill" title="case_id" style="font-family:'IBM Plex Mono',ui-monospace,monospace">${esc(p.case_id || cid)}</span>`);
  3362. $("#pd-meta").innerHTML = meta.join("");
  3363. $("#pd-title").textContent = p.title || "(无标题)";
  3364. const verdict = e["判定理由"] || e["理由"] || "";
  3365. $("#pd-verdict").innerHTML = verdict ? `<div class="pd-verdict">${esc(verdict)}</div>` : "";
  3366. $("#pd-text").textContent = p.body || "(无正文)";
  3367. const imgs = (p.images || []).filter(Boolean);
  3368. $("#pd-images").innerHTML = imgs.length
  3369. ? imgs
  3370. .map(
  3371. (s, i) => imgHtml(s, { extra: `onclick="openLightbox(${i})"` }),
  3372. )
  3373. .join("")
  3374. : '<p style="color:var(--ink-faint);font-size:12px">搜索详情未返回图片。</p>';
  3375. lb.imgs = imgs;
  3376. // 视频预览:仅当 videos 有值时显示模块
  3377. const vids = (p.videos || []).filter(Boolean);
  3378. const showVids = vids.length > 0;
  3379. $("#pd-videos-title").style.display = showVids ? "" : "none";
  3380. const pdVideos = $("#pd-videos");
  3381. pdVideos.style.display = showVids ? "" : "none";
  3382. pdVideos.innerHTML = showVids
  3383. ? vids
  3384. .map((s) => {
  3385. // YouTube 的 videos[0] 是 watch 页 URL,<video> 播不了 → 用 iframe embed
  3386. const isYt = p.platform === "youtube" || /youtube\.com|youtu\.be/.test(s);
  3387. if (isYt) {
  3388. const id = p.video_id || ytId(s);
  3389. return id
  3390. ? `<iframe src="https://www.youtube.com/embed/${esc(id)}" loading="lazy" allow="accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>`
  3391. : `<a class="vid-fallback" href="${esc(s)}" target="_blank" rel="noopener">在 YouTube 打开视频 ↗</a>`;
  3392. }
  3393. // 其他平台(抖音等)走同源视频代理:补 Referer + Range 流式,失败兜底源站链接
  3394. return `<video src="${esc(vidProxy(s))}" data-src="${esc(s)}" controls preload="metadata" playsinline onerror="vidFallback(this)"></video>`;
  3395. })
  3396. .join("")
  3397. : "";
  3398. $("#pd-tags").innerHTML = [
  3399. ...(p.knowledge_type || []).map((t) => "类型:" + t),
  3400. ...(p.found_by || []).map((q) => "命中:" + q),
  3401. ]
  3402. .map((t) => `<span class="pill">${esc(t)}</span>`)
  3403. .join("");
  3404. $("#pd-overall").innerHTML =
  3405. p.overall_score != null
  3406. ? `${p.overall_score}<span style="font-size:11px;color:var(--ink-faint);font-weight:500"> /10</span>`
  3407. : "—";
  3408. /* 评分卡:相关性 + 质量(均分 + 各维度,ⓘ hover 看理由) */
  3409. $("#pd-scores").innerHTML =
  3410. [
  3411. ["01", "相关性"],
  3412. ["02", "质量"],
  3413. ]
  3414. .map(([no, key], i) => {
  3415. const node = e[key];
  3416. if (!node) return "";
  3417. const vs = collectScores(node);
  3418. const avg = vs.length ? (vs.reduce((a, b) => a + b, 0) / vs.length).toFixed(1) : "N/A";
  3419. return `<div class="sc-card">
  3420. <div class="sc-card-head">
  3421. <span><span class="badge">${no}</span>${esc(key)}</span>
  3422. <span class="avg">均分 <b>${avg}</b>/10</span>
  3423. </div>
  3424. <div class="sc-card-body">${(key === "质量" ? renderQuality(node) : walkScores(node)) || '<span style="color:var(--ink-faint)">无评分</span>'}</div>
  3425. </div>`;
  3426. })
  3427. .join("") || '<div class="empty">无评估数据</div>';
  3428. $("#post-dialog").showModal();
  3429. }
  3430. /* ════ Dataset:右栏解构结果 ════ */
  3431. function renderExtractEmpty() {
  3432. $("#xp-head").innerHTML = '<span class="st">解构结果</span>';
  3433. $("#xp-body").innerHTML = '<div class="empty"><span class="glyph">←</span>选择一个帖子查看解构结果</div>';
  3434. }
  3435. async function selectPost(cid) {
  3436. state.caseId = cid;
  3437. state.version = null;
  3438. state.post = state.posts.find((p) => p.case_id === cid) || null;
  3439. renderPosts();
  3440. await ensurePostDetail(state.post); // 列表瘦身,补全正文/评估再渲染右侧详情
  3441. await loadExtract();
  3442. }
  3443. // 列表是瘦身数据(无 body/llm_evaluation/videos);详情按需取单帖并合并到对象上(合并后再点 0 往返)
  3444. async function ensurePostDetail(p) {
  3445. if (!p || p.body !== undefined) return p;
  3446. try {
  3447. const full = await api(`/api/post?mode=${state.mode}&query_id=`
  3448. + encodeURIComponent(state.queryId) + "&case_id=" + encodeURIComponent(p.case_id));
  3449. if (full) Object.assign(p, full);
  3450. } catch (e) { /* 详情取不到不阻断,正文/评分留空 */ }
  3451. return p;
  3452. }
  3453. /* ── 解构结果:客户端缓存 + 请求竞态守卫(解决「多次点击卡顿 / 残留上一帖」)──
  3454. · _extractCache:解构数据只在「重新解构」时变(由本页 startExtract 触发,届时清缓存),
  3455. 故缓存可长留——再次点开看过的帖 0 往返、瞬时渲染。
  3456. · _extractSeq:每次发起 +1;晚到的旧响应据 seq 丢弃,杜绝快速连点时旧响应覆盖新选中。 */
  3457. const _extractCache = new Map(); // key: mode|case_id|version → {versions,data,missing}
  3458. const _extractKey = (cid, ver) => `${state.mode}|${cid}|${ver || ""}`;
  3459. let _extractSeq = 0;
  3460. function invalidateExtractCache(cid) {
  3461. for (const k of [..._extractCache.keys()]) if (k.includes(`|${cid}|`)) _extractCache.delete(k);
  3462. }
  3463. async function loadExtract() {
  3464. if (!state.caseId) return renderExtractEmpty();
  3465. const isProc = state.mode === "process";
  3466. const seq = ++_extractSeq; // 本次请求序号
  3467. const key = _extractKey(state.caseId, state.version);
  3468. // 1) 命中缓存:瞬时渲染,0 往返
  3469. const cached = _extractCache.get(key);
  3470. if (cached) return paintExtract(cached, seq);
  3471. // 2) 未命中:立即显示「原文 + loading」。关键:重写 #xp-body 会移除上一帖的 <img>,
  3472. // 浏览器随即取消其 /api/img 下载,腾出每域 ~6 条连接额度,新的 /api/extract 不再
  3473. // 排在旧图片请求后面等待——这是「多次点击要等很久」的根因。同时给出加载态,
  3474. // 不再停留在上一帖的解构结果。
  3475. renderExtractHead([], null, false, true);
  3476. $("#xp-body").innerHTML =
  3477. renderSourceBlock() +
  3478. `<div class="empty"><span class="spinner"></span>正在加载${isProc ? "工序" : "工具"}解构…</div>`;
  3479. // 版本列表 + 解构详情合一,一个请求拿全(服务端同连接两查,ETag 命中可走 304)
  3480. const url =
  3481. `/api/extract?mode=${state.mode}&case_id=` +
  3482. encodeURIComponent(state.caseId) +
  3483. (state.version ? "&version=" + encodeURIComponent(state.version) : "");
  3484. let res;
  3485. try {
  3486. res = await api(url);
  3487. } catch (e) {
  3488. if (seq !== _extractSeq) return; // 已切到别的帖,丢弃本响应
  3489. $("#xp-body").innerHTML = renderSourceBlock() + '<div class="empty">解构数据加载失败,请重试</div>';
  3490. return;
  3491. }
  3492. if (seq !== _extractSeq) return; // 晚到的旧响应:不覆盖新选中
  3493. const payload = { versions: res.versions || [], data: res.data, missing: res.missing || !res.data };
  3494. _extractCache.set(key, payload);
  3495. paintExtract(payload, seq);
  3496. }
  3497. function paintExtract({ versions, data, missing }, seq) {
  3498. if (seq !== _extractSeq) return; // 渲染前再校验(缓存命中路径也经此)
  3499. const isProc = state.mode === "process";
  3500. renderExtractHead(versions, data, missing);
  3501. const body = $("#xp-body");
  3502. if (missing || !data) {
  3503. body.innerHTML =
  3504. renderSourceBlock() +
  3505. `<div class="empty">该帖暂无${isProc ? "工序" : "工具"}解构<br><br>
  3506. <button class="btn primary" onclick="startExtract(['${esc(state.caseId)}'])">开始解构</button></div>`;
  3507. return;
  3508. }
  3509. state.version = data.version;
  3510. // 以「具体 version」补一条缓存别名,版本下拉切回时也能命中
  3511. _extractCache.set(_extractKey(state.caseId, data.version), { versions, data, missing });
  3512. syncVersionSelect();
  3513. body.innerHTML = isProc ? renderProcedures(data) : renderTools(data);
  3514. requestAnimationFrame(markSrcTextClamp);
  3515. if (isProc) requestAnimationFrame(markStepClamps);
  3516. else requestAnimationFrame(markClampedCells);
  3517. }
  3518. function renderExtractHead(versions, data, missing, loading) {
  3519. const isProc = state.mode === "process";
  3520. const title = state.post ? esc(state.post.title || state.caseId) : esc(state.caseId || "");
  3521. const opts = versions
  3522. .map(
  3523. (v, i) =>
  3524. `<option value="${esc(v.version)}">${esc(v.version)}${i === 0 ? " (最新)" : ""} · ${v.n}${isProc ? "工序" : "工具"}</option>`,
  3525. )
  3526. .join("");
  3527. const stat = loading ? "加载中…" : missing ? "未提取" : "已提取";
  3528. $("#xp-head").innerHTML = `
  3529. <span class="st">大模型${isProc ? "工序" : "工具"}:<em>${stat}</em></span>
  3530. <span style="font-size:12px;color:var(--ink-faint);max-width:330px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap" title="${title}">${title}</span>
  3531. <span class="spacer"></span>
  3532. ${versions.length ? `<select id="ver-sel">${opts}</select>` : ""}
  3533. <button class="btn sm primary" onclick="openReextractDialog()">${missing ? "提取" : "♻ 重新生成"}</button>
  3534. ${isProc && !missing ? `<button class="btn sm" onclick="categorizeCurrent()" title="对本帖工序做分类归纳,把命中分类回写到实质/形式">🏷 归纳</button>` : ""}
  3535. <button class="btn sm" onclick="showTaskPanel()" title="重新打开任务日志面板">📋 操作日志</button>`;
  3536. const vs = $("#ver-sel");
  3537. if (vs)
  3538. vs.onchange = () => {
  3539. state.version = vs.value;
  3540. loadExtract();
  3541. };
  3542. }
  3543. function syncVersionSelect() {
  3544. const vs = $("#ver-sel");
  3545. if (vs && state.version) vs.value = state.version;
  3546. }
  3547. /* ── 原文卡片:标题 + 图片缩略图(横滑、可灯箱预览)+ 正文(定高可展开),整体可收起 ── */
  3548. let srcOpen = true,
  3549. srcTextOpen = false;
  3550. function renderSourceBlock() {
  3551. const p = state.post;
  3552. if (!p || !(p.title || (p.images || []).length || p.body)) return "";
  3553. const imgs = (p.images || []).filter(Boolean);
  3554. const thumbs = imgs.length
  3555. ? `<div class="src-thumbs">${imgs
  3556. .map(
  3557. (s, i) =>
  3558. imgHtml(s, { extra: `onclick="openSrcLightbox(${i})"` }),
  3559. )
  3560. .join("")}</div>`
  3561. : "";
  3562. const body = p.body
  3563. ? `<div class="src-text${srcTextOpen ? "" : " clamp"}" id="src-text">${esc(p.body)}</div>
  3564. <button class="src-text-toggle" id="src-text-toggle" onclick="toggleSrcText()" hidden>${srcTextOpen ? "收起 ▲" : "展开 ▼"}</button>`
  3565. : "";
  3566. const link = p.url
  3567. ? `<a class="src-link" href="${esc(p.url)}" target="_blank" rel="noreferrer" onclick="event.stopPropagation()">原文 ↗</a>`
  3568. : "";
  3569. return `<div class="src-block${srcOpen ? " open" : ""}" id="src-block">
  3570. <div class="src-head" onclick="toggleSrc()">
  3571. <span class="src-caret">▸</span>
  3572. <span class="src-label">原文</span>
  3573. <span class="src-title">${esc(p.title || "(无标题)")}</span>
  3574. ${link}
  3575. <span class="src-case" title="case_id" onclick="event.stopPropagation()">${esc(p.case_id || "")}</span>
  3576. </div>
  3577. <div class="src-body">${thumbs}${body}</div>
  3578. </div>`;
  3579. }
  3580. function toggleSrc() {
  3581. srcOpen = !srcOpen;
  3582. const b = $("#src-block");
  3583. if (b) b.classList.toggle("open", srcOpen);
  3584. requestAnimationFrame(markSrcTextClamp);
  3585. }
  3586. function toggleSrcText() {
  3587. srcTextOpen = !srcTextOpen;
  3588. const t = $("#src-text"),
  3589. btn = $("#src-text-toggle");
  3590. if (t) t.classList.toggle("clamp", !srcTextOpen);
  3591. if (btn) btn.textContent = srcTextOpen ? "收起 ▲" : "展开 ▼";
  3592. }
  3593. function openSrcLightbox(i) {
  3594. lb.imgs = ((state.post && state.post.images) || []).filter(Boolean);
  3595. openLightbox(i);
  3596. }
  3597. /* 仅当正文在定高下溢出时才显示「展开」按钮(需在可见、未展开态测量) */
  3598. function markSrcTextClamp() {
  3599. const t = $("#src-text"),
  3600. btn = $("#src-text-toggle");
  3601. if (!t || !btn) return;
  3602. if (srcTextOpen) {
  3603. btn.hidden = false;
  3604. return;
  3605. }
  3606. btn.hidden = !(t.scrollHeight > t.clientHeight + 2);
  3607. }
  3608. /* ── 工序渲染 ── */
  3609. function renderProcedures(data) {
  3610. const src = data.source || {};
  3611. return (
  3612. renderSourceBlock() +
  3613. (data.procedures || [])
  3614. .map((p) => {
  3615. const d = p.declarations || {};
  3616. const ins =
  3617. (d.inputs || [])
  3618. .map(
  3619. (x) =>
  3620. `<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>` : ""}`,
  3621. )
  3622. .join("<br>") || '<span style="color:var(--ink-faint)">无</span>';
  3623. const ret = d.returns
  3624. ? `<span class="pill teal">${esc(d.returns.type || "")}</span>`
  3625. : '<span style="color:var(--ink-faint)">无</span>';
  3626. return `<div class="proc">
  3627. <div class="proc-head">
  3628. <div class="nm"><span class="pid">工序 ${esc(p.id || "")}</span>${esc(p.name || "")}</div>
  3629. ${p.purpose ? `<div class="pp">#目的:${esc(p.purpose)}</div>` : ""}
  3630. <div class="meta">
  3631. ${p.category ? `<span class="pill red">类别:${esc(p.category)}</span>` : ""}
  3632. ${src.platform ? `<span class="pill">#平台:${esc(src.platform)}</span>` : ""}
  3633. ${src.author ? `<span class="pill">#作者:${esc(src.author)}</span>` : ""}
  3634. <span class="pill">case:${esc(data.case_id)}</span>
  3635. ${(p.tools_used || []).map((t) => `<span class="pill teal">${esc(t)}</span>`).join("")}
  3636. </div>
  3637. </div>
  3638. <div class="decl">
  3639. <div><div class="dl">输入</div><div class="di">${ins}</div></div>
  3640. <div><div class="dl">返回</div><div class="di">${ret}</div></div>
  3641. </div>
  3642. ${renderSteps(p.steps || [])}
  3643. </div>`;
  3644. })
  3645. .join("") || '<div class="empty">本版本无工序</div>'
  3646. );
  3647. }
  3648. function renderSteps(steps) {
  3649. if (!steps.length) return '<div class="empty">无步骤</div>';
  3650. let rows = "";
  3651. for (const s of steps) {
  3652. const ins = s.inputs && s.inputs.length ? s.inputs : [null];
  3653. const outs = s.outputs && s.outputs.length ? s.outputs : [null];
  3654. const n = Math.max(ins.length, outs.length);
  3655. for (let i = 0; i < n; i++) {
  3656. rows += "<tr>";
  3657. if (i === 0) {
  3658. rows += `<td rowspan="${n}" class="sid">${esc(s.id || "")}</td>
  3659. <td rowspan="${n}"><div class="intent-text">${renderIntent(s.intent || s.directive || "")}</div></td>
  3660. <td rowspan="${n}">${s.effect ? `<span class="pill navy">${esc(s.effect)}</span>` : ""}</td>
  3661. <td rowspan="${n}">${renderSF(s.substance, s.substanceMatch)}</td>
  3662. <td rowspan="${n}">${renderSF(s.form, s.formMatch)}</td>`;
  3663. }
  3664. rows += ioCell(ins[i], "in");
  3665. if (i === 0) {
  3666. rows += `<td rowspan="${n}">${s.via ? `<span class="pill teal">${esc(s.via)}</span>` : ""}</td>
  3667. <td rowspan="${n}" class="vtxt">${esc(s.action || "")}</td>
  3668. <td rowspan="${n}" class="vtxt">${esc(s.directive || "")}</td>`;
  3669. }
  3670. rows += ioCell(outs[i], "out");
  3671. rows += "</tr>";
  3672. }
  3673. }
  3674. return `<div style="overflow-x:auto"><table class="steps">
  3675. <colgroup>
  3676. <col style="width:44px"><col style="width:200px"><col style="width:92px">
  3677. <col style="width:180px"><col style="width:168px">
  3678. <col style="width:112px"><col style="width:330px"><col style="width:92px">
  3679. <col style="width:118px"><col style="width:130px"><col style="width:130px">
  3680. <col style="width:112px"><col style="width:360px"><col style="width:110px">
  3681. </colgroup>
  3682. <thead>
  3683. <tr><th class="h-req" colspan="5">需 求</th><th class="h-in" colspan="3">输 入</th><th class="h-im" colspan="3">实 现</th><th class="h-out" colspan="3">输 出</th></tr>
  3684. <tr>
  3685. <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>
  3686. <th class="h-in2">类型</th><th class="h-in2">值</th><th class="h-in2">来源</th>
  3687. <th class="h-im2">外部工具</th><th class="h-im2">动作</th><th class="h-im2">指令</th>
  3688. <th class="h-out2">类型</th><th class="h-out2">值</th><th class="h-out2">去处</th>
  3689. </tr>
  3690. </thead><tbody>${rows}</tbody></table></div>`;
  3691. }
  3692. function fmtSF(v) {
  3693. return v == null ? "" : Array.isArray(v) ? v.join("、") : v;
  3694. }
  3695. const SF_ARROW =
  3696. '<svg class="sf-arrow" viewBox="0 0 24 24" width="13" height="13" aria-hidden="true"><path d="M5 12h14M13 6l6 6-6 6" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/></svg>';
  3697. const SF_NO_MATCH = "无"; // 后端未命中占位符(与 category_match.py NO_MATCH 一致)
  3698. /* 原值拆分:与后端 _split_values 完全一致 —— 括号内的「、」不拆、去重保序,
  3699. 保证原值子项与 *Match 子项「等长等序」可按下标配对 */
  3700. function _splitParts(raw) {
  3701. if (raw == null) return [];
  3702. if (Array.isArray(raw)) {
  3703. const out = [],
  3704. seen = new Set();
  3705. for (const x of raw) {
  3706. const p = String(x).trim();
  3707. if (p && !seen.has(p)) {
  3708. seen.add(p);
  3709. out.push(p);
  3710. }
  3711. }
  3712. return out;
  3713. }
  3714. const parts = [];
  3715. let cur = "",
  3716. depth = 0;
  3717. for (const ch of String(raw)) {
  3718. if (ch === "(" || ch === "(") {
  3719. depth++;
  3720. cur += ch;
  3721. } else if (ch === ")" || ch === ")") {
  3722. depth--;
  3723. cur += ch;
  3724. } else if (ch === "、" && depth === 0) {
  3725. const p = cur.trim();
  3726. if (p) parts.push(p);
  3727. cur = "";
  3728. } else {
  3729. cur += ch;
  3730. }
  3731. }
  3732. const last = cur.trim();
  3733. if (last) parts.push(last);
  3734. const out = [],
  3735. seen = new Set();
  3736. for (const p of parts)
  3737. if (!seen.has(p)) {
  3738. seen.add(p);
  3739. out.push(p);
  3740. }
  3741. return out;
  3742. }
  3743. /* *Match 拆分:按下标对齐,**不去重不滤空**,保留「无」占位 */
  3744. function _matchParts(v) {
  3745. return v == null ? [] : String(v).split("、").map((x) => x.trim());
  3746. }
  3747. /* 实质/形式单元格:逐子项「原值 → 命中值」配对。
  3748. 命中 → 原值灰色划除 + 箭头 + 绿色命中值;
  3749. 未命中(占位「无」/缺失)→ 只显原值,黑色正常(无划除无箭头) */
  3750. function renderSF(value, match) {
  3751. const olds = _splitParts(value);
  3752. const news = _matchParts(match);
  3753. if (!news.length) return esc(fmtSF(value)); // 整格未归类 → 原值黑色
  3754. const n = Math.max(olds.length, news.length);
  3755. let rows = "";
  3756. for (let i = 0; i < n; i++) {
  3757. const a = olds[i],
  3758. b = news[i];
  3759. const matched = b != null && b !== "" && b !== SF_NO_MATCH;
  3760. if (matched) {
  3761. rows += `<div class="sf-pair">${
  3762. a != null ? `<span class="sf-old">${esc(a)}</span>${SF_ARROW}` : ""
  3763. }<span class="sf-new">${esc(b)}</span></div>`;
  3764. } else if (a != null) {
  3765. rows += `<div class="sf-pair"><span class="sf-plain">${esc(a)}</span></div>`;
  3766. }
  3767. }
  3768. return `<div class="sf-map">${rows}</div>`;
  3769. }
  3770. function ioCell(x, kind) {
  3771. const cls = kind === "in" ? "c-in" : "c-out";
  3772. if (!x) return `<td class="${cls}"></td><td class="${cls}"></td><td class="${cls}"></td>`;
  3773. const inf = x.inferred ? ` inf" title="推断理由:${esc(x.inferred_reason || "模型推断补全")}` : "";
  3774. const badge = x.inferred ? '<span class="ib">推</span>' : "";
  3775. return `<td class="${cls}"><span class="pill ${kind === "in" ? "amber" : "blue"}">${esc(x.type || "")}</span></td>
  3776. <td class="${cls}${inf}">${badge}<div class="clamp-val" onclick="toggleClampVal(this)"><span class="vtxt">${esc(x.value || "")}</span></div></td>
  3777. <td class="${cls}"><span class="anchor">${esc(x.anchor || "")}</span></td>`;
  3778. }
  3779. /* 点击「值」单元格展开/收起(仅在内容溢出、已标记 clampable 时生效) */
  3780. function toggleClampVal(el) {
  3781. if (!el.classList.contains("clampable") && !el.classList.contains("open")) return;
  3782. el.classList.toggle("open");
  3783. }
  3784. /* 渲染后标记真正溢出 4 行的「值」单元格:先套限高再测量,溢出才保留 clampable */
  3785. function markStepClamps() {
  3786. document.querySelectorAll("#xp-body .steps .clamp-val").forEach((el) => {
  3787. if (el.classList.contains("open")) return;
  3788. el.classList.add("clampable");
  3789. if (el.scrollHeight <= el.clientHeight + 2) el.classList.remove("clampable");
  3790. });
  3791. }
  3792. /* ── 工具渲染(表格,移植自 fixed_query_eval renderToolTable)── */
  3793. const DASH = '<span class="dash">—</span>';
  3794. function _toolCell(v) {
  3795. if (v === null || v === undefined || v === "" || (Array.isArray(v) && !v.length)) return DASH;
  3796. if (Array.isArray(v)) return "<ul>" + v.map((x) => `<li>${esc(String(x))}</li>`).join("") + "</ul>";
  3797. return esc(String(v));
  3798. }
  3799. function _scopeCell(v) {
  3800. /* 作用域是 JSON 数组:按「、」拼接成短语,不出列表 */
  3801. if (v === null || v === undefined || (Array.isArray(v) && !v.length) || v === "") return DASH;
  3802. return esc(Array.isArray(v) ? v.join("、") : String(v));
  3803. }
  3804. function _ttCell(inner, clampable) {
  3805. return clampable ? `<div class="tcell" onclick="this.classList.toggle('open')">${inner}</div>` : inner;
  3806. }
  3807. function _toolCellContent(c, t) {
  3808. let inner,
  3809. cls = "",
  3810. clampable = true,
  3811. style = "";
  3812. if (c === "工具名称") {
  3813. cls = "col-tool";
  3814. clampable = false;
  3815. inner = `🔧 ${esc(t[c] || "(未命名)")}`;
  3816. } else if (c === "来源链接") {
  3817. clampable = false;
  3818. inner = t[c]
  3819. ? `<a href="${esc(t[c])}" target="_blank" style="color:#176d64;font-weight:600;">🔗 打开</a>`
  3820. : DASH;
  3821. } else if (c === "创作层级") {
  3822. clampable = false;
  3823. inner = t[c]
  3824. ? `<span class="layer-badge ${t[c] === "制作层" ? "make" : "create"}">${esc(t[c])}</span>`
  3825. : DASH;
  3826. } else if (c === "实质作用域" || c === "形式作用域") {
  3827. inner = _scopeCell(t[c]);
  3828. } else {
  3829. inner = _toolCell(t[c]);
  3830. }
  3831. if (["输入", "输出", "用法", "缺点"].includes(c)) style = "max-width:240px;";
  3832. else if (c === "工具名称") style = "width:150px;white-space:normal;";
  3833. else if (c === "创作层级") style = "width:96px;white-space:nowrap;";
  3834. else if (!clampable) style = "white-space:nowrap;";
  3835. return { inner, cls, clampable, style };
  3836. }
  3837. function _td(c, t, rowspan) {
  3838. const { inner, cls, clampable, style } = _toolCellContent(c, t);
  3839. const rs = rowspan > 1 ? ` rowspan="${rowspan}"` : "";
  3840. return `<td class="${cls}" style="${style}"${rs}>${_ttCell(inner, clampable)}</td>`;
  3841. }
  3842. function _caseTd(cse, key) {
  3843. const v = cse && cse[key] != null && cse[key] !== "" ? esc(String(cse[key])) : DASH;
  3844. return `<td class="col-case" style="max-width:210px;">${_ttCell(v, true)}</td>`;
  3845. }
  3846. function renderTools(data) {
  3847. const tools = data.tools || [];
  3848. if (!tools.length) return renderSourceBlock() + '<div class="empty">本版本无工具</div>';
  3849. /* 只展示 4 个核心列(其余字段仍在后台提取/存储,此处不渲染) */
  3850. const cols = ["工具名称", "创作层级", "实质作用域", "形式作用域"];
  3851. /* 只给前两列固定宽度;实质/形式作用域不设宽度,由它们平分剩余宽度(表格 width:100%)。
  3852. 不再补空白填充列——否则右侧会留出一大块空的表头/单元格。 */
  3853. const _thStyle = { 工具名称: "width:150px;", 创作层级: "width:96px;" };
  3854. const thead = `<thead><tr>${cols
  3855. .map((c) => `<th${_thStyle[c] ? ` style="${_thStyle[c]}"` : ""}>${c}</th>`)
  3856. .join("")}</tr></thead>`;
  3857. const rows = tools
  3858. .map((t, ti) => {
  3859. const par = ti % 2 ? "tr-b" : "tr-a";
  3860. return `<tr class="${par}">${cols.map((c) => _td(c, t)).join("")}</tr>`;
  3861. })
  3862. .join("");
  3863. return (
  3864. renderSourceBlock() +
  3865. `<div class="mw-ttwrap"><table class="mw-tt">${thead}<tbody>${rows}</tbody></table></div>`
  3866. );
  3867. }
  3868. /* 渲染后标记真正溢出的单元格(才显示蒙版+可点击) */
  3869. function markClampedCells() {
  3870. document.querySelectorAll("#xp-body .mw-tt .tcell").forEach((el) => {
  3871. if (!el.classList.contains("open") && el.scrollHeight > el.clientHeight + 2) el.classList.add("clamped");
  3872. else if (el.scrollHeight <= el.clientHeight + 2) el.classList.remove("clamped");
  3873. });
  3874. }
  3875. /* ════ 重新解构 · 编辑 Prompt 弹框 ════ */
  3876. async function openReextractDialog() {
  3877. if (!state.caseId) {
  3878. toast("请先选择帖子", "info");
  3879. return;
  3880. }
  3881. const isProc = state.mode === "process";
  3882. const dlg = $("#reextract-dlg"),
  3883. sel = $("#rx-model"),
  3884. ta = $("#rx-prompt"),
  3885. save = $("#rx-save");
  3886. sel.innerHTML = (isProc ? MODELS_PROC : MODELS_TOOL)
  3887. .map((m) => `<option>${m}</option>`)
  3888. .join("");
  3889. ta.value = "加载中…";
  3890. ta.disabled = save.disabled = true;
  3891. dlg.showModal();
  3892. try {
  3893. const r = await api(`/api/extract_prompt?mode=${state.mode}`);
  3894. ta.value = r.prompt || "";
  3895. } catch (e) {
  3896. ta.value = "";
  3897. toast("加载 Prompt 失败:" + (e.body?.error || e.status), "error");
  3898. } finally {
  3899. ta.disabled = save.disabled = false;
  3900. }
  3901. }
  3902. async function saveReextract() {
  3903. const cid = state.caseId;
  3904. if (!cid) return;
  3905. const model = $("#rx-model").value,
  3906. prompt = $("#rx-prompt").value;
  3907. $("#reextract-dlg").close();
  3908. // 临时 prompt 覆盖 + force 重解构(仅本次生效,不改默认 Prompt)
  3909. await startExtract([cid], { model, prompt, force: true });
  3910. }
  3911. /* ════ 解构任务 ════ */
  3912. async function startExtract(caseIds, opts = {}) {
  3913. if (!state.queryId || !caseIds.length) return;
  3914. const isProc = state.mode === "process";
  3915. const model = opts.model || (isProc ? MODELS_PROC[0] : MODELS_TOOL[0]);
  3916. try {
  3917. const body = { query_id: state.queryId, case_ids: caseIds, model };
  3918. if (opts.prompt != null) body.prompt = opts.prompt; // 临时 prompt 覆盖(仅本次)
  3919. if (opts.force) body.force = true; // 换 prompt/模型重解构需跳过去重
  3920. const r = await api(`/api/extract_${isProc ? "process" : "tools"}`, {
  3921. method: "POST",
  3922. body: JSON.stringify(body),
  3923. });
  3924. // 全部正在解构中(被认领跳过):没有 task_id,提示一下即可,别去轮询空任务
  3925. if (!r.task_id) {
  3926. toast(r.note || "所选帖子正在解构中,已跳过", "info");
  3927. return;
  3928. }
  3929. if ((r.skipped || []).length) toast(`${r.skipped.length} 帖正在解构中,已跳过`, "info");
  3930. showTask(`${isProc ? "工序" : "工具"}解构 · ${caseIds.length} 帖`, r.task_id, async () => {
  3931. state.selected.clear();
  3932. caseIds.forEach(invalidateExtractCache); // 重新解构后数据已变,清这些帖的缓存
  3933. await selectQuery(state.queryId);
  3934. if (caseIds.includes(state.caseId)) {
  3935. /* selectQuery 清了 caseId,恢复选中 */
  3936. }
  3937. if (caseIds.length === 1) {
  3938. state.caseId = caseIds[0];
  3939. state.version = null;
  3940. renderPosts();
  3941. await loadExtract();
  3942. }
  3943. // 需求3:工序解构完成 → 自动归类(工具方向无 substance/form,不归类)
  3944. if (isProc) startCategorize(caseIds, { auto: true });
  3945. });
  3946. } catch (e) {
  3947. toast("任务启动失败:" + (e.body?.error || e.status), "error");
  3948. }
  3949. }
  3950. /* ════ 工序归类(category-match)════
  3951. 起 /api/categorize 子进程任务,完成后清缓存并刷新当前帖解构,实质/形式单元格出 tag。
  3952. auto=true 为「工序解构完成后自动归类」,文案略不同。 */
  3953. async function startCategorize(caseIds, opts = {}) {
  3954. if (state.mode !== "process") return; // 仅工序方向有 substance/form 可归类
  3955. if (!state.queryId || !caseIds.length) return;
  3956. try {
  3957. const r = await api("/api/categorize", {
  3958. method: "POST",
  3959. body: JSON.stringify({ query_id: state.queryId, case_ids: caseIds }),
  3960. });
  3961. if (!r.task_id) return toast(r.note || "无可归类帖", "info");
  3962. showTask(`工序归类 · ${caseIds.length} 帖${opts.auto ? "(自动)" : ""}`, r.task_id, async () => {
  3963. caseIds.forEach(invalidateExtractCache); // 归类改了 steps,清缓存才能拿到新 match
  3964. // 乐观更新:归类成功的帖标记已归类,刷新「归类全部(未归类/已采纳)」计数
  3965. const done = new Set(caseIds);
  3966. (state.posts || []).forEach((p) => { if (done.has(p.case_id)) p.has_category = true; });
  3967. updateBatchBtn();
  3968. // 当前正看的帖在本批里 → 重载解构,实质/形式立即出 tag
  3969. if (caseIds.includes(state.caseId)) {
  3970. state.version = null;
  3971. await loadExtract();
  3972. }
  3973. toast(opts.auto ? "解构完成,已自动归类" : "归类完成", "success");
  3974. });
  3975. } catch (e) {
  3976. toast("归类启动失败:" + (e.body?.error || e.status), "error");
  3977. }
  3978. }
  3979. function categorizeCurrent() {
  3980. if (!state.caseId) return toast("请先选择帖子", "warn");
  3981. startCategorize([state.caseId]);
  3982. }
  3983. /* ════ 任务面板(✕ 只隐藏;「操作日志」按钮可随时唤回)════ */
  3984. let pollTimer = null,
  3985. hasTask = false;
  3986. // 自建确认弹框(替代浏览器原生 confirm):返回 Promise<bool>。Enter=确定 / Esc=取消 / 点遮罩=取消
  3987. function uiConfirm(message, opt = {}) {
  3988. const { okText = "确定", cancelText = "取消" } = opt;
  3989. return new Promise((resolve) => {
  3990. const bg = document.createElement("div");
  3991. bg.className = "ui-confirm-bg";
  3992. bg.innerHTML =
  3993. '<div class="ui-confirm"><div class="ui-confirm-msg"></div>'
  3994. + '<div class="ui-confirm-acts">'
  3995. + '<button class="btn" data-act="cancel"></button>'
  3996. + '<button class="btn seal" data-act="ok"></button></div></div>';
  3997. bg.querySelector(".ui-confirm-msg").textContent = message;
  3998. bg.querySelector('[data-act="cancel"]').textContent = cancelText;
  3999. bg.querySelector('[data-act="ok"]').textContent = okText;
  4000. document.body.appendChild(bg);
  4001. const done = (v) => { bg.remove(); document.removeEventListener("keydown", onKey, true); resolve(v); };
  4002. bg.addEventListener("click", (e) => {
  4003. if (e.target === bg) return done(false);
  4004. const a = e.target.closest("[data-act]");
  4005. if (a) done(a.dataset.act === "ok");
  4006. });
  4007. const onKey = (e) => {
  4008. if (e.key === "Escape") { e.preventDefault(); done(false); }
  4009. else if (e.key === "Enter") { e.preventDefault(); done(true); }
  4010. };
  4011. document.addEventListener("keydown", onKey, true);
  4012. bg.querySelector('[data-act="ok"]').focus();
  4013. });
  4014. }
  4015. /* 多按钮选择弹框(uiConfirm 的多选版):buttons=[{key,text,primary?}]。
  4016. 点业务按钮返回其 key;取消/Esc/点遮罩返回 null;Enter=primary(或第一个)按钮。 */
  4017. function uiChoose(message, buttons, opt = {}) {
  4018. const { cancelText = "取消" } = opt;
  4019. return new Promise((resolve) => {
  4020. const bg = document.createElement("div");
  4021. bg.className = "ui-confirm-bg";
  4022. const btns = buttons
  4023. .map((b) => `<button class="btn ${b.primary ? "seal" : ""}" data-key="${esc(b.key)}">${esc(b.text)}</button>`)
  4024. .join("");
  4025. bg.innerHTML =
  4026. '<div class="ui-confirm"><div class="ui-confirm-msg"></div>'
  4027. + '<div class="ui-confirm-acts">'
  4028. + `<button class="btn" data-key="">${esc(cancelText)}</button>`
  4029. + btns + "</div></div>";
  4030. bg.querySelector(".ui-confirm-msg").textContent = message;
  4031. document.body.appendChild(bg);
  4032. const done = (v) => { bg.remove(); document.removeEventListener("keydown", onKey, true); resolve(v); };
  4033. bg.addEventListener("click", (e) => {
  4034. if (e.target === bg) return done(null);
  4035. const a = e.target.closest("[data-key]");
  4036. if (a) done(a.dataset.key || null); // data-key="" → 取消 → null
  4037. });
  4038. const onKey = (e) => {
  4039. if (e.key === "Escape") { e.preventDefault(); done(null); }
  4040. else if (e.key === "Enter") {
  4041. e.preventDefault();
  4042. const p = buttons.find((b) => b.primary) || buttons[0];
  4043. done(p ? p.key : null);
  4044. }
  4045. };
  4046. document.addEventListener("keydown", onKey, true);
  4047. (bg.querySelector(".ui-confirm-acts .seal") || bg.querySelector(".ui-confirm-acts .btn:last-child")).focus();
  4048. });
  4049. }
  4050. function showTask(title, taskId, onDone, onSettled) {
  4051. hasTask = true;
  4052. $("#task-panel").hidden = false;
  4053. $("#task-title").textContent = title;
  4054. $("#task-dot").className = "dot";
  4055. $("#task-log").textContent = "启动中…";
  4056. clearTimeout(pollTimer);
  4057. const poll = async () => {
  4058. let t;
  4059. try {
  4060. t = await api("/api/task_status?task_id=" + encodeURIComponent(taskId));
  4061. } catch (e) {
  4062. $("#task-log").textContent = "状态查询失败";
  4063. if (onSettled) onSettled("error"); // 轮询出错也算结束,让调用方恢复按钮等
  4064. return;
  4065. }
  4066. const log = $("#task-log");
  4067. log.textContent = t.log_tail || "(暂无日志)";
  4068. log.scrollTop = log.scrollHeight;
  4069. if (t.status === "running") {
  4070. pollTimer = setTimeout(poll, 2000);
  4071. return;
  4072. }
  4073. $("#task-dot").className = "dot " + t.status;
  4074. $("#task-title").textContent = title + (t.status === "done" ? " · 完成" : " · 失败");
  4075. if (t.status === "done" && onDone) onDone();
  4076. if (onSettled) onSettled(t.status); // done / failed 都触发
  4077. };
  4078. poll();
  4079. }
  4080. /* ✕ 只隐藏面板,轮询照跑(任务完成后回调依然触发) */
  4081. function hideTask() {
  4082. $("#task-panel").hidden = true;
  4083. }
  4084. function showTaskPanel() {
  4085. if (!hasTask) return toast("本次会话还没有任务日志", "warn");
  4086. $("#task-panel").hidden = false;
  4087. const log = $("#task-log");
  4088. log.scrollTop = log.scrollHeight;
  4089. }
  4090. /* ════ Query 规则组织器 ════ */
  4091. // 扁平维度词表(移植自 query-builder.html DIMS);实质/形式 改为接口下钻,不在此。
  4092. const QR_FLAT = [
  4093. { id: "tool_type", label: "工具类型", items: ["AI", "桌面 APP", "云端 Web", "API·CLI", "插件扩展"] },
  4094. { id: "modality", label: "模态", items: ["图片", "视频"] },
  4095. { id: "suffix", label: "后缀", items: ["怎么做"] },
  4096. ];
  4097. const QR_TREE = [
  4098. { id: "substance", label: "实质", source: "实质" },
  4099. { id: "form", label: "形式", source: "形式" },
  4100. ];
  4101. const qrState = {
  4102. flat: { tool_type: null, modality: null, suffix: null },
  4103. treePath: { substance: [], form: [] }, // 实质/形式 选中 name 路径(仅作 Sonnet 上下文)
  4104. treeData: { substance: null, form: null },
  4105. axisPath: { action: [], type: [] }, // 动作/类型 筛选路径(l1/l2/叶子,来自 matrix,筛表显示)
  4106. matrix: null, // /api/query_matrix
  4107. scores: null, // 最近一次评分结果 cells
  4108. threshold: 7, // 达标 = keep 且 综合分≥此值(可在弹层调)
  4109. lastCost: null,
  4110. };
  4111. function qrChip(label, active, on, cls) {
  4112. const b = document.createElement("button");
  4113. b.className = "chip" + (cls ? " " + cls : "") + (active ? " on" : "");
  4114. b.textContent = label;
  4115. b.onclick = on;
  4116. return b;
  4117. }
  4118. function qrRow(root, labtxt) {
  4119. const row = document.createElement("div");
  4120. row.className = "qr-row";
  4121. row.innerHTML = `<span class="qr-lab">${labtxt}</span>`;
  4122. const wrap = document.createElement("span");
  4123. wrap.className = "qr-chips";
  4124. row.appendChild(wrap);
  4125. root.appendChild(row);
  4126. return wrap;
  4127. }
  4128. // 动作/类型 三级(l1/l2/叶子)取自 matrix items 的 l1/l2/name
  4129. function qrAxisLevelOptions(items, prefix) {
  4130. if (prefix.length === 0) return [...new Set(items.map((x) => x.l1))];
  4131. if (prefix.length === 1) return [...new Set(items.filter((x) => x.l1 === prefix[0]).map((x) => x.l2))];
  4132. return items.filter((x) => x.l1 === prefix[0] && x.l2 === prefix[1]).map((x) => x.name);
  4133. }
  4134. function qrAxisMatch(item, path) {
  4135. if (path[0] && item.l1 !== path[0]) return false;
  4136. if (path[1] && item.l2 !== path[1]) return false;
  4137. if (path[2] && item.name !== path[2]) return false;
  4138. return true;
  4139. }
  4140. function renderQrDims() {
  4141. const root = $("#qr-dims");
  4142. root.innerHTML = "";
  4143. // 扁平维度(工具类型/模态/后缀):拼词上下文
  4144. QR_FLAT.forEach((d) => {
  4145. const wrap = qrRow(root, `· ${d.label}`);
  4146. wrap.appendChild(qrChip("无", qrState.flat[d.id] == null, () => { qrState.flat[d.id] = null; renderQrDims(); renderQrTable(); }));
  4147. d.items.forEach((it) =>
  4148. wrap.appendChild(qrChip(it, qrState.flat[d.id] === it, () => { qrState.flat[d.id] = it; renderQrDims(); renderQrTable(); })));
  4149. });
  4150. // 实质/形式 接口下钻:仅作 Sonnet 上下文,不拼词、不筛表
  4151. QR_TREE.forEach((d) => {
  4152. const path = qrState.treePath[d.id];
  4153. let level = qrState.treeData[d.id] ? qrState.treeData[d.id].tree : [];
  4154. for (let depth = 0; ; depth++) {
  4155. const wrap = qrRow(root, depth === 0 ? `· ${d.label}` : "");
  4156. wrap.appendChild(qrChip("无", path.length === depth, () => { qrState.treePath[d.id] = path.slice(0, depth); renderQrDims(); }));
  4157. (level || []).forEach((node) =>
  4158. wrap.appendChild(qrChip(node.name, path[depth] === node.name,
  4159. () => { qrState.treePath[d.id] = [...path.slice(0, depth), node.name]; renderQrDims(); })));
  4160. const sel = (level || []).find((n) => n.name === path[depth]);
  4161. if (!sel || !(sel.children && sel.children.length)) break;
  4162. level = sel.children;
  4163. }
  4164. });
  4165. // 动作/类型 下钻(来自 matrix l1/l2):筛选表格显示
  4166. if (qrState.matrix) {
  4167. [{ id: "action", label: "动作", items: qrState.matrix.actions },
  4168. { id: "type", label: "类型", items: qrState.matrix.types }].forEach((d) => {
  4169. const path = qrState.axisPath[d.id];
  4170. for (let depth = 0; depth <= 2; depth++) {
  4171. const opts = qrAxisLevelOptions(d.items, path.slice(0, depth));
  4172. if (!opts.length) break;
  4173. const wrap = qrRow(root, depth === 0 ? `· ${d.label}` : "");
  4174. wrap.appendChild(qrChip("无", path.length === depth,
  4175. () => { qrState.axisPath[d.id] = path.slice(0, depth); renderQrDims(); renderQrTable(); }, "axis"));
  4176. opts.forEach((name) =>
  4177. wrap.appendChild(qrChip(name, path[depth] === name,
  4178. () => { qrState.axisPath[d.id] = [...path.slice(0, depth), name]; renderQrDims(); renderQrTable(); }, "axis")));
  4179. if (path[depth] == null) break; // 未选中本层 → 不展开下一层
  4180. }
  4181. });
  4182. }
  4183. }
  4184. async function qrOpen() {
  4185. qrClosePop();
  4186. renderQrDims();
  4187. // 并行拉矩阵 + 两棵分类树(接口挂则该维度降级:提示不可选)
  4188. try { qrState.matrix = qrState.matrix || await api("/api/query_matrix"); }
  4189. catch (e) { return toast("内容树矩阵加载失败", "error"); }
  4190. for (const d of QR_TREE) {
  4191. if (qrState.treeData[d.id]) continue;
  4192. try { qrState.treeData[d.id] = await api("/api/category_tree?source_type=" + encodeURIComponent(d.source)); }
  4193. catch (e) { toast(`${d.label} 接口不可达,该维度暂不可选`, "warn"); }
  4194. }
  4195. renderQrDims();
  4196. renderQrTable();
  4197. }
  4198. // 单格 query = [工具类型] 动作叶 类型叶 [模态] [后缀](与后端 query_score._build_cells 一致)
  4199. function qrCellQuery(action, type) {
  4200. const f = qrState.flat;
  4201. return [f.tool_type, action, type, f.modality, f.suffix].filter((x) => x && x !== "无").join(" ");
  4202. }
  4203. function renderQrTable() {
  4204. const m = qrState.matrix;
  4205. if (!m) return;
  4206. const { actions, types, matrix } = m;
  4207. const sc = qrState.scores; // {"ai_ti":{keep,score,rewrite,...}}
  4208. // 按 动作/类型 筛选路径过滤可见行列(保留原始索引 ai/ti 供评分键 ai_ti)
  4209. const aIdx = actions.map((_, i) => i).filter((i) => qrAxisMatch(actions[i], qrState.axisPath.action));
  4210. const tIdx = types.map((_, i) => i).filter((i) => qrAxisMatch(types[i], qrState.axisPath.type));
  4211. let html = '<table class="qr-tab"><thead>';
  4212. html += '<tr><th class="qr-corner" rowspan="2">类型 \\ 动作</th>';
  4213. const groups = [];
  4214. aIdx.forEach((ai) => {
  4215. const l1 = actions[ai].l1;
  4216. const last = groups[groups.length - 1];
  4217. if (last && last.l1 === l1) last.span++;
  4218. else groups.push({ l1, span: 1 });
  4219. });
  4220. groups.forEach((g) => { html += `<th colspan="${g.span}" class="qr-gh">${g.l1}</th>`; });
  4221. html += "</tr><tr>";
  4222. aIdx.forEach((ai) => { html += `<th class="qr-ah">${actions[ai].name}</th>`; });
  4223. html += "</tr></thead><tbody>";
  4224. let curL1 = null;
  4225. tIdx.forEach((ti) => {
  4226. const t = types[ti];
  4227. if (t.l1 !== curL1) {
  4228. curL1 = t.l1;
  4229. html += `<tr><td class="qr-tl1" colspan="${aIdx.length + 1}">${t.l1}</td></tr>`;
  4230. }
  4231. html += `<tr><th class="qr-th">${t.name}</th>`;
  4232. aIdx.forEach((ai) => {
  4233. const tier = (matrix[ai][ti] || {}).tier || 0;
  4234. const q = qrCellQuery(actions[ai].name, t.name);
  4235. const v = sc ? sc[`${ai}_${ti}`] : null;
  4236. const keep = qrKeep(v);
  4237. const cls = `qr-c t${tier}` + (tier === 0 ? " dead" : "") + (keep ? " keep" : "");
  4238. const badge = keep && v.score != null ? `<i class="qr-bd">${v.score}</i>` : "";
  4239. html += `<td class="${cls}" data-ai="${ai}" data-ti="${ti}">${q}${badge}</td>`;
  4240. });
  4241. html += "</tr>";
  4242. });
  4243. html += "</tbody></table>";
  4244. $("#qr-table-wrap").innerHTML = html;
  4245. }
  4246. function qrSelBody() {
  4247. return {
  4248. tool_type: qrState.flat.tool_type || "",
  4249. modality: qrState.flat.modality || "",
  4250. suffix: qrState.flat.suffix || "",
  4251. substance_path: qrState.treePath.substance,
  4252. form_path: qrState.treePath.form,
  4253. };
  4254. }
  4255. async function qrLoadScores(sel) {
  4256. const r = await api("/api/query_score?sel=" + encodeURIComponent(sel));
  4257. if (r && r.pending) return false;
  4258. qrState.scores = r.cells || {};
  4259. qrState.lastCost = r.cost_usd;
  4260. renderQrTable();
  4261. qrRefreshKeep();
  4262. return true;
  4263. }
  4264. // 达标 = Sonnet keep 且 综合分≥阈值;高亮/计数/搜全部达标 统一口径
  4265. function qrKeep(v) { return !!(v && v.keep && v.score != null && v.score >= qrState.threshold); }
  4266. function qrRefreshKeep() {
  4267. if (!qrState.scores) return;
  4268. const k = Object.values(qrState.scores).filter(qrKeep).length;
  4269. $("#qr-hint").textContent = `达标(keep 且 ≥${qrState.threshold}):${k} 格`
  4270. + (qrState.lastCost != null ? ` · 评分 $${qrState.lastCost}` : "");
  4271. $("#qr-search-all").hidden = k === 0;
  4272. }
  4273. $("#qr-thr").addEventListener("input", () => {
  4274. const x = parseFloat($("#qr-thr").value);
  4275. qrState.threshold = isNaN(x) ? 0 : x;
  4276. if (qrState.scores) { qrClosePop(); renderQrTable(); qrRefreshKeep(); }
  4277. });
  4278. $("#qr-score").onclick = async () => {
  4279. const btn = $("#qr-score");
  4280. if (btn.disabled) return; // 评分进行中:防重复点击(避免重复起任务/花钱)
  4281. const orig = btn.textContent;
  4282. btn.disabled = true; btn.textContent = "评估中…";
  4283. const restore = () => { btn.disabled = false; btn.textContent = orig; };
  4284. renderQrTable(); // 先按当前 chips 刷新拼词
  4285. $("#qr-hint").textContent = "提交评分…";
  4286. let r;
  4287. try { r = await api("/api/query_score", { method: "POST", body: JSON.stringify(qrSelBody()) }); }
  4288. catch (e) { toast("评分启动失败:" + (e.body?.error || e.status), "error"); return restore(); }
  4289. if (r.cached) { try { await qrLoadScores(r.sel); } finally { restore(); } return; }
  4290. // 后台任务:完成→载入结果;成功/失败/查询出错 都恢复按钮(onSettled)
  4291. showTask("Query 评分 · 643 格", r.task_id,
  4292. async () => { await qrLoadScores(r.sel); },
  4293. (status) => { if (status !== "done") toast("评分任务" + (status === "failed" ? "失败" : "状态异常") + ",可重试", "warn"); restore(); });
  4294. };
  4295. async function qrRunSearch(query, label) {
  4296. const body = { query, platforms: "xhs,gzh", max_count: 20 }; // 用改写词搜索,方向无关
  4297. if (label && label !== query) body.query_text = label; // query 列表存原始组合词
  4298. const r = await api("/api/run_search", { method: "POST", body: JSON.stringify(body) });
  4299. return r; // {task_id, query_id}
  4300. }
  4301. // 点高亮格 → 气泡显示评分/理由 + 发起搜索/复制(不再用浏览器原生 confirm)
  4302. function qrClosePop() { $("#qr-pop").hidden = true; }
  4303. function qrShowPop(td, v) {
  4304. const pop = $("#qr-pop");
  4305. const query = v.rewrite || v.query;
  4306. const orig = v.rewrite && v.rewrite !== v.query ? `<div class="orig">原: ${v.query}</div>` : "";
  4307. const tier = td.classList.contains("t3") ? 3 : td.classList.contains("t2") ? 2 : td.classList.contains("t1") ? 1 : 0;
  4308. pop.innerHTML =
  4309. `<div class="q">${query}</div>${orig}` +
  4310. `<div class="sc"><b>${v.score ?? "?"}</b><span class="dim">综合分 = 人话 ${v.natural ?? "?"}×.4 + 可搜 ${v.findable ?? "?"}×.3 + 价值 ${v.useful ?? "?"}×.3</span></div>` +
  4311. `<div class="dim" style="margin:0 0 7px">内容树 tier ${tier}(人工预判可检索度,仅参考,不计入综合分)</div>` +
  4312. `<div class="rsn">${v.reason || "(无理由)"}</div>` +
  4313. `<div class="acts"><button class="btn seal" id="qr-pop-go">发起搜索</button><button class="btn" id="qr-pop-copy">复制</button></div>`;
  4314. pop.hidden = false;
  4315. const r = td.getBoundingClientRect(), pw = 300, ph = pop.offsetHeight || 150;
  4316. let left = r.left, top = r.bottom + 6;
  4317. if (left + pw > window.innerWidth - 10) left = window.innerWidth - pw - 10;
  4318. if (top + ph > window.innerHeight - 10) top = r.top - ph - 6;
  4319. pop.style.left = Math.max(10, left) + "px";
  4320. pop.style.top = Math.max(10, top) + "px";
  4321. $("#qr-pop-go").onclick = async () => {
  4322. qrClosePop();
  4323. try { const rr = await qrRunSearch(query, v.query); showTask(`搜索 · ${rr.query_id} ${query}`, rr.task_id, null); }
  4324. catch (err) { toast("搜索启动失败:" + (err.body?.error || err.status), "error"); }
  4325. };
  4326. $("#qr-pop-copy").onclick = () => { navigator.clipboard && navigator.clipboard.writeText(query); toast("已复制", "info", 1200); };
  4327. }
  4328. $("#qr-table-wrap").onclick = (e) => {
  4329. const td = e.target.closest("td.qr-c.keep");
  4330. if (!td) return;
  4331. const v = qrState.scores && qrState.scores[`${td.dataset.ai}_${td.dataset.ti}`];
  4332. if (v) qrShowPop(td, v);
  4333. };
  4334. // 点气泡外/表格空白处 关闭气泡
  4335. $("#qr-modal").addEventListener("click", (e) => {
  4336. if (!e.target.closest("#qr-pop") && !e.target.closest("td.qr-c.keep")) qrClosePop();
  4337. });
  4338. // 搜全部达标:逐格起任务(朴素循环,失败不阻断)
  4339. // 批量进度面板:任务面板里列出每个搜索的实时状态(轮询各 task_id)
  4340. function showQrBatch(items) {
  4341. hasTask = true;
  4342. $("#task-panel").hidden = false;
  4343. $("#task-title").textContent = `搜全部达标 · ${items.length} 个`;
  4344. $("#task-dot").className = "dot";
  4345. clearTimeout(pollTimer);
  4346. const st = {};
  4347. const poll = async () => {
  4348. await Promise.all(items.map(async (it) => {
  4349. if (st[it.task_id] && st[it.task_id] !== "running") return;
  4350. try { const t = await api("/api/task_status?task_id=" + encodeURIComponent(it.task_id)); st[it.task_id] = t.status; }
  4351. catch (e) { st[it.task_id] = st[it.task_id] || "running"; }
  4352. }));
  4353. const done = items.filter((it) => st[it.task_id] && st[it.task_id] !== "running").length;
  4354. $("#task-title").textContent = `搜全部达标 · ${done}/${items.length} 完成`;
  4355. $("#task-log").textContent = items.map((it) => {
  4356. const s = st[it.task_id] || "running";
  4357. return `${s === "done" ? "✅" : s === "failed" ? "❌" : "⏳"} ${it.query_id} ${it.query}`;
  4358. }).join("\n");
  4359. if (done < items.length) pollTimer = setTimeout(poll, 2000);
  4360. else $("#task-dot").className = "dot done";
  4361. };
  4362. poll();
  4363. }
  4364. $("#qr-search-all").onclick = async () => {
  4365. const keeps = Object.entries(qrState.scores || {}).filter(([, v]) => qrKeep(v));
  4366. if (!keeps.length) return;
  4367. if (!(await uiConfirm(`将对 ${keeps.length} 个达标 query 各起一次搜索(小红书+公众号 各20),确认?`))) return;
  4368. qrClosePop();
  4369. const items = [];
  4370. for (const [, v] of keeps) {
  4371. const q = v.rewrite || v.query;
  4372. 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 }); }
  4373. catch (e) { /* 单格失败不阻断 */ }
  4374. }
  4375. if (!items.length) return toast("全部发起失败", "error");
  4376. toast(`已发起 ${items.length}/${keeps.length} 个搜索`, "info");
  4377. showQrBatch(items);
  4378. };
  4379. /* ════ 新建搜索 ════ */
  4380. /* 渠道下拉多选(选项同 search_eval:小红书/知乎/公众号/抖音/视频号/YouTube) */
  4381. const CHANNELS = [
  4382. { key: "xhs", name: "小红书", on: true },
  4383. { key: "zhihu", name: "知乎", on: true },
  4384. { key: "gzh", name: "公众号" },
  4385. { key: "douyin", name: "抖音" },
  4386. { key: "sph", name: "视频号" },
  4387. { key: "youtube", name: "YouTube" },
  4388. ];
  4389. $("#s-plat-panel").innerHTML = CHANNELS.map(
  4390. (c) => `
  4391. <label class="dd-opt ${c.on ? "sel" : ""}">
  4392. <input type="checkbox" value="${c.key}" ${c.on ? "checked" : ""}>${c.name}
  4393. </label>`,
  4394. ).join("");
  4395. function selectedPlatforms() {
  4396. return [...document.querySelectorAll("#s-plat-panel input:checked")].map((x) => x.value);
  4397. }
  4398. function syncPlatBtn() {
  4399. const names = [...document.querySelectorAll("#s-plat-panel input:checked")].map(
  4400. (x) => CHANNELS.find((c) => c.key === x.value).name,
  4401. );
  4402. $("#s-plat-btn").innerHTML =
  4403. `<span>${names.length ? esc(names.join("、")) : "选择渠道"}</span><span class="dd-arrow">▾</span>`;
  4404. }
  4405. $("#s-plat-btn").onclick = (e) => {
  4406. e.stopPropagation();
  4407. $("#s-plat-panel").hidden = !$("#s-plat-panel").hidden;
  4408. };
  4409. $("#s-plat-panel").onclick = (e) => e.stopPropagation();
  4410. $("#s-plat-panel").addEventListener("change", (e) => {
  4411. e.target.closest(".dd-opt").classList.toggle("sel", e.target.checked);
  4412. syncPlatBtn();
  4413. });
  4414. document.addEventListener("click", () => {
  4415. $("#s-plat-panel").hidden = true;
  4416. });
  4417. syncPlatBtn();
  4418. $("#btn-new-search").onclick = () => {
  4419. $("#s-mode").value = state.mode === "process" ? "工序" : "工具"; // 默认跟随当前子模式
  4420. $("#search-modal").hidden = false;
  4421. $("#s-query").focus();
  4422. };
  4423. $("#search-modal").onclick = (e) => {
  4424. if (e.target === $("#search-modal")) $("#search-modal").hidden = true;
  4425. };
  4426. $("#s-go").onclick = async () => {
  4427. const query = $("#s-query").value.trim();
  4428. if (!query) return toast("请填写 query", "warn");
  4429. const plats = selectedPlatforms();
  4430. if (!plats.length) return toast("请至少选择一个检索渠道", "warn");
  4431. const body = {
  4432. query,
  4433. synonyms: $("#s-syn").value.trim(),
  4434. mode_type: $("#s-mode").value,
  4435. platforms: plats.join(","),
  4436. max_count: parseInt($("#s-max").value) || 10,
  4437. };
  4438. try {
  4439. const r = await api("/api/run_search", { method: "POST", body: JSON.stringify(body) });
  4440. $("#search-modal").hidden = true;
  4441. showTask(`搜索 · ${r.query_id} ${query}`, r.task_id, async () => {
  4442. /* 搜索结果落在 s-mode 对应的表,完成后切到对应子模式再选中 */
  4443. const m = body.mode_type === "工具" ? "tools" : "process";
  4444. if (state.mode !== m) {
  4445. state.mode = m;
  4446. $("#m-process").classList.toggle("on", m === "process");
  4447. $("#m-tools").classList.toggle("on", m === "tools");
  4448. }
  4449. await loadQueries();
  4450. selectQuery(r.query_id);
  4451. });
  4452. } catch (e) {
  4453. toast("搜索启动失败:" + (e.body?.error || e.status), "error");
  4454. }
  4455. };
  4456. /* ════ query 列表筛选下拉 ════ */
  4457. function markQfActive() {
  4458. $("#qf-btn").classList.toggle("active", qFilter.time !== "desc" || qFilter.searched !== "all");
  4459. }
  4460. $("#qf-btn").onclick = (e) => {
  4461. e.stopPropagation();
  4462. $("#qf-pop").hidden = !$("#qf-pop").hidden;
  4463. };
  4464. $("#qf-time").onchange = (e) => {
  4465. qFilter.time = e.target.value;
  4466. markQfActive();
  4467. renderQueries();
  4468. };
  4469. $("#qf-searched").onchange = (e) => {
  4470. qFilter.searched = e.target.value;
  4471. markQfActive();
  4472. renderQueries();
  4473. };
  4474. /* 点下拉外部关闭 */
  4475. document.addEventListener("click", (e) => {
  4476. if (!e.target.closest("#qf-pop") && !e.target.closest("#qf-btn")) $("#qf-pop").hidden = true;
  4477. });
  4478. /* ════ 工序/工具子模式 ════ */
  4479. $("#m-process").onclick = () => setMode("process");
  4480. $("#m-tools").onclick = () => setMode("tools");
  4481. function setMode(m) {
  4482. if (state.mode === m) return;
  4483. state.mode = m;
  4484. state.version = null;
  4485. /* 工序/工具是两张独立搜索表,切换时整体重置三栏 */
  4486. state.queryId = null;
  4487. state.caseId = null;
  4488. state.post = null;
  4489. state.posts = [];
  4490. state.selected.clear();
  4491. state.platFilter = "all";
  4492. $("#m-process").classList.toggle("on", m === "process");
  4493. $("#m-tools").classList.toggle("on", m === "tools");
  4494. $("#plat-tabs").hidden = true;
  4495. $("#p-count").textContent = "";
  4496. $("#post-list").innerHTML = '<div class="empty"><span class="glyph">←</span>先选择左侧 query</div>';
  4497. renderExtractEmpty();
  4498. loadQueries();
  4499. }
  4500. $("#btn-query-rule").onclick = () => { $("#qr-modal").hidden = false; qrOpen(); };
  4501. $("#qr-close").onclick = () => { $("#qr-modal").hidden = true; };
  4502. $("#qr-modal").onclick = (e) => { if (e.target === $("#qr-modal")) $("#qr-modal").hidden = true; };
  4503. window.addEventListener("resize", () => chartRefs.forEach((c) => c.resize()));
  4504. route();
  4505. </script>
  4506. </body>
  4507. </html>