index.html 121 KB

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