index.html 166 KB

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