index.html 154 KB

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