index.html 147 KB

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