index.html 124 KB

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