index.html 104 KB

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