CockpitShell.vue 204 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003
  1. <!--
  2. 驾驶舱外壳:唯一 /cockpit 路由的全部内容。
  3. 骨架与视觉参考《驾驶舱原型图-美化版》(切角面板 / 青色辉光 / 深空蓝底 / 全息地图壳),
  4. 但不锁 16:9:页面铺满视口,**中央一张图作为整个主体的背景铺满**,左右两栏浮在图上。
  5. 语义按 ADR 0003 / 0007:四个一级模式、模式内 4 个二级面板同屏展示、无子视图切换。
  6. 一级模式只通过 uiStore.mode 切换,不新增路由、不重建外壳与地图节点。
  7. 范围与行业是全局筛选(filterStore),切换一级模式不得重置它们(验收第 ⑦ 条)。
  8. -->
  9. <template>
  10. <div
  11. class="cockpit-shell"
  12. :data-font-gate="fontGate"
  13. :data-font-faces="fontFaceCount"
  14. :data-display-gate="displayGate.phase"
  15. :data-display-epoch="String(displayGate.epoch)"
  16. >
  17. <div class="cockpit-shell__atmosphere" aria-hidden="true"></div>
  18. <header class="cockpit-shell__topbar" :style="navDecorStyle">
  19. <div class="cockpit-shell__topbar-bg" aria-hidden="true"></div>
  20. <!-- 票 17 第十一轮:底边光路改为**裁切窗口**——只显示切图中段线段(画布列 22.9%–62%),
  21. 从标题右侧起铺到屏幕右缘。此前整图拉伸 100% 宽,线段按百分比映射视口,
  22. 起点永远落在标题上(挪图片盒子无济于事)。URL 经语义 key 注入(navDecorStyle)。 -->
  23. <div class="cockpit-shell__topbar-path" aria-hidden="true"></div>
  24. <span class="cockpit-shell__wing is-left" aria-hidden="true"></span>
  25. <span class="cockpit-shell__wing is-right" aria-hidden="true"></span>
  26. <div class="cockpit-shell__brand">
  27. <!--
  28. 票 17 第六轮(维护者:要符合切图素材风格,把 brand-glow / brand-glow-path 用上):
  29. 标题回到蓝湖切图 `Group 5061`(渐变文字 + 底座光带,设计原样)。
  30. 第五轮"太小"的真因是**按顶栏高度等比缩放**——切图 470×114 里文字只占上部 53.5%,
  31. 等比进 52u 顶栏后文字仅 29u。现在**按文字高度反推整图宽**(宽 313u → 高 76u → 文字 ≈41u),
  32. 图片顶部对齐(不居中,切图文字从画布第 0 行开始,居中会裁掉字顶),
  33. 底部淡晕溢出顶栏、由下方筛选条自然承接——正是设计稿里光层(114)比文字(61)高的关系。
  34. -->
  35. <CockpitIcon class="cockpit-shell__mark" name="brand" size="calc(404 * var(--u))" />
  36. <strong class="cockpit-shell__sr-only">城市生命线驾驶舱系统</strong>
  37. </div>
  38. <nav class="cockpit-shell__modes" aria-label="一级模式">
  39. <button
  40. v-for="item in MODES"
  41. :key="item"
  42. type="button"
  43. class="cockpit-shell__mode"
  44. :class="{ 'is-active': item === mode }"
  45. :aria-pressed="item === mode"
  46. @click="uiStore.setMode(item)"
  47. >
  48. {{ modeLabel(item) }}
  49. </button>
  50. </nav>
  51. <div class="cockpit-shell__top-meta">
  52. <!--
  53. 票 30:快速归位(回到目标城市预设视角)。
  54. 票 37:区内/区外文案不同 —— 区内是「归位」(已进区,只是回该视角);
  55. 区外是「归位/进入」(点它就进区并锁定,ADR 0009 R2-5)。
  56. -->
  57. <button
  58. type="button"
  59. class="cockpit-shell__chip cockpit-shell__home"
  60. :class="{ 'is-active': atHomeView }"
  61. :data-home-at="atHomeView ? 'yes' : 'no'"
  62. :data-area-locked="areaLocked ? 'yes' : 'no'"
  63. :title="homeTitle"
  64. :aria-label="areaBar.homeLabel"
  65. @click="returnHome()"
  66. >
  67. {{ areaBar.homeLabel }}
  68. </button>
  69. <!-- 票 37:只有区内才有「返回全球」(区外它没有意义,不占位置)。 -->
  70. <button
  71. v-if="areaBar.returnGlobal"
  72. type="button"
  73. class="cockpit-shell__chip cockpit-shell__return-global"
  74. data-return-global
  75. :title="`解除主场景区限位,回到自由全球视角(区内最远 ${Math.round(areaLimits.max)} m)`"
  76. @click="returnToGlobal()"
  77. >
  78. 返回全球
  79. </button>
  80. <!-- 票 102:顶栏只留在用的按钮(归位 / 返回全球)与时钟。
  81. 维护者 2026-11-02:配置三态、只读标记、模式读数三个诊断读数下屏 ——
  82. 它们既占走查视线,又把右侧状态区撑宽,挤得中列菜单左右晃动。 -->
  83. <CockpitClock />
  84. </div>
  85. </header>
  86. <!-- 全局筛选:作用于整个驾驶舱,切换一级模式不重置 -->
  87. <div class="cockpit-shell__scope">
  88. <div class="cockpit-shell__scope-left">
  89. <span class="cockpit-shell__scope-label">当前范围</span>
  90. <div class="cockpit-shell__chips">
  91. <button
  92. v-for="item in SCOPES"
  93. :key="item.key"
  94. type="button"
  95. class="cockpit-shell__chip cockpit-shell__scope-btn"
  96. :class="{ 'is-active': item.key === scope }"
  97. :aria-pressed="item.key === scope"
  98. :data-scope="item.key"
  99. @click="filterStore.setScope(item.key)"
  100. >
  101. {{ item.label }}
  102. </button>
  103. </div>
  104. <span class="cockpit-shell__divider" aria-hidden="true"></span>
  105. <span class="cockpit-shell__scope-label">行业</span>
  106. <div class="cockpit-shell__chips">
  107. <button
  108. v-for="item in industryChips"
  109. :key="item.key"
  110. type="button"
  111. class="cockpit-shell__chip cockpit-shell__industry-btn"
  112. :class="{ 'is-active': item.key === industry }"
  113. :aria-pressed="item.key === industry"
  114. :data-industry="item.key"
  115. @click="filterStore.setIndustry(item.key)"
  116. >
  117. <!-- 批次 1:行业图标,纯装饰;aria-hidden 不参与按钮命名。 -->
  118. <CockpitIcon v-if="item.icon" :name="item.icon" :size="industryIconSize" class="cockpit-shell__industry-icon" />
  119. {{ item.label }}
  120. </button>
  121. </div>
  122. <span class="cockpit-shell__divider" aria-hidden="true"></span>
  123. <!--
  124. 票 21:地面/管线视图(决策地图票 05 定的「全局视图条件」)。
  125. 它是全局条件,与范围/行业同级 —— 切换一级模式不重置它。
  126. -->
  127. <span class="cockpit-shell__scope-label">视图</span>
  128. <div class="cockpit-shell__chips">
  129. <button
  130. v-for="item in VIEW_MODE_OPTIONS"
  131. :key="item.key"
  132. type="button"
  133. class="cockpit-shell__chip cockpit-shell__view-btn"
  134. :class="{ 'is-active': item.key === viewMode }"
  135. :aria-pressed="item.key === viewMode"
  136. :data-view-mode="item.key"
  137. :title="item.hint"
  138. @click="switchViewMode(item.key)"
  139. >
  140. {{ item.label }}
  141. </button>
  142. </div>
  143. </div>
  144. <div class="cockpit-shell__scope-right">
  145. <div
  146. class="cockpit-shell__status-summary"
  147. :class="{ 'is-open': statusPanelExpanded }"
  148. :data-status-expanded="statusPanelExpanded ? 'true' : 'false'"
  149. >
  150. <button
  151. type="button"
  152. class="cockpit-shell__status-toggle"
  153. data-status-toggle
  154. :aria-expanded="statusPanelExpanded"
  155. aria-controls="cockpit-status-details"
  156. @click="statusPanelExpanded = !statusPanelExpanded"
  157. >
  158. <i class="cockpit-shell__status-dot" :class="statusSummaryTone" aria-hidden="true"></i>
  159. <span data-status-summary>{{ statusSummaryText }}</span>
  160. <span class="cockpit-shell__status-chevron" aria-hidden="true">{{ statusPanelExpanded ? '⌃' : '⌄' }}</span>
  161. </button>
  162. <div
  163. id="cockpit-status-details"
  164. v-show="statusPanelExpanded"
  165. class="cockpit-shell__status-details"
  166. data-status-details
  167. >
  168. <!--
  169. 票 14(决策 02 的 Q24/Q25):地图摘要进入系统/筛选变化后**自动分批加载到完成**。
  170. 它作为状态详情的一行保留 `data-map-summary-*` 断言面;手动刷新按钮移到状态摘要
  171. 右侧独立位置,避免和范围/行业/视图选择争抢横向空间。
  172. -->
  173. <div
  174. class="cockpit-shell__map-summary"
  175. :data-map-summary-phase="mapSummaryView.phase"
  176. role="status"
  177. aria-label="地图摘要"
  178. >
  179. <i class="cockpit-shell__map-summary-dot" aria-hidden="true"></i>
  180. <span class="cockpit-shell__map-summary-text" data-map-summary-label :title="mapSummaryView.detail">
  181. {{ mapSummaryView.label }}
  182. </span>
  183. <span
  184. class="cockpit-shell__map-summary-counts"
  185. data-map-summary-counts
  186. :data-map-summary-partial="mapSummaryPartial ? 'yes' : 'no'"
  187. :title="mapSummaryCountsText"
  188. >{{ mapSummaryCountsText }}</span>
  189. </div>
  190. <!--
  191. 票 05:共享数据分区的状态板。验收第 6 条要的「只把受影响分区标为数据不可用、
  192. 保留已成功分区与地图骨架」在这里可见;每个分区带 data-section-* 供走查断言。
  193. 票 14(规格 09):real 与 mock **同构启动**——同一套分区语义对两种数据源都成立,
  194. real 的失败路径(不可达 / 未配地址)同样只标对应分区。
  195. -->
  196. <span class="cockpit-shell__scope-label">数据分区</span>
  197. <div class="cockpit-shell__sections" data-section-board>
  198. <SectionStateTag
  199. v-for="item in sharedSections"
  200. :key="item.name"
  201. :name="item.name"
  202. :section="item.section"
  203. :label="item.label"
  204. />
  205. </div>
  206. <!--
  207. 票 25:地图信息并入**本状态面板**,不再另起容器。
  208. 维护者反馈过另起面板会与顶部图例、本面板互相占用容器(图一 vs 图二)。
  209. 内容含:当前模式、降级说明、图层、标记计数、坐标准入明细、引擎读数、
  210. 数据来源署名(Cesium 自带署名已移出画面,见 cesiumEngine.js)。
  211. -->
  212. <MapInfoPanel
  213. class="cockpit-shell__map-info"
  214. :mode-label="modeLabel(mode)"
  215. :ui-debug="uiDebug"
  216. :degraded-notes="modeLayerPlan.degradedNotes"
  217. :marker-on-map="mapMarkerCount"
  218. :marker-status-text="mapMarkerStatusText"
  219. :coordinate-overview="mapCoordinateOverview"
  220. :basemap-label="mapBasemapLabel"
  221. :credits="mapDataSourceCredits"
  222. />
  223. <!--
  224. 票 67(含维护者 2026-10-23 更正):「当前范围」对管线/构件图层的真实落点。
  225. 几何 properties 里确实没有片区字段,但**设施编码**的规则是「片区+行业+时间编码」
  226. (TCRQ... = 太常燃气),所以片区能从编码前缀推出来并按它裁剪图层
  227. (domain/pipeNetwork.js 的 pipeDistrictOf)。这条说明讲的就是「片区是推出来的」。
  228. 措辞来自 domain/filterCaliber.js 的单一来源,外壳不另写一份。
  229. -->
  230. <span class="cockpit-shell__chip cockpit-shell__pipe-scope" data-pipe-district-note role="note">
  231. {{ PIPE_DISTRICT_NOTE }}
  232. </span>
  233. <!--
  234. 票 17:定位反馈。**票 38(第 5 条)把它从这块折叠详情里挪走了**——
  235. 「状态详情」默认收起,失败提示藏在里面等于「点了没反应」;
  236. 现在它是主体区底部的浮层(见 cockpit-shell__notice),这里只留注释锚点。
  237. -->
  238. <!--
  239. 票 42(规格 14:刷新核对链):换新快照期间设备图层已挂起,详情进入「待核对」;
  240. 顶栏如实提示并保留关闭入口(关闭按钮在上方 data-anchor-hidden chip 里)。
  241. -->
  242. <span v-if="snapshotPending && detailOpen"
  243. class="cockpit-shell__chip cockpit-shell__anchor-status" data-snapshot-pending role="status">
  244. 快照核对中 · 关联设备图层已暂撤
  245. </span>
  246. <!--
  247. 票 42:完整加载仍找不到所选点位 → 详情已按规格关闭,并说明原因。
  248. -->
  249. <span v-if="snapshotAbsentNote" class="cockpit-shell__chip cockpit-shell__locate" data-snapshot-absent role="status">
  250. {{ snapshotAbsentNote }}
  251. </span>
  252. <!--
  253. 票 37:进区受阻时的如实提示(主场景区未配置 / 配置非法)。
  254. 与票 04/05 同一条立场:能力不可用只标出来,不弹窗、不遮罩、不挡业务。
  255. -->
  256. <span v-if="areaNotice" class="cockpit-shell__chip cockpit-shell__locate" data-area-notice role="status">
  257. {{ areaNotice }}
  258. </span>
  259. <!--
  260. 票 15:状态推送的连接状态(验收第 6 条「连接/重连/过期/失败可演示」)。
  261. data-ws-state 是走查断言面;文案来自运行时服务,外壳不重写。
  262. -->
  263. <span
  264. class="cockpit-shell__chip cockpit-shell__ws"
  265. :class="{ 'is-bad': !runtimeStore.live }"
  266. :data-ws-state="runtimeStore.status.state"
  267. :title="runtimeStore.status.lastError || runtimeStore.statusText"
  268. role="status"
  269. >
  270. {{ runtimeStore.statusText }}
  271. <span v-if="runtimeStore.orderScanIntervalMs" data-order-scan-delay> · 工单扫描间隔 {{ runtimeStore.orderScanIntervalMs / 1000 }} 秒</span>
  272. </span>
  273. <!--
  274. 票 16:统一新鲜度 —— 「最近一次成功更新」+ 四态。
  275. 过期时**必须**看得见(验收第 4 条:保留旧值但不伪装成实时),
  276. 所以文案与色键都来自 domain/freshnessModel.js,外壳不重写。
  277. data-freshness / data-freshness-at 是走查断言面。
  278. -->
  279. <span
  280. class="cockpit-shell__chip cockpit-shell__freshness"
  281. :class="{ 'is-stale': runtimeStore.retained, 'is-bad': runtimeStore.freshness.view === 'unavailable' }"
  282. :data-freshness="runtimeStore.freshness.view"
  283. :data-freshness-at="runtimeStore.freshness.lastSuccessClock"
  284. :data-freshness-overall="overallFreshnessState"
  285. :title="runtimeStore.freshness.reason || runtimeStore.freshness.text"
  286. role="status"
  287. >
  288. 更新 {{ runtimeStore.freshness.lastSuccessClock }} · {{ runtimeStore.freshness.text }}
  289. <!--
  290. 票 16 验收第 2 条:**部分失败**是跨分区的性质,单块面板只会说自己那一份,
  291. 所以在这里补一句整体结论(判据来自 domain/freshnessModel.js,界面不数数)。
  292. -->
  293. <b v-if="overallFreshnessState === 'partial'" class="cockpit-shell__freshness-extra" data-freshness-partial>
  294. · {{ overallFreshnessLabel }}
  295. </b>
  296. </span>
  297. </div>
  298. </div>
  299. </div>
  300. <!--
  301. 票 61:这个按钮刷的是**统一刷新**(地图摘要 + 当前模式的面板分区),
  302. 与新鲜度轮询共用 `requestRefresh()` 同一个入口。断言面:
  303. data-refresh-state(idle/running/ok/partial/failed)、
  304. data-refresh-failed(上一轮失败的面板 key,空 = 全成)、aria-busy。
  305. -->
  306. <button
  307. type="button"
  308. class="cockpit-shell__chip cockpit-shell__refresh-action"
  309. :class="{ 'is-refreshing': refreshStore.refreshing }"
  310. data-map-summary-action
  311. data-map-refresh
  312. :data-refresh-state="refreshStore.state"
  313. :data-refresh-failed="refreshStore.failedKeys"
  314. :disabled="refreshStore.refreshing || mapStore.busy"
  315. :aria-busy="refreshStore.refreshing"
  316. :aria-label="refreshStore.text"
  317. :title="refreshStore.text"
  318. @click="requestRefresh()"
  319. >
  320. <span aria-hidden="true" class="cockpit-shell__refresh-glyph">↻</span>
  321. <span v-if="refreshStore.refreshing" class="cockpit-shell__refresh-progress" data-refresh-progress>刷新中</span>
  322. </button>
  323. </div>
  324. <main class="cockpit-shell__main">
  325. <!--
  326. 中央一张图:铺满整个主体背景。常驻——不放在 v-for 内,也不加 v-if/key,
  327. 一级模式切换只重渲染左右两栏,本节点保持原实例。
  328. -->
  329. <section class="cockpit-shell__map" aria-label="中央一张图">
  330. <!--
  331. 票 46:模式图层计划在**外壳**算一次(外壳握有设备行/异常设备/选择态全部输入),
  332. 地图组件只消费计划 —— 模式过滤在 `domain/modeLayerPlan.js` 收口,无第二次过滤。
  333. 引导态(`introVisible`)时计划输出全空:无标记、无图例、无计数浮标、无详情;
  334. 地图摘要仍可预取(mapStore 照常加载)。
  335. -->
  336. <MapCanvas
  337. :mode-label="modeLabel(mode)"
  338. :ui-debug="uiDebug"
  339. :plan="modeLayerPlan"
  340. @pipeline-pick="selectPipeEnhancement"
  341. />
  342. <!--
  343. 票 48:管线颜色图例——中央「一张图」**正下方、水平居中、持久显示**
  344. (不随模式切换/筛选/悬停消失;与顶部状态图例是两条不同的东西,不合并不替换)。
  345. 计数 = `pipeNetworkStore` **全量**口径(不随行业筛选变化,对齐顶部状态图例的
  346. 全局未筛口径立场);图层还没取数时 counts.available=false → 不画计数,不补 0。
  347. 放在地图段内(而非 main 顶层):局部增强窗是本段的兄弟且层级更高,
  348. 窗开着时把图例一并盖住——图例描述的是被窗遮住的那些管线,此刻不该浮在窗上。
  349. -->
  350. <PipeColorLegend :counts="pipeColorCountsView" />
  351. <!-- 实体详情只占中央一张图;按来源栏靠近对应侧边,绝不覆盖侧栏。 -->
  352. <EntityDetailDrawer
  353. v-if="!introVisible && !facilityDetailOpen"
  354. :side="entityDetailSide"
  355. :underground-ready="undergroundReadyForDetail"
  356. @locate-device="locateDeviceFromDetail"
  357. @focus-network="focusNetworkFromDetail"
  358. @open-work-order="openWorkOrderFromDetail"
  359. @open-underground="openUndergroundFromDetail"
  360. />
  361. </section>
  362. <PipeEnhancement
  363. class="cockpit-shell__enhancement"
  364. :plan="pipeEnhancementPlan"
  365. :device-state="enhancementDevicesStore"
  366. :facility-state="enhancementFacilityState"
  367. @object-pick="selectPipeEnhancement"
  368. @facility-retry="retryEnhancementFacility"
  369. @device-pick="enhancementDevicesStore.open"
  370. @devices-reload="enhancementDevicesStore.load(mapStore.summary, { force: true })"
  371. @device-close="enhancementDevicesStore.closeDetail"
  372. @device-retry="enhancementDevicesStore.open(enhancementDevicesStore.selected)"
  373. @radius-change="pipeEnhancementStore.setRadius"
  374. @locate-device="locateDeviceFromDetail"
  375. @close="closePipeEnhancement"
  376. />
  377. <!--
  378. 超宽屏(2026-10-23 维护者):长宽比 ≥ 3:1 时,两侧栏内部由「上下堆叠」改「并排」,
  379. 并且两栏各自退到画面上下、把中间让给一张图。判据用**容器** `aspect-ratio`
  380. 而不是视口 media query —— 驾驶舱跑在微前端宿主里,视口不是本组件的已知量。
  381. -->
  382. <aside class="cockpit-shell__column is-left" aria-label="左栏">
  383. <CockpitPanel
  384. v-for="panelId in columns.left"
  385. :key="panelId"
  386. :panel-id="panelId"
  387. :title="panelTitle(panelId)"
  388. :meta="panelMeta(panelId)"
  389. :meta-align="panelSubtitle(panelId) ? 'end' : ''"
  390. :section="sectionOf(panelId)"
  391. :expanded="isExpanded(panelId)"
  392. :grow="panelGrow(panelId)"
  393. :table-heavy="isTableHeavyPanel(panelId)"
  394. :basis="columnBasis(columns.left)[panelId]"
  395. @toggle="uiStore.togglePanel(panelId)"
  396. >
  397. <PanelBlocks
  398. v-if="hasPanelView(panelId) && !['currentEvents', 'historyAnalysis', 'responseEfficiency', 'eventAnalysis'].includes(panelId)"
  399. :view="panelViewOf(panelId)"
  400. @locate="locateOnMap"
  401. @open-card="openLedgerCard"
  402. @card-action="(action) => handleCardAction(action, panelSideOf(panelId))"
  403. @locate-facility="(action) => handleCardAction(action, panelSideOf(panelId))"
  404. @badge-needed="loadLedgerBadge"
  405. @panel-action="handlePanelAction"
  406. />
  407. <!--
  408. 票 13:当前预警面板挂**事件列表 + 预警/报警切换**(可复用组件)。
  409. 它是自己的组件而不是 PanelBlocks 的块:事件列表的形状(分段切换 +
  410. 表格行)不在 kpi/bars/rows/list 四种块画法里,硬塞进共享渲染层会
  411. 让 PanelBlocks 认识事件字段(票 18 解除的耦合又长回来)。
  412. 票 19 的另外三块面板复用它(同一个 eventStore.mode 切换状态)。
  413. -->
  414. <EventListPane v-else-if="panelId === 'currentEvents'" />
  415. <WarningResponsePane v-else-if="['historyAnalysis', 'responseEfficiency', 'eventAnalysis'].includes(panelId)" :panel-id="panelId" />
  416. <PanelPlaceholder v-else :panel-id="panelId" />
  417. </CockpitPanel>
  418. </aside>
  419. <aside class="cockpit-shell__column is-right" aria-label="右栏">
  420. <CockpitPanel
  421. v-for="panelId in columns.right"
  422. :key="panelId"
  423. :panel-id="panelId"
  424. :title="panelTitle(panelId)"
  425. :meta="panelMeta(panelId)"
  426. :meta-align="panelSubtitle(panelId) ? 'end' : ''"
  427. :section="sectionOf(panelId)"
  428. :expanded="isExpanded(panelId)"
  429. :grow="panelGrow(panelId)"
  430. :table-heavy="isTableHeavyPanel(panelId)"
  431. :basis="columnBasis(columns.right)[panelId]"
  432. @toggle="uiStore.togglePanel(panelId)"
  433. >
  434. <PanelBlocks
  435. v-if="hasPanelView(panelId) && !['currentEvents', 'historyAnalysis', 'responseEfficiency', 'eventAnalysis'].includes(panelId)"
  436. :view="panelViewOf(panelId)"
  437. @locate="locateOnMap"
  438. @open-card="openLedgerCard"
  439. @card-action="(action) => handleCardAction(action, panelSideOf(panelId))"
  440. @locate-facility="(action) => handleCardAction(action, panelSideOf(panelId))"
  441. @badge-needed="loadLedgerBadge"
  442. @panel-action="handlePanelAction"
  443. />
  444. <!--
  445. 票 13:当前预警面板挂**事件列表 + 预警/报警切换**(可复用组件)。
  446. 它是自己的组件而不是 PanelBlocks 的块:事件列表的形状(分段切换 +
  447. 表格行)不在 kpi/bars/rows/list 四种块画法里,硬塞进共享渲染层会
  448. 让 PanelBlocks 认识事件字段(票 18 解除的耦合又长回来)。
  449. 票 19 的另外三块面板复用它(同一个 eventStore.mode 切换状态)。
  450. -->
  451. <EventListPane v-else-if="panelId === 'currentEvents'" />
  452. <WarningResponsePane v-else-if="['historyAnalysis', 'responseEfficiency', 'eventAnalysis'].includes(panelId)" :panel-id="panelId" />
  453. <PanelPlaceholder v-else :panel-id="panelId" />
  454. </CockpitPanel>
  455. </aside>
  456. <!--
  457. 票 10:两级详情浮层(点地图上的监测点打开)。浮在图上、两栏之间;
  458. 它是 `<main>` 的兄弟而不是地图节点的子节点 —— MapCanvas 仍是常驻的那个实例。
  459. 位置与宽度由本外壳给(组件自己不假设身处哪里,票 18 的台账面板可复用同一个卡片)。
  460. 票 46:**选择态暂停**(规格 18)—— 目标模式不显示所选项时详情暂停(隐藏但保留
  461. 选择身份),切回且对象恢复可见时自动恢复;引导态同样不显示。
  462. -->
  463. <div v-if="detailOpen && !introVisible && selectionVisibleInMode && anchorLayout.visible && !fixedLocationReason"
  464. class="cockpit-shell__anchor-lead" data-anchor-lead :style="anchorLeadStyle" aria-hidden="true"></div>
  465. <aside v-if="detailOpen && !introVisible" v-show="selectionVisibleInMode" ref="detailRef" class="cockpit-shell__detail"
  466. :class="{ 'is-anchored': !fixedLocationReason, 'is-fixed-left': facilityFixedLeft }"
  467. :style="detailStyle"
  468. :data-anchor-state="fixedLocationReason ? 'fixed' : anchorLayout.visible ? 'visible' : 'hidden'"
  469. :data-anchor-side="anchorLayout.side"
  470. :data-fixed-side="facilityFixedLeft ? 'left' : 'right'"
  471. :data-anchor-code="selectedDetailCode"
  472. :data-selection-paused="selectionVisibleInMode ? 'no' : 'yes'"
  473. :data-detail-open="String(detailOpen)"
  474. :data-intro-visible="String(introVisible)"
  475. :aria-label="facilityDetailOpen ? '设施详情' : '点位与设备详情'"
  476. :data-facility-anchor-id="facilityDetailOpen ? entityDetailStore.identity.id : null">
  477. <FacilityDetailCard
  478. v-if="facilityDetailOpen"
  479. :location-reason="fixedLocationReason"
  480. :location-hint="facilityPointStore.selectedPoint?.locationHint || ''"
  481. :underground-ready="facilityUndergroundReady"
  482. @locate-device="locateDeviceFromDetail"
  483. @focus-network="focusNetworkFromDetail"
  484. @open-work-order="openWorkOrderFromDetail"
  485. @open-underground="openFacilityUnderground"
  486. />
  487. <PointDetailCard v-else :location-reason="fixedLocationReason" @locate-device="locateDeviceFromDetail" />
  488. </aside>
  489. <aside v-if="eventStore.selectedEvent && uiStore.mode === 'warningResponse' && !introVisible"
  490. class="cockpit-shell__event-detail" aria-label="事件详情" @keydown.esc="eventStore.closeEvent()">
  491. <EventDetailCard />
  492. </aside>
  493. <!--
  494. 票 38(第 5 条):定位反馈浮层。原来它挂在顶部「状态详情」里,而那块**默认收起**——
  495. 点「定位」后失败提示永远看不见,维护者读作「点了没反应」。「没反应」是缺陷,
  496. 所以三种失败(不在已加载范围 / 后端判定不可上图 / 地图未就绪)必须**当场可见**:
  497. 居中底部浮层,自动收起。成功仍不给文字(地图真的会动、详情卡会开,再弹一句是噪音)。
  498. data-locate-result 断言面随它搬到这里,走查仍按该属性取数。
  499. -->
  500. <div v-if="locateFeedback" class="cockpit-shell__notice" data-locate-notice>
  501. <span
  502. class="cockpit-shell__notice-chip cockpit-shell__locate"
  503. :data-locate-result="locateFeedback.result"
  504. role="status"
  505. >
  506. {{ locateFeedback.pointCode }} · {{ locateFeedback.reasonText }}
  507. </span>
  508. <button type="button" class="cockpit-shell__notice-close" data-locate-close @click="dismissLocateFeedback">关闭</button>
  509. </div>
  510. </main>
  511. <!-- 进入引导(票 30):覆盖全屏,点击进入后飞到目标城市预设视角 -->
  512. <CockpitIntro
  513. v-if="intro.enabled && introVisible"
  514. :title="homeFlightPending ? '正在准备地图…' : intro.title"
  515. :subtitle="areaNotice || intro.subtitle"
  516. :spin-seconds="intro.spinSeconds"
  517. @enter="enterSystem"
  518. />
  519. </div>
  520. </template>
  521. <script setup>
  522. import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'
  523. import { storeToRefs } from 'pinia'
  524. import { MODES, columnsForMode, labelForPanel, modeLabel, panelGrow, panelSideFor, panelSubtitle } from './domain/panelCatalog.js'
  525. import { panelView, hasPanelView } from './domain/panelViews.js'
  526. // 票 98:面板视图按输入快照记忆化(模板里每次重渲染都会调 panelViewOf)。
  527. import { createViewMemo } from './domain/panelViewCache.js'
  528. import { CARD_ACTION } from './domain/panelBlocks.js'
  529. // 票 67:全局筛选(当前范围/行业)生效面的**单一措辞来源**(面板口径说明 + 管线图层那句)。
  530. import { PIPE_DISTRICT_NOTE } from './domain/filterCaliber.js'
  531. // 票 65:「预警效率」面板标题随预警/报警切换,词表复用 domain 单一词条。
  532. import { responseEfficiencyTitle } from './domain/warningResponsePanels.js'
  533. // 2026-10-22(票 05–08):overview 新四块不再产生 `link` 面板动作,旧映射表随旧视图退役;
  534. // 唯一的联动是预警类型排行 → 切「预警处置」并做本地类型筛选(见 handlePanelAction)。
  535. import { EVENT_FAMILY } from './domain/events.js'
  536. import { LOCATE_RESULT } from './domain/mapLocate.js'
  537. import { resolveDetailAnchor, resolveFacilityDetailAnchor, detailAnchorLocation } from './domain/detailAnchor.js'
  538. import { solvePointAnchor } from './domain/pointAnchor.js'
  539. import {
  540. overallFreshness,
  541. overallFreshnessText,
  542. sectionStateOf,
  543. viewFromSectionState,
  544. } from './domain/freshnessModel.js'
  545. import { INDUSTRIES, SCOPES, industryQuery, districtQuery, industryIcon } from './domain/filterOptions.js'
  546. import { VIEW_MODES } from './domain/viewModes.js'
  547. import { useUiStore } from './stores/uiStore.js'
  548. import { useFilterStore } from './stores/filterStore.js'
  549. import { usePipeNetworkStore } from './stores/pipeNetworkStore.js'
  550. import { useFacilityPointStore } from './stores/facilityPointStore.js'
  551. import CockpitPanel from './components/CockpitPanel.vue'
  552. import CockpitClock from './components/CockpitClock.vue'
  553. import CockpitIcon from './components/CockpitIcon.vue'
  554. import MapCanvas from './components/MapCanvas.vue'
  555. import PipeEnhancement from './components/PipeEnhancement.vue'
  556. // 票 48:管线颜色图例(一张图正下方居中持久显示;色值/词条/计数全部同源 domain/pipeVisual.js)。
  557. import PipeColorLegend from './components/PipeColorLegend.vue'
  558. // 票 25:地图信息内容块(挂在本外壳的状态面板内,不另起容器)。
  559. import MapInfoPanel from './components/MapInfoPanel.vue'
  560. import PanelPlaceholder from './components/PanelPlaceholder.vue'
  561. import PanelBlocks from './components/PanelBlocks.vue'
  562. import EventListPane from './components/EventListPane.vue'
  563. import EventDetailCard from './components/EventDetailCard.vue'
  564. import EntityDetailDrawer from './components/EntityDetailDrawer.vue'
  565. import WarningResponsePane from './components/WarningResponsePane.vue'
  566. import CockpitIntro from './components/CockpitIntro.vue'
  567. import SectionStateTag from './components/SectionStateTag.vue'
  568. import PointDetailCard from './components/PointDetailCard.vue'
  569. import FacilityDetailCard from './components/FacilityDetailCard.vue'
  570. import { DETAIL_LEVEL } from './domain/detailFlow.js'
  571. import { homeLabel } from './domain/viewPresets.js'
  572. // 2026-10-30 加载优化:契约 mock 样例(约 210KB)只在 mock 模式下动态载入,
  573. // real 模式的首屏不再为一个用不到的样例包付出解析成本。
  574. // 票 14:启动计划(规格 09 的主接缝)——real 与 mock 同构启动,差别只剩 registerMocks。
  575. import { STARTUP_ACTION, planCockpitStartup } from './domain/startupPlan.js'
  576. // 票 41:监测点选择的统一入口(外壳的「重新定位」也走它,不发明第二条定位路径)。
  577. import { selectMonitoringPoint } from './pointSelection.js'
  578. // 票 46:模式图层计划(唯一裁决点)+ 模式切换的选择态语义判定。
  579. import { planModeLayers, planModeSelectionTransition } from './domain/modeLayerPlan.js'
  580. // #13:定位揭示目标**由选择派生**(选择关掉揭示就消失,不再靠一次性选项传递)。
  581. import { deriveLocateReveal } from './domain/locateReveal.js'
  582. // 本票(主场景渐进显示与完整加载):显示就绪门控(区域锁定 + 相机归位 + 至少一帧真实渲染)。
  583. import { DISPLAY_GATE, armDisplayGate, createDisplayGate, disarmDisplayGate, displayReady, observeDisplayGate } from './domain/displayReadiness.js'
  584. import { PIPE_ENHANCEMENT_KIND, planPipeEnhancement } from './domain/pipeEnhancement.js'
  585. import { facilityAsComponent, facilityUndergroundTarget } from './domain/facilityUnderground.js'
  586. import { facilityBelongsToObject, pipeEnhancementFacilityIdentity } from './domain/assetDetailKind.js'
  587. // 票 48:图例计数纯函数(色值/词条/计数与地图管线同源的 domain 单源)。
  588. import { pipeColorCounts } from './domain/pipeVisual.js'
  589. import { usePipeEnhancementStore } from './stores/pipeEnhancementStore.js'
  590. import { useEnhancementDevicesStore } from './stores/enhancementDevicesStore.js'
  591. import { planEnhancementDevices } from './domain/enhancementDevices.js'
  592. import { fetchDeviceFacilityRelations, relationIndex } from './services/deviceFacilityRelations.js'
  593. import { useDetailStore } from './stores/detailStore.js'
  594. import { useDeviceLayerStore } from './stores/deviceLayerStore.js'
  595. import { useInfrastructureStore } from './stores/infrastructureStore.js'
  596. import { useMonitoringStore } from './stores/monitoringStore.js'
  597. import { usePointLocateStore } from './stores/pointLocateStore.js'
  598. import { useDeviceStatusStore } from './stores/deviceStatusStore.js'
  599. import { useEventStore } from './stores/eventStore.js'
  600. import { useEntityDetailStore } from './stores/entityDetailStore.js'
  601. // 2026-10-22(票 02):总体概览模式的四块面板(感知设备/基础设施/预警研判/报警处置)。
  602. // store 仍是票 20 的旧取数实现 —— 新端点的接线归票 05–08,本票先钉身份与画法。
  603. import { useOverviewStore } from './stores/overviewStore.js'
  604. import { useRuntimeStore } from './stores/runtimeStore.js'
  605. import { useMapStore } from './stores/mapStore.js'
  606. import { useRefreshStore } from './stores/refreshStore.js'
  607. import { MAP_OBJECT_KIND, MAP_SUMMARY_PHASE } from './domain/mapSummary.js'
  608. import { getCockpitConfigState, loadCockpitConfig, withUrlDataSourceOverride } from './services/cockpitConfig.js'
  609. import { fetchPumpStationTypeDict } from './services/facilityDictApi.js'
  610. import { loadDictionaries } from './services/cockpitDict.js'
  611. import { fetchWorkOrderList } from './services/detailApi.js'
  612. import { setPumpTypeLabels } from './domain/facilityTypeDict.js'
  613. import {
  614. atHome,
  615. getAreaLimits,
  616. getAreaState,
  617. getFogState,
  618. getLifecycleStats,
  619. getHomeView,
  620. getCameraState,
  621. getPrimaryAreaPlan,
  622. getMapCanvasRect,
  623. getMapMarkerAnchor,
  624. hasMapMarker,
  625. onMapFrame,
  626. onCameraStateChange,
  627. publishPointSelectionHandle,
  628. publishDeviceSelectionHandle,
  629. setPanelSelectionLevel,
  630. getIntroConfig,
  631. // 票 25:底图措辞与数据来源署名(Cesium 署名已移出画面,改由状态面板承担)。
  632. getBasemapLabel,
  633. getDataSourceCredits,
  634. goHome,
  635. isEntryMapPending,
  636. resetToIntroView,
  637. setAreaState,
  638. setGlobeSpin,
  639. setViewMode,
  640. } from './services/mapService.js'
  641. import { AREA_STATE, GLOBAL_IDLE_MS, areaBarActions, shouldReturnToIntro } from './domain/areaLimits.js'
  642. // 视觉 token 的唯一来源(票 06)。挂在本组件根元素上,靠继承作用于驾驶舱子树。
  643. import './styles/tokens.css'
  644. // 票 17(批次 4):字体面按授权门禁注入 —— 门禁不通过的字体不生成 @font-face,
  645. // 于是「无证据字体不可被解析为运行时字体」由结构保证,而非靠约定(规格 11)。
  646. import { fontStatus } from './domain/runtimeAssets.js'
  647. import { installFontFaces } from './domain/fontFaces.js'
  648. // 票 17 第七轮:模式按钮选中态底板 / 选中光晕经语义 key 解析成 CSS 变量注入,
  649. // 组件样式里不出现物理路径(规格 09 的 manifest 唯一入口纪律)。
  650. import { iconFor } from './domain/icons.js'
  651. const uiStore = useUiStore()
  652. const filterStore = useFilterStore()
  653. // 票 24:设施点位与管线是**独立于地图摘要**的一条读取路径(不同业务对象、不同口径),
  654. // 单独一个 store 持有,避免两种对象在同一个 store 里互相污染统计。
  655. const pipeNetworkStore = usePipeNetworkStore()
  656. // 票 68:四类设施点(水厂/泵站/水源地/用水户)是第三条读取路径(设施台账 + 实体详情补坐标),
  657. // 同样独立成 store:设施点不进摘要序列、也不与管线/构件混算。
  658. const facilityPointStore = useFacilityPointStore()
  659. const detailStore = useDetailStore()
  660. const mapStore = useMapStore()
  661. const infrastructureStore = useInfrastructureStore()
  662. const monitoringStore = useMonitoringStore()
  663. const pointLocateStore = usePointLocateStore()
  664. // 维护者 2026-11-04:设备状态池是**全站口径**(顶部状态栏四个模式都常驻),
  665. // 所以它有独立的全局数据源,不挂在「运行监测」的面板分区上。
  666. const deviceStatusStore = useDeviceStatusStore()
  667. const overviewStore = useOverviewStore()
  668. const eventStore = useEventStore()
  669. const entityDetailStore = useEntityDetailStore()
  670. const facilityDetailOpen = computed(() => entityDetailStore.open && entityDetailStore.identity?.kind === 'facility')
  671. /**
  672. * 管线详情视图的「资产详情」页签:设施详情与设备详情并列可选。
  673. *
  674. * 只有设施身份确实属于当前管线选中对象时才喂给面板——否则会把「设施台账里刚点过、
  675. * 但和这条管段无关」的设施串进管线详情(跨上下文串数据比空着更糟)。
  676. */
  677. const enhancementFacilityState = computed(() => {
  678. const identity = entityDetailStore.identity
  679. const object = pipeEnhancementPlan.value?.object
  680. if (!identity || identity.kind !== 'facility' || !object) return { detail: null, loading: false, error: false }
  681. // 归属判据见 domain/assetDetailKind.js:设施 identity.id 是 UUID,
  682. // 3D 对象的 code 是设施编码,只比 code 会永不相等(窨井设施详情因此恒为 null)。
  683. if (!facilityBelongsToObject(identity, object)) return { detail: null, loading: false, error: false }
  684. return {
  685. detail: entityDetailStore.detail,
  686. loading: entityDetailStore.loading === true,
  687. error: Boolean(entityDetailStore.error),
  688. }
  689. })
  690. const runtimeStore = useRuntimeStore()
  691. const statusPanelExpanded = ref(false)
  692. const { mode, expandedPanelIds } = storeToRefs(uiStore)
  693. const { scope, industry, deviceType, viewMode, pointStatus, areaState } = storeToRefs(filterStore)
  694. /**
  695. * 批次 1:行业筛选按钮带上图标(`all` 无图标,渲染时不画)。
  696. * 单独派生一份而不是就地改 `INDUSTRIES` —— 筛选契约本身不带视觉信息。
  697. */
  698. const industryChips = computed(() => INDUSTRIES.map((item) => ({ ...item, icon: industryIcon(item.key) })))
  699. /** 与筛选按钮文字配套的图标边长(走查反馈偏小,由 11 上调)。 */
  700. const industryIconSize = 'calc(14 * var(--u, 1px))'
  701. // ---- 四个已接数据的模式(票 17 基础设施 / 票 18 运行监测 / 票 19 预警处置 / 票 20 总体概览)----
  702. // 16 块面板现已全部接上真实视图;`PanelPlaceholder` 仍是未注册 panelId 的兜底。
  703. const { sections: infrastructureSections } = storeToRefs(infrastructureStore)
  704. const { sections: monitoringSections, badges: monitoringBadges } = storeToRefs(monitoringStore)
  705. // 概览四块的分区(键与 `panelCatalog.js` 的新 panelId 一致;旧合成区随票 02 一并移除)。
  706. const { sections: overviewSections } = storeToRefs(overviewStore)
  707. /**
  708. * 启动已就绪(配置落地且按启动计划执行完首轮取数)——筛选跟随只在这之后生效。
  709. * 票 14:原 `mockReady` 只在 mock 分支置位(real 不取数);同构启动后两种数据源
  710. * 都会置位,改名以如实表达语义。
  711. */
  712. const lifecycleReady = ref(false)
  713. /**
  714. * 面板外框标题(票 65):预警处置「预警效率」面板的标题随预警/报警切换一起换,
  715. * 词表复用 domain 的 `responseEfficiencyTitle`(与面板内部标题同一份,不新增第二张)。
  716. * 其余面板标题仍是静态的 `panelCatalog.js` 中文名。
  717. */
  718. function panelTitle(panelId) {
  719. if (panelId === 'responseEfficiency') return responseEfficiencyTitle(eventStore.mode)
  720. return labelForPanel(panelId)
  721. }
  722. /** 该 panelId 的分区(各 store 各查各的;都没接就回 null)。 */
  723. function sectionOf(panelId) {
  724. // 2026-10-22(票 02):overview 旧四块(含「态势总览」这个合成区)已从目录移除,
  725. // 这里不再有合成特例 —— 新四块各查各的分区,接线归票 05–08。
  726. if (Object.prototype.hasOwnProperty.call(overviewSections.value, panelId)) return overviewSections.value[panelId]
  727. if (Object.prototype.hasOwnProperty.call(infrastructureSections.value, panelId)) return infrastructureSections.value[panelId]
  728. if (Object.prototype.hasOwnProperty.call(monitoringSections.value, panelId)) return monitoringSections.value[panelId]
  729. // 票 19:预警处置四块共享同一个 mode,并各有独立分区状态。
  730. if (['currentEvents', 'historyAnalysis', 'responseEfficiency', 'eventAnalysis'].includes(panelId)) return eventStore.sections[panelId]
  731. return null
  732. }
  733. /** 还没取过数的分区(`sectionOf` 都不认识这个 panelId 时的兜底;正常情况下 store 自带 pending)。 */
  734. function pendingSection() {
  735. return { state: 'empty', reason: '', mode: '', data: null, missing: [], freshness: '', retained: false, loaded: false }
  736. }
  737. /**
  738. * panelId → 算好的视图计划(分发归 `domain/panelViews.js` 的注册表,外壳只做参数搬运)。
  739. *
  740. * **已接数据的面板一定有视图**(哪怕还没取数):domain 的视图计划对 `data: null` 仍返回
  741. * 结构完整的对象,其 `placeholder` 是「正在取数…」。所以「已实现」与「还没实现」由
  742. * `hasPanelView(panelId)` 分辨(那才决定走组件还是走占位),**不由视图在不在分辨** ——
  743. * 早先把两者混起来时,一个已接数据但还在加载的面板会被画成「面板占位 · panelId」,
  744. * 那是在说"这块还没做",与实际不符。
  745. *
  746. * 台账要额外喂一份徽标(票 18 的 N+1),所以只有它多带第三个参数 —— 这是本票唯一的
  747. * "某个面板需要额外输入"的地方,写在壳里比塞进注册表签名更清楚。
  748. */
  749. /**
  750. * 基础档案的设施类型分布(票 06):运行信息九项读数与「基础档案」面板同源。
  751. *
  752. * 为什么不在运行信息端点自己算:运行信息只下发“有指标”的设施,水厂/泵站/水源地会因
  753. * 能力值为空而缺席,拿它计数就是把「后端没给」画成 0。档案目录里是真实计数。
  754. *
  755. * 返回数组引用(不是新对象),让 `panelViewOf` 的记忆化键保持稳定;
  756. * 档案未就绪/失败时回 null —— 面板显示「—」,不补 0。
  757. */
  758. const archiveFacilityTypes = computed(() => {
  759. const archive = infrastructureSections.value.archive
  760. const data = archive && archive.data
  761. return data && Array.isArray(data.facilityTypes) ? data.facilityTypes : null
  762. })
  763. /** 当前是否有行业/片区筛选:档案里缺失的类型,有筛选=0,无筛选=未发布(「—」)。 */
  764. const facilityFilterActive = computed(() => industry.value !== 'all' || scope.value !== 'all')
  765. /** 面板视图缓存:输入快照不变就返回同一个视图对象(子组件 props 稳定 ⇒ 不重渲染)。 */
  766. const panelViewMemo = createViewMemo()
  767. function panelViewOf(panelId) {
  768. if (!hasPanelView(panelId)) return null
  769. const section = sectionOf(panelId) || pendingSection()
  770. /** 台账要额外喂一份徽标(票 18 的 N+1);票 14:监测分布的饼图要喂全局未筛分布与当前选中。 */
  771. // 票 98:这里是**每次重渲染都会被调用**的方法(模板里 `:view="panelViewOf(panelId)"`)。
  772. // 外壳还有 500ms 归位轮询、WS 推送、store 更新等重渲染源 —— 若不记忆化,
  773. // 基础设施/运行监测这两个大视图(块最多、行最大)会被反复整体重建。
  774. // 所以:先用**稳定输入快照**(分区对象/数据对象/几个标量)查缓存,未变就返回同一个视图对象。
  775. // 快照纪律:只放稳定引用或标量;临时对象(如 `{ scope, count }`)必须在 `build` 里现建。
  776. const overview = panelId === 'operationOverview' ? monitoringSections.value.monitoringOverview : null
  777. // 快照用**字段值**而不是分区对象身份:`sectionOf` 认不出的面板会走
  778. // `pendingSection()`,它每次渲染都返回新字面量 —— 拿身份做键会每帧 miss,缓存等于没有。
  779. // 空 `missing` 也折成 null(同一个理由:新字面量里是空数组,引用每帧都不同)。
  780. const inputs = [
  781. section.state,
  782. section.reason,
  783. section.mode,
  784. section.data,
  785. section.missing && section.missing.length ? section.missing : null,
  786. section.freshness,
  787. section.retained,
  788. section.loaded,
  789. // 只有对应面板消费的那一项才进快照(其余位置填 null,保持槽位对齐)。
  790. panelId === 'monitoringPointLedger' ? monitoringBadges.value : null,
  791. panelId === 'monitoringDistribution' ? mapStore.statusDistribution : null,
  792. // 维护者 2026-11-04:状态分布统一到**设备状态池**(全站同源),缓存键必须带上它。
  793. panelId === 'monitoringDistribution' ? deviceStatusStore.pools : null,
  794. panelId === 'operationOverview' ? deviceStatusStore.pools : null,
  795. panelId === 'monitoringDistribution' ? pointStatus.value : null,
  796. panelId === 'operation' ? scope.value : null,
  797. panelId === 'operation' ? archiveFacilityTypes.value : null,
  798. panelId === 'operation' ? facilityFilterActive.value : null,
  799. panelId === 'operationOverview' ? (overview && overview.data ? overview.data.devices : null) : null,
  800. panelId === 'perceptionDevices' ? filterStore.industry : null,
  801. ]
  802. return panelViewMemo.read(panelId, inputs, () => {
  803. let extra
  804. if (panelId === 'monitoringPointLedger') extra = monitoringBadges.value
  805. else if (panelId === 'monitoringDistribution') {
  806. // 维护者 2026-11-04:四卡与状态分布改吃**设备状态池**(全局同源),不再用点位八桶。
  807. extra = {
  808. statusDistribution: mapStore.statusDistribution,
  809. deviceStatusPools: deviceStatusStore.pools,
  810. selectedStatuses: pointStatus.value,
  811. }
  812. }
  813. // 票 64:运行信息要当前**片区**键(换片区 ⇒ 页码回第 1 页,周期刷新 ⇒ 页码保持)。
  814. // 票 06:九项读数取**基础设施档案目录**(与「基础档案」同源);取不到传 null,不造 0。
  815. else if (panelId === 'operation') {
  816. // 票 06:九项读数取基础档案的设施类型分布;filtered 决定缺失类型显示 0 还是「—」。
  817. extra = { scope: scope.value, facilityTypes: archiveFacilityTypes.value, filtered: facilityFilterActive.value }
  818. }
  819. // 票 62:运行概况的设备台账在 `monitoringOverview` 分区(跨分区取数只在这一处搬运)。
  820. else if (panelId === 'operationOverview') {
  821. // 维护者 2026-11-04:运行概况的预警/报警设备也取同一份状态池,三处同数。
  822. extra = {
  823. devices: (overview && overview.data && overview.data.devices) || [],
  824. deviceStatusPools: deviceStatusStore.pools,
  825. }
  826. }
  827. // 票 11:感知设备的类型卡可点,要当前生效行业键画选中态(只传标量)。
  828. else if (panelId === 'perceptionDevices') extra = { industry: filterStore.industry }
  829. return panelView(panelId, section.data, section, extra)
  830. })
  831. }
  832. /**
  833. * 由**专用列表组件**渲染的面板(它们不走 PanelBlocks 的块系统,所以查不到 list 块)。
  834. *
  835. * 这是一张**很短的、以渲染方式为判据**的表,不是"哪些面板内容多"的业务分类:
  836. * 它回答的是"这块是不是由列表组件画的",与 `panelViewOf` 的分派分支一一对应,
  837. * 面板增删时跟着那边一起改(两处都在本文件里,改动可见)。
  838. */
  839. const LIST_COMPONENT_PANELS = ['currentEvents', 'historyAnalysis']
  840. /**
  841. * 同栏每块面板的**高度份额**(`--panel-basis`),维护者 2026-10-23 反馈第 3 条。
  842. *
  843. * 为什么必须在外壳算:份额是"同栏内相对分配",是同栏几块之间的关系 ——
  844. * 单块面板自己看不到兄弟,纯 CSS 也算不出权重和。所以外壳按栏算一次,逐块下发。
  845. *
  846. * 三步(顺序有意义):
  847. * 1. **归一**:以该栏最大权重为基准(权重本身是内容自然高度,可能上万,不能直接当 basis);
  848. * 2. **下限**:任何一块不得低于最大权重块的 `MIN_SHARE_RATIO`(约 0.36)——
  849. * 表格面板打折后不会把另一块压成一条线;
  850. * 3. **失衡上限**:任何一块不得高于最小块的 `MAX_BALANCE_RATIO` 倍 ——
  851. * 表格再长也只占这一比例,同栏另一块始终留得住可观面积。
  852. *
  853. * 返回 0–100 的百分比(CSS flex-basis 直接吃)。
  854. */
  855. const MIN_SHARE_RATIO = 0.36
  856. const MAX_BALANCE_RATIO = 1.75
  857. /** 该栏每块的 basis 份额(panelId → 百分比字符串)。 */
  858. function columnBasis(panelIds) {
  859. if (!Array.isArray(panelIds) || panelIds.length === 0) return {}
  860. const weights = panelIds.map((panelId) => Math.max(1, panelGrow(panelId) || 1))
  861. const top = Math.max(...weights)
  862. const floor = top * MIN_SHARE_RATIO
  863. const balanced = weights.map((weight) => Math.max(weight, floor))
  864. // 失衡上限:最重的那块最多是最轻的 MAX_BALANCE_RATIO 倍。
  865. const lightest = Math.min(...balanced)
  866. const ceiling = lightest * MAX_BALANCE_RATIO
  867. const capped = balanced.map((weight) => Math.min(weight, ceiling))
  868. const sum = capped.reduce((total, weight) => total + weight, 0)
  869. return Object.fromEntries(panelIds.map((panelId, index) => [panelId, `${((capped[index] / sum) * 100).toFixed(2)}%`]))
  870. }
  871. /**
  872. * 面板是否**以表格/清单为主体**(维护者 2026-10-23 反馈第 3 条)。
  873. *
  874. * 判据看**视图里的块**而不是面板身份:有 `list` 块(长清单/台账)就算表格主体。
  875. * 用视图判而不是维护一张"哪些面板是表格"的表 —— 后者会随面板增删漂移,
  876. * 而"这块的内容是不是长清单"本来就能从视图里读出来。
  877. */
  878. function isTableHeavyPanel(panelId) {
  879. // 「当前预警」走 EventListPane 这个专用组件(不是 PanelBlocks 块),视图为 null,
  880. // 只查 blocks 会把它整个漏掉 —— 但它恰恰是这一栏里最"表格"的一块。
  881. // 所以先认这两类**专用列表组件**的面板,再按块判其余。
  882. if (LIST_COMPONENT_PANELS.includes(panelId)) return true
  883. const view = panelViewOf(panelId)
  884. if (!view || !Array.isArray(view.blocks)) return false
  885. return view.blocks.some((block) => block.kind === 'list' || block.kind === 'rows')
  886. }
  887. /**
  888. * 面板标题右侧的提要:有数据的写一句口径摘要;**已接数据但还没取数**写「正在取数」;
  889. * 没实现的写「面板占位」—— 后两者必须分开,否则"正在加载"会被读成"这块还没做"。
  890. *
  891. * 2026-10-22(票 02 · 规格 §6.1):overview 四块的小字是**面板身份**(如「研判分析」),
  892. * 严格照抄、不增删;因此它们优先于数据提要 —— 分区成败仍由标题栏的
  893. * `SectionStateTag` 说(就绪/无数据/过期/失败),两件事各画各的位置。
  894. */
  895. function panelMeta(panelId) {
  896. const subtitle = panelSubtitle(panelId)
  897. if (subtitle) return subtitle
  898. // 票 13:当前预警面板的提要由「事件 + 切换」视图给(条数/状态来自事件分区)。
  899. if (panelId === 'currentEvents') {
  900. const view = eventStore.view
  901. const section = eventStore.sections.currentEvents
  902. if (!section || section.loaded !== true) return '正在取数'
  903. if (!view.hasContent) return '暂无事件'
  904. // 票 61:条数读服务端 total(不由当前页反推);多页时带当前页读数。
  905. const total = view.pagination ? view.pagination.total : view.rows.length
  906. return view.pagination && view.pagination.pageCount > 1
  907. ? `${total} 条事件 · 第 ${view.pagination.page}/${view.pagination.pageCount} 页`
  908. : `${total} 条事件`
  909. }
  910. if (!hasPanelView(panelId)) return '面板占位'
  911. const section = sectionOf(panelId)
  912. if (!section || section.loaded !== true) return '正在取数'
  913. const view = panelViewOf(panelId)
  914. if (!view || !view.hasContent) return '暂无数据'
  915. return `${view.blocks.length} 组读数`
  916. }
  917. /** 定位反馈:取最近一次失败结果(成功时地图与详情卡自己会说话)。 */
  918. const locateFeedback = computed(() => {
  919. const candidates = [pointLocateStore.locate, facilityPointStore.locate].filter((item) => item && item.result)
  920. const latest = candidates.sort((a, b) => (b.at || 0) - (a.at || 0))[0]
  921. return latest && latest.result !== LOCATE_RESULT.OK ? latest : null
  922. })
  923. /** 离开 /cockpit 后不再启动延迟任务(重图层空闲加载可能晚于卸载)。 */
  924. let shellDisposed = false
  925. /**
  926. * 统一登记的延迟回调:视图切换重试、进区/归位重试、900ms 状态刷新等。
  927. * 卸载时一律清掉,避免离开后仍写 store / 操作相机。
  928. */
  929. const deferredTimers = new Set()
  930. function defer(task, ms) {
  931. const id = window.setTimeout(() => {
  932. deferredTimers.delete(id)
  933. if (!shellDisposed) task()
  934. }, ms)
  935. deferredTimers.add(id)
  936. return id
  937. }
  938. function clearDeferredTimers() {
  939. for (const id of deferredTimers) window.clearTimeout(id)
  940. deferredTimers.clear()
  941. }
  942. let spinTimer = null
  943. function clearSpinTimer() {
  944. if (spinTimer !== null) {
  945. window.clearInterval(spinTimer)
  946. spinTimer = null
  947. }
  948. }
  949. /**
  950. * 票 38:反馈浮层自动收起。失败提示要**当场看得见**(不再藏在折叠面板里),
  951. * 但也不能常驻——值班人员接着点下一个点位时,上一条的说明早该走了。
  952. * 定时器随结果变化重建:同一点位重取(result 相同但 pointCode 变)也算一次新反馈。
  953. * 手动「关闭」与自动到点走同一个 `clearLocate`(store 是唯一持有者,壳不自己抹状态)。
  954. */
  955. let locateDismissTimer = null
  956. watch(locateFeedback, (current) => {
  957. if (locateDismissTimer) {
  958. window.clearTimeout(locateDismissTimer)
  959. locateDismissTimer = null
  960. }
  961. if (!current) return
  962. locateDismissTimer = window.setTimeout(() => {
  963. locateDismissTimer = null
  964. pointLocateStore.clearLocate()
  965. infrastructureStore.clearLocate()
  966. facilityPointStore.clearLocate()
  967. }, 8000)
  968. })
  969. function dismissLocateFeedback() {
  970. if (locateDismissTimer) {
  971. window.clearTimeout(locateDismissTimer)
  972. locateDismissTimer = null
  973. }
  974. pointLocateStore.clearLocate()
  975. infrastructureStore.clearLocate()
  976. facilityPointStore.clearLocate()
  977. }
  978. /** 点面板里的可定位对象 → 地图定位(#131:统一走 pointLocateStore)。 */
  979. function locateOnMap(pointCode) {
  980. return pointLocateStore.locateTarget({ kind: 'map-object', code: pointCode })
  981. }
  982. /**
  983. * 票 18:点台账卡片 → 打开与地图**相同**的两级详情。
  984. *
  985. * 监测点/设备沿用各自已有入口;设施台账按维护者追加要求同时定位并打开点旁浮层,
  986. * 与地图设施点点击共用 facilityPointStore.select,不再走历史固定抽屉。
  987. */
  988. /**
  989. * 详情里的「关联设备定位」——统一走 pointLocateStore(#131)。
  990. * 判定、地形感知飞行、打开设备详情、揭示目标都由通用入口承担。
  991. */
  992. async function locateDeviceFromDetail(deviceCode) {
  993. if (facilityDetailOpen.value) entityDetailStore.close()
  994. const result = await pointLocateStore.locateTarget({ kind: 'map-object', code: deviceCode })
  995. // 兜底:定位链在「设备未上图 / 宿主点位取不到」时不会进设备级详情,
  996. // 而用户点这个按钮要的是「看到设备」。这里不依赖定位结果,直接按设备编码补开一次。
  997. /**
  998. * 当前两级详情选择。
  999. *
  1000. * Pinia 的 setup store 会把 ref 解包,所以 `detailStore.selection` 拿到的**已经是对象**;
  1001. * 早先直接写 `const selection = detailStore.selection` 再用 `selection.value.level`,
  1002. * 等于对普通对象取 `.value` —— `detailOpen` 这个 computed 每次渲染都抛 TypeError,
  1003. * 详情浮层的 `v-if` 于是恒为假:定位成功、选择正确,面板却永远不出现(维护者 2026-12-02)。
  1004. * 这里包一层 computed,使之与下游所有 `selection.value.xxx` 的写法一致。
  1005. */
  1006. const selection = computed(() => detailStore.selection || { level: DETAIL_LEVEL.NONE, pointCode: '', deviceCode: '' })
  1007. const opened = selection.value.level === DETAIL_LEVEL.EQUIPMENT && selection.value.deviceCode === deviceCode
  1008. // 兜底时**必须把定位链设好的揭示目标带上**:openDevice 内部会 setLocateTarget(options.locateTarget || null),
  1009. // 传空对象等于把 reveal 清成 null,详情面板的可见性判据随即失去「这是定位目标」的依据而被隐藏
  1010. // (维护者 2026-12-02:定位成功、浮层节点也在,却被 v-show 置成 display:none)。
  1011. if (!opened) await detailStore.openDevice(deviceCode, { locateTarget: detailStore.locateTarget })
  1012. // 定位这条链跨了「摘要 → 设备档案 → 设备图层 → 详情面板」四层,
  1013. // 只飞不动或只开面板不出点时,光看界面分不清断在哪一层。这行把四层的现场一次打出来。
  1014. console.info('[定位设备]', {
  1015. code: deviceCode,
  1016. result: result && result.result,
  1017. reason: result && result.reasonText,
  1018. inSummary: (mapStore.summary.objects || []).some((item) => item && item.code === deviceCode),
  1019. level: detailStore.selection && detailStore.selection.level,
  1020. deviceCode: detailStore.selection && detailStore.selection.deviceCode,
  1021. })
  1022. return result
  1023. }
  1024. /**
  1025. * 详情里的「关联管网聚焦」:复用设施定位入口 ——
  1026. * `resolveFacilityPoint` 对 PIPE_NETWORK 已按 sourceId/networkId 从管线图层解析位置,
  1027. * 所以管网走的就是同一条飞行与高亮链;解析不到时由统一反馈如实说明原因,不静默。
  1028. */
  1029. /**
  1030. * 关联工单只给了工单号,而工单详情是按**数字主键**取的(后端实测按编号请求 400)。
  1031. * 工单列表总量只有几十条,取一页足够大的再按编号匹配出主键即可,不必翻页。
  1032. */
  1033. async function resolveWorkOrderId(workOrderCode) {
  1034. try {
  1035. const section = await fetchWorkOrderList({ page: 1, pageSize: 200 })
  1036. const orders = (section && section.data && section.data.orders) || []
  1037. const hit = orders.find((order) => order.code === workOrderCode)
  1038. return hit && hit.id ? String(hit.id) : ''
  1039. } catch {
  1040. return ''
  1041. }
  1042. }
  1043. /** 详情里的「关联工单」:反查主键后打开只读工单详情(与台账卡同一入口)。 */
  1044. async function openWorkOrderFromDetail(workOrderCode) {
  1045. if (!workOrderCode) return false
  1046. if (facilityDetailOpen.value) entityDetailStore.close()
  1047. const orderId = await resolveWorkOrderId(workOrderCode)
  1048. // 记住来源详情:工单卡点 × 时退回刚才那张隐患/风险详情,而不是一路关掉。
  1049. const back = entityDetailStore.identity ? { ...entityDetailStore.identity } : null
  1050. // 反查不到(工单被删或超出列表范围)时仍按编号打开,由卡片如实说「详情暂未取到」。
  1051. return entityDetailStore.show(
  1052. { kind: 'work-order', id: orderId || workOrderCode },
  1053. orderId ? { orderId } : {},
  1054. back ? { returnTo: back } : {},
  1055. )
  1056. }
  1057. /** 关联信息行 → 对应详情;预警/报警按业务编号,工单优先内部 orderId。 */
  1058. function openRelationFromDetail(item) {
  1059. if (!item || !item.kind) return false
  1060. if (entityDetailStore.open) entityDetailStore.close()
  1061. if (item.kind === 'work-order') {
  1062. const id = item.orderId || item.detailId || item.code
  1063. if (!id) return false
  1064. return entityDetailStore.show({ kind: 'work-order', id: String(id) }, { orderId: String(id) })
  1065. }
  1066. if (item.kind === 'warning' || item.kind === 'alarm') {
  1067. const id = item.detailId || item.code
  1068. if (!id) return false
  1069. const family = item.kind === 'warning' ? 'WARNING' : 'ALARM'
  1070. eventStore.closeEvent()
  1071. return entityDetailStore.show({ kind: 'event', id: String(id), family }, {}, { side: entityDetailStore.sourceSide || 'right' })
  1072. }
  1073. return false
  1074. }
  1075. /**
  1076. * 管段的详情标识。
  1077. *
  1078. * 实测:基础设施详情端点按 **sourceId**(`raw_P4527` 这类)取才 200,
  1079. * 用业务编码(`TCWS202609080346`)取是 404 —— 所以详情必须用图层里的 sourceId。
  1080. * 拿不到 sourceId 时才退回编码(那种情况详情取不到,卡片用 prefill 兜底)。
  1081. */
  1082. function networkEntityId(networkCode) {
  1083. const pipes = (pipeNetworkStore.layer.data && pipeNetworkStore.layer.data.pipes) || []
  1084. const pipe = pipes.find((item) => item && item.code === networkCode)
  1085. return pipe && pipe.sourceId ? String(pipe.sourceId) : networkCode
  1086. }
  1087. /** 管段 → 设施详情卡的 prefill(图层里已有的名称/类型/等级/管径/起止坐标)。 */
  1088. function networkPrefill(networkCode) {
  1089. const pipes = (pipeNetworkStore.layer.data && pipeNetworkStore.layer.data.pipes) || []
  1090. const pipe = pipes.find((item) => item && item.code === networkCode)
  1091. if (!pipe) return null
  1092. const line = Array.isArray(pipe.sourceCoordinates) ? pipe.sourceCoordinates : []
  1093. const first = line[0] || null
  1094. const last = line[line.length - 1] || null
  1095. return {
  1096. code: pipe.code,
  1097. name: pipe.name || pipe.code,
  1098. category: 'PIPE_NETWORK',
  1099. location: pipe.remark || '',
  1100. coordinates: first && last
  1101. ? { longitude: first[0], latitude: first[1], endLongitude: last[0], endLatitude: last[1] }
  1102. : null,
  1103. attributes: {
  1104. networkType: pipe.networkType,
  1105. networkLevel: pipe.networkLevel,
  1106. diameterMillimeters: pipe.diameter,
  1107. remark: pipe.remark,
  1108. },
  1109. }
  1110. }
  1111. /**
  1112. * 关联管网聚焦 = 复用设施那条链的三件事:**打开设施详情卡 + 画出设施图标 + 飞到管段中点**。
  1113. *
  1114. * 为什么不用 `locateFacility`:那条路走 `facilityPointStore.select` 的竞态令牌,
  1115. * 详情关闭或并发选择会把本次调用判成过期并返回 false(表现为「设施定位未完成」)。
  1116. * 这里把三件事拆开各自确定性执行,飞行交给不参与令牌的 `focusFacilityPoint`。
  1117. */
  1118. async function focusNetworkFromDetail(networkCode) {
  1119. if (!networkCode) return false
  1120. if (facilityDetailOpen.value) entityDetailStore.close()
  1121. // 定位点是从管线图层算出来的:图层还没取过就先取一次,否则会落成「尚未取到该管段几何」。
  1122. if (pipeNetworkStore.loaded !== true) {
  1123. try {
  1124. await pipeNetworkStore.load({ industry: industry.value, scope: scope.value })
  1125. } catch {
  1126. // 取不到就让下面的定位把原因如实说出来,不静默。
  1127. }
  1128. }
  1129. // 详情按 sourceId 取(实测按业务编码 404);飞行也用它 —— resolveFacilityPoint 认 sourceId。
  1130. const entityId = networkEntityId(networkCode)
  1131. const identity = { kind: 'facility', id: entityId, category: 'PIPE_NETWORK' }
  1132. // 打开卡片与飞行并行:卡片一打开,设施图标就由 facilityPointStore 的选中点派生出来。
  1133. const [located] = await Promise.all([
  1134. pointLocateStore.focusFacilityPoint(identity, { network: pipeNetworkStore.layer.data }),
  1135. // 只有拿不到 sourceId 时才跳过远端(那种情况确实没有可取的详情)。
  1136. entityDetailStore.show(identity, networkPrefill(networkCode), entityId === networkCode ? { skipRemote: true } : {}),
  1137. ])
  1138. return located
  1139. }
  1140. function openLedgerCard(pointCode) {
  1141. return monitoringStore.openLedgerPoint(pointCode)
  1142. }
  1143. /** 统一实体卡片分派:点位/设备保留成熟链,其余进入统一只读详情抽屉。 */
  1144. function handleCardAction(action, sourceSide = 'right') {
  1145. if (!action || !action.code) return false
  1146. if ([CARD_ACTION.POINT, CARD_ACTION.DEVICE].includes(action.kind)) {
  1147. facilityPointStore.clearLocate()
  1148. if (facilityDetailOpen.value) entityDetailStore.close()
  1149. }
  1150. if (action.kind === CARD_ACTION.POINT) return selectMonitoringPoint(action.code, { mode: mode.value })
  1151. // 维护者 2026-10-29:设备台账卡要像监测点台账一样「定位 + 进设备级详情」。
  1152. // #131:统一走 pointLocateStore,不再另造设备维度定位路径。
  1153. if (action.kind === CARD_ACTION.DEVICE) return pointLocateStore.locateTarget({ kind: 'map-object', code: action.code })
  1154. const row = action.row || {}
  1155. const prefill = row.identityPayload || row
  1156. if (action.kind === CARD_ACTION.EVENT) {
  1157. eventStore.closeEvent()
  1158. return entityDetailStore.show({
  1159. kind: action.kind,
  1160. id: action.code,
  1161. family: row.identityFamily || row.family || eventStore.mode,
  1162. }, prefill, { side: sourceSide })
  1163. }
  1164. if (action.kind === CARD_ACTION.FACILITY) {
  1165. return pointLocateStore.locateTarget({
  1166. kind: 'facility',
  1167. code: action.code,
  1168. category: row.identityCategory || row.category || '',
  1169. facility: { kind: 'facility', id: action.code, category: row.identityCategory || row.category || '' },
  1170. prefill,
  1171. side: sourceSide,
  1172. })
  1173. }
  1174. if ([CARD_ACTION.WORK_ORDER, CARD_ACTION.EMERGENCY].includes(action.kind)) {
  1175. return entityDetailStore.show({
  1176. kind: action.kind,
  1177. id: action.code,
  1178. category: row.identityCategory || row.category || '',
  1179. }, prefill, { side: sourceSide })
  1180. }
  1181. return false
  1182. }
  1183. /**
  1184. * 票 14:监测分布面板的 `filter-status` 出口已随「面板自带筛选入口」一并移除——
  1185. * 状态筛选的唯一入口是地图顶部状态栏(`MapCanvas` 直接写 filterStore),
  1186. * 全局条件只有一个可操作面(决策 02 的 Q19)。
  1187. */
  1188. /** 票 18:台账卡片进视口 → 补拉该点位的设备徽标(Q14 裁定:进视口才拉、逐点位、失败不牵连其它卡片)。
  1189. *
  1190. * 触发点在 `PanelBlocks.vue` 的 `IntersectionObserver`(组件只回答"这张卡露出来了"),
  1191. * 取数与记账在 store —— 组件不认识接口,也不自己发请求。
  1192. */
  1193. function loadLedgerBadge(pointCode) {
  1194. return monitoringStore.loadLedgerBadge(pointCode)
  1195. }
  1196. /**
  1197. * 面板联动接缝(票 20 立,票 37/05–08 复用):渲染层只回答「哪一项被点了」(`{ kind, key }`),
  1198. * **它不认识 panelId、也不认识业务语义**;把 `kind` 翻成动作收在这一处,
  1199. * 与 `panelViews.js` 把 panelId 翻成视图计划是同一个立场。
  1200. *
  1201. * 四种动作:
  1202. * · `industry` —— 写全局行业筛选(基础设施面板的行业行;这里直接写 filterStore,
  1203. * 不再借道 overviewStore 的旧方法 —— 概览四块已不产生这个动作);
  1204. * · `deviceType` —— 写全局设备类型筛选(toggle 语义在 filterStore);
  1205. * · `warningType` —— 预警研判的类型排行 → 切「预警处置」+ 事件列表**本地**按类型筛选(G11);
  1206. * · 其余一律拒绝(不静默吞掉一个认不出的动作)。
  1207. * **没有"地图定位"这一种**:概览四个端点不含点位编码或坐标,落到事件列表才是真实链路。
  1208. * @param {{kind: string, key: string}} action
  1209. */
  1210. function handlePanelAction(action) {
  1211. if (!action) return false
  1212. if (action.kind === 'industry') {
  1213. filterStore.setIndustry(action.key)
  1214. return true
  1215. }
  1216. if (action.kind === 'deviceType') {
  1217. filterStore.toggleDeviceType(action.key)
  1218. return true
  1219. }
  1220. if (action.kind === 'warningType') return focusWarningType(action.key)
  1221. if (action.kind === 'historyType') return focusHistoryType(action.key)
  1222. return false
  1223. }
  1224. /**
  1225. * 概览「预警类型排行」是**近 30 日发生量**,点击落点是预警处置的**历史分析**类型筛选,
  1226. * 不是当前预警(已处理/已解除的类型在当前列表本来就看不到)。
  1227. */
  1228. function focusWarningType(code) {
  1229. const key = typeof code === 'string' ? code.trim() : ''
  1230. if (!key) return false
  1231. uiStore.setMode('warningResponse')
  1232. eventStore.clearWarningTypeFilter()
  1233. eventStore.setHistoryTypeFilter(key, warningTypeLabel(key), EVENT_FAMILY.WARNING)
  1234. void eventStore.loadPanels({ mode: EVENT_FAMILY.WARNING, range: '30d' })
  1235. return true
  1236. }
  1237. /** 预警分析「按事件类型」排行 → 同一条历史分析类型筛选;再点一次取消。 */
  1238. function focusHistoryType(code) {
  1239. const key = typeof code === 'string' ? code.trim() : ''
  1240. if (!key) return false
  1241. if (eventStore.historyTypeFilter && eventStore.historyTypeFilter.code === key) {
  1242. eventStore.clearHistoryTypeFilter()
  1243. return true
  1244. }
  1245. eventStore.setHistoryTypeFilter(key, warningTypeLabel(key), EVENT_FAMILY.WARNING)
  1246. return true
  1247. }
  1248. /** 类型码 → 中文名(从已加载的研判分区里取,取不到就显示码本身 —— 不编一个假名)。 */
  1249. function warningTypeLabel(code) {
  1250. const section = overviewSections.value.warningStudy
  1251. const ranking = (section && section.data && section.data.typeRanking) || {}
  1252. const row = (ranking.top || []).find((item) => item.code === code)
  1253. return (row && row.label) || code
  1254. }
  1255. /** 票 21:视图条件的两个选项(决策地图票 05:全局视图条件,与范围/行业同级)。 */
  1256. const VIEW_MODE_OPTIONS = [
  1257. { key: VIEW_MODES.GROUND, label: '地面视图', hint: '常规俯视;管线隐藏、地形与模型不透明' },
  1258. { key: VIEW_MODES.PIPELINE, label: '管线视图', hint: '压低弹簧臂、放宽俯仰;地形与模型半透明以露出管线' },
  1259. ]
  1260. /**
  1261. * 切换视图:状态先进 store(全局条件,切一级模式不重置),再下发给地图服务。
  1262. * 引擎没就绪时服务返回 false,稍后重试 —— 与「归位」同一套兜底。
  1263. */
  1264. function switchViewMode(next) {
  1265. if (!VIEW_MODE_OPTIONS.some((item) => item.key === next)) return
  1266. filterStore.setViewMode(next)
  1267. // 票 21:倾角/透明度可由 map.viewMode 覆盖(缺省用 domain/viewModes.js 的默认)。
  1268. const mapConfig =
  1269. configState.value && configState.value.config && configState.value.config.map ? configState.value.config.map : null
  1270. const overrides = (mapConfig && mapConfig.viewMode) || {}
  1271. let tries = 0
  1272. const apply = () => {
  1273. tries += 1
  1274. if (setViewMode(next, overrides) || tries >= 40) {
  1275. // 票 37:视图切换会换 range 区间(管线 [400, 6000])并与区域限位取交集,
  1276. // 所以顶栏那条「区内限位 · 最远 N m」要跟着刷新 —— 它是人工核对三处交集的读数。
  1277. areaLimits.value = getAreaLimits()
  1278. return
  1279. }
  1280. defer(apply, 250)
  1281. }
  1282. apply()
  1283. }
  1284. const { sections, selection } = storeToRefs(detailStore)
  1285. // ---- 票 42:关联监测设备临时图层 ----
  1286. //
  1287. // 本层是**合成点**:它读 mapStore 的当前快照 `deviceCodes`(总数依据)与 detailStore 的点位详情
  1288. // `devices[]`(状态与设备级坐标),按 `domain/deviceLayer.js` 判定,再由地图服务画到独立图层。
  1289. // 外壳负责三类触发(缺一条都会让图层停在过期状态):
  1290. // ① **选择变化**:换点/关闭 → 立即重算(关闭时无点位级选择 ⇒ 撤下图层);
  1291. // ② **详情到达**:设备级坐标与状态来自详情,它回来之前设备只能是「待确认」;
  1292. // ③ **快照变化**:刷新/筛选重载/快照失效 → **先撤下旧图层**再等新的(规格明写,不许留旧数据)。
  1293. const deviceLayerStore = useDeviceLayerStore()
  1294. const { rows: deviceRows, counts: deviceCounts, legend: deviceLegend, notice: deviceNotice } = storeToRefs(deviceLayerStore)
  1295. /** 最近一次「已撤下旧图层」对应的快照标记(同一个快照不重复撤,避免翻页时把图层打没)。 */
  1296. let deviceSnapshotSeen = ''
  1297. /**
  1298. * 票 42(规格 14:刷新核对链)——外壳持有的**核对状态**:
  1299. * · `snapshotPending`:刷新/失效发起后、核对收口前,设备图层挂起 + 顶栏「待核对」;
  1300. * · `snapshotAbsentNote`:完整加载仍找不到所选点位 → 详情已关闭,顶栏说明原因。
  1301. * 挂起与收口由下方三个监听驱动(发起 / 失效相位 / settled)。
  1302. */
  1303. const snapshotPending = ref(false)
  1304. const snapshotAbsentNote = ref('')
  1305. /**
  1306. * 票 14:设备级筛选(行业/范围/类型)是否生效——生效时 map-snapshot 的 `deviceCodes`
  1307. * 是**命中设备子集**,详情独有按「未命中当前筛选」归类(另有 N 台),而非快照不一致。
  1308. * 状态筛选不算:它作用在对象状态上,不裁剪点位的设备清单。
  1309. */
  1310. const deviceFilterActive = computed(
  1311. () => industryQuery(industry.value) !== '' || districtQuery(scope.value) !== '' || String(deviceType.value || '').trim() !== '',
  1312. )
  1313. /**
  1314. * 当前定位揭示目标(#13):**由选择派生**,不是由定位链传下来的一次性选项。
  1315. *
  1316. * 选择是「用户正在看谁」的唯一真相;揭示只是它的投影。于是:
  1317. * 关闭详情 → 选择清空 → 揭示自动消失;定位完成后数据到达 → 揭示自动补上。
  1318. * 原先读 `detailStore.locateTarget`(会被关闭/返回/切模式/改图例清空)的链路正是
  1319. * 「定位成功之后图标与锚定又没了」的成因。
  1320. *
  1321. * 兜底仍保留一次性记录:坐标只在设备档案里(要异步取)时,派生拿不到,
  1322. * 但定位链当场已经把那一行交过来了。
  1323. */
  1324. const locateReveal = computed(() => deriveLocateReveal({
  1325. selection: selection.value,
  1326. objects: mapStore.summary.objects,
  1327. pointDetail: sections.value.pointDetail && sections.value.pointDetail.data,
  1328. }) || detailStore.locateTarget || null)
  1329. function syncDeviceLayer(options = {}) {
  1330. // 票 46:`entered` 跟随引导态 —— 进入前关联设备图层整体不呈现(规格 18 的引导列)。
  1331. // 票 45:重叠展开阈值来自 `map.overlap.maxFan`,未配置时用规格默认 10。
  1332. const mapConfig = configState.value && configState.value.config && configState.value.config.map
  1333. const maxFan = options.maxFan || (mapConfig && mapConfig.overlap && mapConfig.overlap.maxFan) || 10
  1334. // #135:关联设备定位时,宿主点位可能被当前模式隐藏;设备图层仍要按揭示目标常驻,
  1335. // 否则 parentVisible=false 会把刚补出来的设备点又撤掉(表现就是“定位成功但图标丢失”)。
  1336. const reveal = locateReveal.value
  1337. const revealParent = Boolean(reveal && reveal.deviceCode && reveal.code === selection.value.pointCode)
  1338. return deviceLayerStore.syncForSelection({
  1339. ...options,
  1340. mode: mode.value,
  1341. entered: displayEntered.value,
  1342. parentVisible: !selection.value.pointCode || revealParent || [...modeLayerPlan.value.markers, ...modeLayerPlan.value.blocked]
  1343. .some((item) => item.code === selection.value.pointCode),
  1344. maxFan,
  1345. filterActive: deviceFilterActive.value,
  1346. // #131:关联设备定位时把揭示目标(含设备自身坐标)交给设备图层,正常/离线也能临时上图。
  1347. //
  1348. // 揭示目标由**选择派生**(见上方 locateReveal):关闭详情就自动消失,
  1349. // 不再依赖"谁记得清 / 谁记得再写一次"。
  1350. revealDevice: reveal,
  1351. })
  1352. }
  1353. /**
  1354. * 票 46:**异常设备集**(规格 18 的输入)。
  1355. *
  1356. * 来源是 `/monitoring/situation` 的 `abnormalEquipment[]`(运行监测「运行概况」面板的数据,
  1357. * `monitoringStore.sections.operationOverview`)—— 那是**设备状态事实**,不是监测点聚合状态。
  1358. * 它与 `map-snapshot` 跨端点:数据没取到时给 `null`(计划层会输出降级说明,不猜异常点)。
  1359. */
  1360. const modeAbnormalDevices = computed(() => {
  1361. const section = monitoringSections.value.operationOverview
  1362. const data = section && section.data
  1363. return data && Array.isArray(data.abnormalEquipment) ? data.abnormalEquipment : null
  1364. })
  1365. // ---- 进入引导与视角预设(票 30)——声明上移至此 ----
  1366. // 原位置在下方「进入引导与视角预设」分节;因管线增强 watch(票 24/47)在 setup 期
  1367. // 急切读取 `modeLayerPlan`(其 computed 引用 `introVisible`),声明晚于该 watch 会触发
  1368. // TDZ(ReferenceError: Cannot access 'introVisible' before initialization,整壳挂掉)。
  1369. // 声明只依赖 `getIntroConfig()`(顶部 import),上移安全;分节的其余内容仍在原处。
  1370. const intro = ref(getIntroConfig())
  1371. const introVisible = ref(intro.value.enabled)
  1372. /**
  1373. * 本票(主场景渐进显示)显示就绪门控:业务标记不再只看「是否离开引导态」,
  1374. * 而要等「区域锁定 + 相机真正归位 + 至少一帧真实渲染」都满足后才释放首批
  1375. * (判定与相位见 domain/displayReadiness.js)。引导关闭(走查自隔离)时没有地球视角
  1376. * 可等,维持旧的「进入即显示」,不改变既有走查行为。
  1377. */
  1378. const displayGate = ref(createDisplayGate())
  1379. const displayEntered = computed(() => (intro.value.enabled ? displayReady(displayGate.value) : true))
  1380. /**
  1381. * 票 46:**唯一**的模式图层计划(规格 18:引擎和组件只消费计划,不做第二次过滤)。
  1382. *
  1383. * 在外壳算一次(外壳是唯一同时握有 mapStore 对象、设备行、异常设备与选择态的层),
  1384. * 地图组件、图例、详情暂停都只读这一份:
  1385. * · `markers/legend` → MapCanvas(图例与标记同源,只统计本模式可见的标记);
  1386. * · `selection.visible` → 详情浮层的**暂停/恢复**(目标模式不显示所选项时隐藏但保留选择);
  1387. * · `degradedNotes` → 「设施/管线/异常设备数据未就绪」的如实说明。
  1388. */
  1389. const pipeEnhancementStore = usePipeEnhancementStore()
  1390. const enhancementDevicesStore = useEnhancementDevicesStore()
  1391. const { selected: pipeEnhancementSelection, radiusM: pipeEnhancementRadius } = storeToRefs(pipeEnhancementStore)
  1392. /**
  1393. * 管段选中 → 现取一次「管道详情」(维护者 2026-11-16)。
  1394. *
  1395. * 用 `watch` 而不是只挂在点击处理函数上:3D 里的管段可以从多条路径被选中
  1396. * (管线拾取、附近管道列表、外部的 `pipeEnhancementStore.select`),
  1397. * 挂在单一入口必漏。取数沿用 `facilityPointStore.select`(同一条只读详情端点)。
  1398. *
  1399. * 取数主键用 `sourceId` 而不是 `code`:几何里管段
  1400. * `properties.code` 是业务编码、`properties.sourceId` 才是 `pipe_network_base` 主键,
  1401. * 拿编码去查详情会 404(实测 TCRQ202609080001 → raw_P11920)。
  1402. * `pipeEnhancementFacilityIdentity()` 负责从选中对象或可见管线里补出主键。
  1403. */
  1404. watch(
  1405. () => `${pipeEnhancementSelection.value?.kind || ''}|${pipeEnhancementSelection.value?.code || ''}`,
  1406. () => {
  1407. const identity = pipeEnhancementFacilityIdentity(
  1408. pipeEnhancementSelection.value,
  1409. pipeNetworkStore.pipelines?.value ?? pipeNetworkStore.pipelines ?? [],
  1410. )
  1411. if (!identity) return
  1412. const current = entityDetailStore.identity
  1413. // 同一管段已取过就不重复请求(半径/筛选变化会反复触发本 watch)。
  1414. if (current && String(current.kind) === 'facility'
  1415. && String(current.category) === identity.category
  1416. && String(current.id) === identity.id) return
  1417. facilityPointStore.select(identity, null, { side: 'right' })
  1418. },
  1419. { immediate: true },
  1420. )
  1421. /** 选中的图例行 → 命中的设备编码集(与图例同一份设备台账;空集=不筛)。 */
  1422. const deviceFilter = computed(() => deviceStatusStore.filterDeviceCodes(pointStatus.value))
  1423. /**
  1424. * 设备标签事实(#127):基础属性 + 可叠加标签,交给模式计划解析显示状态。
  1425. * 池未就绪时传 null,计划层回退对象自身 `status`——不拿未知标签冒充可见。
  1426. */
  1427. const modeDeviceFacts = computed(() => {
  1428. const pools = deviceStatusStore.pools
  1429. return pools && pools.available ? pools.devices : null
  1430. })
  1431. /**
  1432. * 交给计划层的定位揭示目标(#127):与设备图层同源,都读**选择派生**的 `locateReveal`。
  1433. * 只把「目标本身是摘要对象」的情况交给计划层;关联设备揭示的是宿主点位标记,
  1434. * 仍由设备层按标签状态着色。
  1435. */
  1436. const modeLocateTarget = computed(() => {
  1437. const target = locateReveal.value
  1438. if (!target || !target.code) return null
  1439. const onMap = (mapStore.summary.objects || []).some((object) => object && object.code === target.code)
  1440. return onMap ? { code: target.code, deviceCode: target.deviceCode || '' } : null
  1441. })
  1442. const modeLayerPlan = computed(() => planModeLayers({
  1443. mode: mode.value,
  1444. objects: mapStore.summary.objects,
  1445. abnormalDevices: modeAbnormalDevices.value,
  1446. // 维护者 2026-11-05:状态筛选按**设备标签**过滤地图对象,与图例计数同口径。
  1447. deviceFilter: deviceFilter.value,
  1448. // #127:模式可见性/显示状态消费标签事实;定位目标临时揭示。
  1449. deviceFacts: modeDeviceFacts.value,
  1450. locateTarget: modeLocateTarget.value,
  1451. // 票 24:设施点位与管线接真实图层。取不到时由 store 收成失败分区,
  1452. // 计划如实降级为「未就绪」——不再传 `null` 假装"还没接线"。
  1453. // 过滤只在这一层做(`pipeNetworkStore.filtered`),引擎与组件都不做第二次过滤。
  1454. facilities: pipeNetworkStore.facilities,
  1455. pipelines: pipeNetworkStore.pipelines,
  1456. // 票 68:设施点图层(水厂/泵站/水源地/用水户)。筛选同样只在这一层做:
  1457. // 设施类型(独立维度)+ 全局行业/片区;点位/设备状态筛选不作用于本图层。
  1458. facilityPoints: facilityPointStore.renderPoints,
  1459. associatedDevices: deviceRows.value,
  1460. selection: {
  1461. level: selection.value.level,
  1462. pointCode: selection.value.pointCode,
  1463. deviceCode: selection.value.deviceCode,
  1464. },
  1465. entered: displayEntered.value,
  1466. }))
  1467. // 模式/图例筛选变化:定位揭示必须收场,旧目标不能越过新筛选继续强制显示。
  1468. watch([mode, pointStatus], () => {
  1469. detailStore.clearLocateTarget()
  1470. if (selection.value.pointCode) syncDeviceLayer({ force: true })
  1471. })
  1472. // 设备状态池到达/刷新:关联设备图层按「基础属性 + 标签」显示状态重算。
  1473. // 选中点位时设备池可能还没回来;池到达后不能停在旧的单一状态上。
  1474. watch(() => deviceStatusStore.pools, () => {
  1475. if (selection.value.pointCode) syncDeviceLayer()
  1476. })
  1477. /**
  1478. * 当前打开的设施在**地图标记行**里的那一行(含经纬度与类型)。
  1479. *
  1480. * 为什么要回查标记行:`entityDetailStore.detail` 只有详情字段,坐标在
  1481. * `facilityPointStore` 的标记行上。两者按「类别 + 主键」对上,不按编码猜。
  1482. */
  1483. const currentFacilityRow = computed(() => {
  1484. if (!facilityDetailOpen.value) return null
  1485. const identity = entityDetailStore.identity || {}
  1486. const rows = facilityPointStore.points?.value ?? facilityPointStore.points ?? []
  1487. const category = String(identity.category || "").toUpperCase()
  1488. const id = String(identity.id || "")
  1489. const row = (Array.isArray(rows) ? rows : []).find((item) => item
  1490. && String(item.type || "").toUpperCase() === category
  1491. && String(item.id || "") === id)
  1492. return row || null
  1493. })
  1494. /** 当前设施转成的 3D 构件(只有窨井这类有模型的才非空)。 */
  1495. const undergroundFacilityComponent = computed(() => facilityAsComponent(currentFacilityRow.value))
  1496. /** 设施能否进「地下管线详情视图」:只看自身有没有可渲染的 3D 模型与坐标。 */
  1497. /**
  1498. * 设施卡上的「查看详情」是否可用。
  1499. *
  1500. * 常规设施靠「能不能定位到一条真实可见的管段」判定;但管网聚焦打开的就是这张设施卡,
  1501. * 而管段不在设施点图层里,currentFacilityRow 恒为空 —— 所以补一条按实体身份判定的分支,
  1502. * 否则管网详情永远看不到这个入口(维护者 2026-12-02)。
  1503. */
  1504. const facilityUndergroundReady = computed(() => {
  1505. if (facilityUndergroundTarget(currentFacilityRow.value)) return true
  1506. return Boolean(entityDetailStore.identity && entityDetailStore.identity.category === 'PIPE_NETWORK')
  1507. })
  1508. /** 实体详情抽屉里的地下设施能否进「地下管线详情视图」:管网一定能(按管段编码选中),窨井沿用设施判定。 */
  1509. const undergroundReadyForDetail = computed(() => {
  1510. const category = entityDetailStore.identity && entityDetailStore.identity.category
  1511. if (category === 'PIPE_NETWORK') return true
  1512. return category === 'MANHOLE' && facilityUndergroundReady.value
  1513. })
  1514. /**
  1515. * 设备→设施真实关联索引(维护者 2026-10-22 批准的后端契约)。
  1516. *
  1517. * 后端 `GET /api/cockpit/v1/equipments/facility-relations` 只按真实主键解析出 `deviceCode` 的行;
  1518. * 当前库数据下通常为空(关联表存的是设备 id、管点 network_id 悬空、equipment_id 查不到),
  1519. * 因此这里拿到空 Map 属**正常降级**,界面继续标「邻近设备 · 示意安装」,不伪报真实绑定。
  1520. */
  1521. const facilityRelations = ref(new Map())
  1522. const facilityRelationsState = ref({ state: 'idle', loaded: false })
  1523. async function loadFacilityRelations() {
  1524. try {
  1525. const section = await fetchDeviceFacilityRelations()
  1526. facilityRelations.value = relationIndex(section)
  1527. facilityRelationsState.value = { state: section.state, loaded: true }
  1528. } catch {
  1529. facilityRelations.value = new Map()
  1530. facilityRelationsState.value = { state: 'failed', loaded: true }
  1531. }
  1532. }
  1533. const pipeEnhancementPlan = computed(() => {
  1534. const plan = planPipeEnhancement({
  1535. selected: pipeEnhancementSelection.value,
  1536. radiusM: pipeEnhancementRadius.value,
  1537. visiblePipes: modeLayerPlan.value.pipelines,
  1538. // 窨井(维护者 2026-11-16):设施自己有 3D 模型(井筒+井盖),
  1539. // 必须作为构件进入可见集合,否则 3D 视图里只有周边管线、没有它自己。
  1540. visibleComponents: [
  1541. ...modeLayerPlan.value.facilities,
  1542. ...(undergroundFacilityComponent.value ? [undergroundFacilityComponent.value] : []),
  1543. ],
  1544. })
  1545. return { ...plan, ...planEnhancementDevices(plan, enhancementDevicesStore.source.rows, {
  1546. mode: mode.value, abnormalDevices: modeAbnormalDevices.value, facilityRelations: facilityRelations.value,
  1547. }),
  1548. deviceCoverage: enhancementDevicesStore.source,
  1549. relationCoverage: facilityRelationsState.value }
  1550. })
  1551. watch(() => JSON.stringify(pipeEnhancementSelection.value), () => enhancementDevicesStore.closeDetail())
  1552. watch(pipeEnhancementRadius, () => enhancementDevicesStore.closeDetail())
  1553. // Explicit filters/mode changes are a new scope; do not retain the old scope's local devices.
  1554. watch(() => JSON.stringify([mode.value, scope.value, industry.value, deviceType.value, pointStatus.value]),
  1555. () => enhancementDevicesStore.clear(), { flush: 'sync' })
  1556. // 首次打开详情视图时取一次真实关联(只读、免认证);失败按空索引降级,绝不阻塞场景。
  1557. watch(() => pipeEnhancementPlan.value.visible, (visible) => {
  1558. if (visible && !facilityRelationsState.value.loaded) void loadFacilityRelations()
  1559. })
  1560. watch(() => pipeEnhancementPlan.value.deviceList, (list) => {
  1561. if (!mapStore.refreshing) enhancementDevicesStore.reconcile(list)
  1562. })
  1563. watch(() => mapStore.refreshing, (refreshing) => {
  1564. if (refreshing) enhancementDevicesStore.invalidate()
  1565. else if (pipeEnhancementPlan.value.visible) void enhancementDevicesStore.load(mapStore.summary)
  1566. }, { flush: 'sync' })
  1567. watch(() => [pipeEnhancementSelection.value, modeLayerPlan.value.pipelines, modeLayerPlan.value.facilities,
  1568. mapStore.summary.batchUpdatedAt, mapStore.summary.phase, mapStore.summary.objects], () => {
  1569. if (mapStore.refreshing) return
  1570. if (pipeEnhancementPlan.value.visible) void enhancementDevicesStore.load(mapStore.summary)
  1571. else enhancementDevicesStore.clear()
  1572. })
  1573. /**
  1574. * 票 48:管线颜色图例的计数(`pipeColorCounts()` 的视图入口)。
  1575. *
  1576. * 读 `pipeNetworkStore.layer.data` 的**全量**图层(不读 `filtered`):
  1577. * 图例回答的是「图上这类颜色是什么」,计数不随行业筛选变化——与顶部状态图例
  1578. * 「计数=全局未筛全集」的既定立场(决策 02)同一条纪律。图层没取数/取数失败时
  1579. * `data` 为 null → `available:false` → 图例各行不画计数(不补 0)。
  1580. */
  1581. const pipeColorCountsView = computed(() => pipeColorCounts(pipeNetworkStore.layer.data))
  1582. /**
  1583. * 当前设施能否下钻到「地下管线详情视图」(维护者 2026-11-16)。
  1584. *
  1585. * 判据收在 `domain/facilityUnderground.js`:设施要能定位到一条**真实可见的管段**
  1586. * (窨井/排水设施用详情里的 networkId,管线用自身编码)。定位不到就不画按钮 ——
  1587. * 画了就是「点了必然失败」的入口。
  1588. */
  1589. /** 「查看详情」:选中关联管段,既有三维视图随之打开(不新建第二条渲染链)。 */
  1590. /**
  1591. * 详情卡里的「查看详情 →」:进「地下管线详情视图」。
  1592. *
  1593. * 管网没有设施点行(走的是实体详情抽屉),所以直接按管段编码选中三维视图;
  1594. * 其它地下设施仍走原有判定(要有可渲染的 3D 模型与坐标)。
  1595. */
  1596. function openUndergroundFromDetail() {
  1597. if (openNetworkUnderground()) return
  1598. openFacilityUnderground()
  1599. }
  1600. /**
  1601. * 管网进地下视图:select 认的是**管段业务编码**,而实体详情的 identity.id 是 sourceId(raw_*),
  1602. * 所以取详情里的业务编码,退不到才用 identity.id。
  1603. */
  1604. function openNetworkUnderground() {
  1605. const identity = entityDetailStore.identity
  1606. if (!identity || identity.category !== 'PIPE_NETWORK') return false
  1607. const code = (entityDetailStore.detail && entityDetailStore.detail.displayCode) || identity.code || identity.id
  1608. if (!code) return false
  1609. pipeEnhancementStore.select(PIPE_ENHANCEMENT_KIND.PIPE, code)
  1610. return true
  1611. }
  1612. function openFacilityUnderground() {
  1613. const target = facilityUndergroundTarget(currentFacilityRow.value)
  1614. if (target) {
  1615. pipeEnhancementStore.select(target.kind, target.code)
  1616. return
  1617. }
  1618. // 设施卡由管网聚焦打开时没有设施点行,改按实体详情身份进地下视图。
  1619. openNetworkUnderground()
  1620. }
  1621. function selectPipeEnhancement(hit) {
  1622. const kind = hit && hit.objectKind === 'component'
  1623. ? PIPE_ENHANCEMENT_KIND.COMPONENT
  1624. : hit && hit.objectKind === 'pipe'
  1625. ? PIPE_ENHANCEMENT_KIND.PIPE
  1626. : ''
  1627. if (!kind) return
  1628. pipeEnhancementStore.select(kind, hit.code)
  1629. loadPipeAssetDetail(kind, hit.code)
  1630. }
  1631. /**
  1632. * 管段选中时按自己的链现取一次「管道详情」(维护者 2026-11-16)。
  1633. *
  1634. * 为什么窨井不用这一步:窨井从设施点链进来,`entityDetailStore` 已有详情,
  1635. * 3D 视图按主键认回即可。管段从管线拾取链进来,`entityDetailStore` 从未被填充,
  1636. * 资产详情因此恒空 —— 这就是「井盖能显示、管道不显示」的根源。
  1637. *
  1638. * 详情取数沿用既有的 `facilityPointStore.select`(同一条 `/infrastructure/entities/{id}/detail` 只读端点),
  1639. * 不新造取数路径;失败按既有降级(资产详情显示取数提示,不阻塞 3D 场景)。
  1640. */
  1641. function loadPipeAssetDetail(kind, code) {
  1642. const identity = pipeEnhancementFacilityIdentity({ kind, code })
  1643. if (!identity) return
  1644. const current = entityDetailStore.identity
  1645. // 同一个管段已经取过就不重复请求(切换半径/筛选时会被反复触发)。
  1646. if (current && String(current.kind) === 'facility'
  1647. && String(current.category) === identity.category
  1648. && String(current.id) === identity.id) return
  1649. facilityPointStore.select(identity, null, { side: 'right' })
  1650. }
  1651. /** 资产详情页签的设施重试:沿用实体详情的既有重试入口,不另造取数路径。 */
  1652. function retryEnhancementFacility() {
  1653. if (entityDetailStore.identity?.kind === 'facility') entityDetailStore.retry()
  1654. }
  1655. function closePipeEnhancement() {
  1656. pipeEnhancementStore.clear()
  1657. enhancementDevicesStore.clear()
  1658. }
  1659. // Only a background refresh of the same viewing context may retain its visibility/anchor.
  1660. const detailViewKey = computed(() => JSON.stringify([mode.value, scope.value, industry.value, deviceType.value, pointStatus.value,
  1661. selection.value.level, selection.value.pointCode, selection.value.deviceCode, entityDetailStore.identity]))
  1662. const detailRefreshState = ref(null)
  1663. const keepDetailDuringRefresh = computed(() => detailRefreshState.value?.key === detailViewKey.value)
  1664. watch(detailViewKey, () => { detailRefreshState.value = null }, { flush: 'sync' })
  1665. const selectionVisibleInMode = computed(() => keepDetailDuringRefresh.value ? detailRefreshState.value.visible
  1666. : facilityDetailOpen.value ? ['overview', 'infrastructure'].includes(mode.value)
  1667. : modeLayerPlan.value.selection.visible === true)
  1668. /**
  1669. * 快照变化 → 先撤下旧设备图层(规格:刷新或快照失效时先撤下,免得旧快照的设备被误读成新范围的)。
  1670. * **同一个标记不重复撤**:翻页时标记不变,此时若也撤,会把正在看的设备层打没
  1671. * —— 那正是规格禁止的「同一快照翻页造成闪烁」。
  1672. *
  1673. * 用 `batchUpdatedAt` 而不是 `summary.snapshot` 作判据:两者是同一份合并态里同批更新的
  1674. * 等价标记(见 `domain/mapSummary.js` 的 `mergeMapPage`),但 `snapshot` 那个**字段名**
  1675. * 会被 t08 的 H1 守卫命中 —— 该守卫查的是「界面不得出现分页/快照的**接口参数名**」
  1676. * (票 08 验收第 2 条)。我不放宽守卫,改用不含该字样的等价字段。
  1677. */
  1678. function syncDeviceLayerForSnapshot(batchUpdatedAt) {
  1679. const current = batchUpdatedAt || ''
  1680. if (current && current === deviceSnapshotSeen) return
  1681. deviceSnapshotSeen = current
  1682. deviceLayerStore.invalidateForSnapshot({ filterActive: deviceFilterActive.value })
  1683. syncDeviceLayer({ force: true })
  1684. }
  1685. /**
  1686. * 票 42(规格 14:刷新核对链):快照链 settled 后对「挂起中的所选点位」做一次核对。
  1687. *
  1688. * 三种收口,全部是规格 14:86 的原句:
  1689. * · **找到**(含被护栏截掉的前部页——用装载器的全页索引,不用合并态当证据):
  1690. * 强制重取点位摘要(保留选择层级),设备图层经既有监听自行恢复;
  1691. * · **确认无地图位置**:固定详情由既有 `fixedLocationReason` 呈现,无需额外处理;
  1692. * · **完整加载仍找不到**:关闭详情并在顶栏说明原因。
  1693. * 查找失败(failed 相位)**保持待核对**:已取数据与顶栏关闭入口都在,允许再次刷新重试。
  1694. */
  1695. async function reconcileSnapshotSelection() {
  1696. // A reload can pass through an empty/settled state before the current chain completes.
  1697. if (mapStore.refreshing) return
  1698. const { pointCode, deviceCode, level } = selection.value
  1699. if ((!pointCode && !deviceCode) || level === 'none') {
  1700. snapshotPending.value = false
  1701. detailRefreshState.value = null
  1702. return
  1703. }
  1704. const phase = mapStore.summary.phase
  1705. if (phase === MAP_SUMMARY_PHASE.FAILED || phase === MAP_SUMMARY_PHASE.EXPIRED) return
  1706. const kind = pointCode ? 'monitoring-point' : 'unassociated-equipment'
  1707. const code = pointCode || deviceCode
  1708. if (mapStore.hasSnapshotObject(kind, code)) {
  1709. snapshotPending.value = false
  1710. const retained = detailRefreshState.value
  1711. const results = await Promise.all([
  1712. pointCode ? detailStore.reloadPointDetail(pointCode) : null,
  1713. deviceCode ? detailStore.loadEquipmentAggregate(deviceCode) : null,
  1714. ])
  1715. // Let the point-detail watcher restore its device layer before releasing the old anchor.
  1716. await nextTick()
  1717. if (detailRefreshState.value === retained && !mapStore.refreshing
  1718. && results.every((result) => !result || (!result.retained && !['failed', 'unavailable'].includes(result.state)))) detailRefreshState.value = null
  1719. return
  1720. }
  1721. if (phase === MAP_SUMMARY_PHASE.COMPLETE || phase === MAP_SUMMARY_PHASE.EMPTY) {
  1722. snapshotPending.value = false
  1723. detailRefreshState.value = null
  1724. snapshotAbsentNote.value = `所选${pointCode ? '点位' : '设备'} ${code} 已不在当前快照范围,详情已关闭`
  1725. detailStore.closeDetail()
  1726. }
  1727. }
  1728. /**
  1729. * 票 46:模式切换的**选择态语义**(规格 18 / 决策票 13):
  1730. * · 总览 ↔ 任一分项:保留选择身份;目标模式不显示所选项时**暂停**(详情浮层隐藏、设备图层撤下),
  1731. * 切回总览且对象仍在当前范围时恢复 —— 恢复就是"计划重新判定为可见",不需要额外状态;
  1732. * · 分项 ↔ 分项:清空选择(走 `detailStore.closeDetail()`,唯一的关闭入口,不另造状态)。
  1733. * 判定在 `domain/modeLayerPlan.js` 的纯函数里,本壳只执行它的结论。
  1734. */
  1735. function applyModeSelectionTransition(fromMode, toMode) {
  1736. const verdict = planModeSelectionTransition({
  1737. fromMode,
  1738. toMode,
  1739. selection: {
  1740. level: selection.value.level,
  1741. pointCode: selection.value.pointCode,
  1742. deviceCode: selection.value.deviceCode,
  1743. },
  1744. })
  1745. if (verdict.action !== 'clear') return verdict
  1746. // 分项→分项:清空。closeDetail 是唯一的关闭入口(不动相机、不换快照)。
  1747. detailStore.closeDetail()
  1748. if (facilityDetailOpen.value) entityDetailStore.close()
  1749. return verdict
  1750. }
  1751. /** 引导态/进入系统后的联动:设备图层与锚定都要按 `entered` 重算一次。 */
  1752. function syncLayersForEntered(nextEntered) {
  1753. if (nextEntered) {
  1754. syncDeviceLayer({ force: true })
  1755. refreshAnchor({ force: true })
  1756. } else {
  1757. // 回到引导态(闲置回引导页):撤下设备图层(计划层已把一切输出置空)。
  1758. syncDeviceLayer({ force: true })
  1759. }
  1760. }
  1761. const stopDeviceWatches = []
  1762. /** 票 10:两级详情是否打开(浮层只在有选择时渲染;关掉后地图与面板保持原样)。 */
  1763. const detailOpen = computed(() => {
  1764. if (facilityDetailOpen.value) return true
  1765. const current = selection.value
  1766. return Boolean(current && current.level && current.level !== DETAIL_LEVEL.NONE)
  1767. })
  1768. // ---- 票 41:详情面板锚定跟随监测点标记(决策票 04 / 规格票 12 的修订节)----
  1769. //
  1770. // 三条口径直接来自规格,不要在本层自行发明:
  1771. // 1. **始终贴可见标记**:面板只避开画布边缘,**不再避让左右业务栏/图例/底部摘要**(R-1),
  1772. // 被详情窗遮住是允许的、消失不是(R-4);
  1773. // 2. **只在窗口完全离开画面时隐藏**(R-4),且**允许被画布裁切**(R-2)——
  1774. // 所以 `no-space` / `icon-covered` 两种暂隐原因在本层**不再存在**(规格要求移除或标废弃);
  1775. // 3. **层级低于四个详情窗**(R-3):`z-index` 取 1,压在 `--z-columns` 之下。
  1776. //
  1777. // 投影与落位都是**只读**的:地图服务给「标记在不在、投到哪儿」,本组件只摆 DOM,
  1778. // 不持有 Cesium 实体,也不把帧坐标塞进任何业务 store。
  1779. const detailRef = ref(null)
  1780. const anchorLayout = ref({ visible: false, reason: 'canvas-missing', rect: null, line: null, side: '' })
  1781. /** 面板坐标基准:`main` 的窗口矩形(投影给的是窗口坐标,两者相减才是 DOM 局部坐标)。 */
  1782. const anchorOrigin = ref({ left: 0, top: 0 })
  1783. /** 上一帧写下去的落位:与本次相同就**不再写 DOM**(规格:镜头稳定且布局未变时停止重算)。 */
  1784. let lastAnchorKey = ''
  1785. /** 摘要锚向监测点;设备详情锚向所选设备;业务归属编码保持不变。 */
  1786. const detailTarget = computed(() => keepDetailDuringRefresh.value && detailRefreshState.value.target
  1787. ? detailRefreshState.value.target
  1788. : facilityDetailOpen.value ? resolveFacilityDetailAnchor(facilityPointStore.selectedPoint)
  1789. : resolveDetailAnchor({ selection: selection.value, objects: mapStore.summary.objects, devices: deviceRows.value }))
  1790. /** 详情卡上要显示的对象编码(顶栏暂隐入口读它)。 */
  1791. const selectedDetailCode = computed(() => {
  1792. const target = detailTarget.value
  1793. return target ? target.code : ''
  1794. })
  1795. /**
  1796. * 「无地图位置」的固定详情(票 04 的特例)。
  1797. *
  1798. * 判据由 `detailAnchorLocation()` 转交坐标准入领域函数,按当前点位或设备读取——
  1799. * 外壳不自己调 `isRenderable` / `blockReason`:界面自己判坐标正是票 07 的 I3 守卫禁止的事。
  1800. *
  1801. * 三种情形分得开:对象**不在已加载快照里**(分页没翻到 / 引擎未就绪)**不算**无地图位置,
  1802. * 那是"暂时无法锚定",走暂隐并保留选择;只有后端明确判不可上图才转固定详情。
  1803. */
  1804. const fixedLocationReason = computed(() => {
  1805. const target = detailTarget.value
  1806. if (!target) return ''
  1807. const verdict = detailAnchorLocation(target)
  1808. return verdict.present && !verdict.renderable ? verdict.reasonText : ''
  1809. })
  1810. /**
  1811. * 求当前锚点的落位。
  1812. * 返回 `{ canvas, layout }`:`canvas` 只作内部判定输入,`layout` 才是写进视图的对象
  1813. * (暂隐与可见**同形**,模板才能只读一组字段,不会出现"有时读得到 reason、有时读不到")。
  1814. */
  1815. function measureAnchor() {
  1816. const canvas = getMapCanvasRect()
  1817. if (!canvas) return { canvas: null, layout: { visible: false, reason: 'canvas-missing', rect: null, line: null, side: '' } }
  1818. const hidden = (reason) => ({ canvas, layout: { visible: false, reason, rect: null, line: null, side: '' } })
  1819. const target = detailTarget.value
  1820. if (!target) return hidden('marker-missing')
  1821. if (!hasMapMarker(target.kind, target.code, target.pointCode, target.key)) return hidden('marker-missing')
  1822. const anchor = getMapMarkerAnchor(target.kind, target.code, target.pointCode, target.key)
  1823. // 投影拿不到(相机背面 / 地平线后 / 投影无效)与标记在画布外,都归"完全离开画面"。
  1824. if (!anchor) return hidden('marker-offscreen')
  1825. // 高度取 `scrollHeight`(内容自然高度,**不受已写入的显式高度影响**):
  1826. // 用它做判据不会出现「设了高度→量到高度→又设回 auto」的来回抖动。
  1827. const natural = detailRef.value ? detailRef.value.scrollHeight : 0
  1828. const height = Number.isFinite(natural) && natural > 0 ? natural : 0
  1829. return { canvas, layout: solvePointAnchor({ anchor, canvas, height, iconSize: anchor.iconSize || 18, gap: anchor.panelGap || 12, avoidKey: `${anchor.panelGap || 0}/${anchor.iconSize || 0}` }) }
  1830. }
  1831. /**
  1832. * 重算锚定落位。
  1833. *
  1834. * `options.force` 的由来(**真机走查抓到的真缺陷**):规格要求「页面不可见时停止计算」,
  1835. * 原实现把 `document.hidden` 写成无条件早退 —— 于是标签页在后台时**连首次布局都不做**,
  1836. * 面板永远停在初值 `canvas-missing` 上(走查环境正是这种标签页,整条锚定链路不可观测)。
  1837. * 正确的分工是:
  1838. * · **逐帧**重算(`force` 未设)在页面不可见时跳过 —— 那是规格要的省算力;
  1839. * · **显式**重算(详情选择变化 / 尺寸变化 / 挂载,`force: true`)照常执行 ——
  1840. * 它由用户动作驱动、次数极少,跳过只会让面板停留在错误位置。
  1841. */
  1842. function refreshAnchor(options = {}) {
  1843. if (!detailOpen.value || introVisible.value || typeof document === 'undefined') return
  1844. if (document.hidden && options.force !== true) return
  1845. const retainedTarget = keepDetailDuringRefresh.value && detailRefreshState.value.target
  1846. // The old marker is temporarily withdrawn, not a reason to hide/move a panel being read.
  1847. if (retainedTarget && !hasMapMarker(retainedTarget.kind, retainedTarget.code, retainedTarget.pointCode, retainedTarget.key)) return
  1848. // 维护者反馈:限速 10Hz 后"点位摘要/设备详情面板不跟手"。锚定必须**逐帧跟随**,
  1849. // 与 DOM 图标同一条纪律;重复写 DOM 由下面的 `lastAnchorKey` 判定挡住,镜头不动时不写。
  1850. const main = detailRef.value ? detailRef.value.closest('.cockpit-shell__main') : null
  1851. if (main) {
  1852. const rect = main.getBoundingClientRect()
  1853. anchorOrigin.value = { left: rect.left, top: rect.top }
  1854. }
  1855. const { layout } = measureAnchor()
  1856. // 票 76(2026-10-26 面板让位不稳定根因):缓存键**必须包含让位量**。
  1857. // 原来键里只有 side/rect/line —— 进入聚合选择态(②④)时标记位置没变,但 `panelGap` /
  1858. // `iconSize` 变了(84/40 vs 12/18),落位结果随之变化,然而键相同 → 被当成「没变化」跳过,
  1859. // 于是面板**停在旧位置**。走查表现为「hover 时偶尔让位、真正进入选择态反而不让位」。
  1860. const key = layout.visible
  1861. ? `${layout.side}|${Math.round(layout.rect.left)},${Math.round(layout.rect.top)},${Math.round(layout.rect.width)},${Math.round(layout.rect.height)}|${JSON.stringify(layout.line)}|${layout.avoidKey || ''}`
  1862. : layout.reason
  1863. // 与上一帧相同就**不再写 DOM**(规格:镜头稳定且布局未变时停止重算)。
  1864. if (key === lastAnchorKey) return
  1865. lastAnchorKey = key
  1866. anchorLayout.value = layout
  1867. }
  1868. /**
  1869. * 面板落位。**用绝对定位**(不是 `fixed`):百分比 `max-height` 要按 `main` 解析,
  1870. * 而 `fixed` 会按视口解析 —— 视口比地图区多出顶栏与筛选条那一条,阈值就会漂。
  1871. */
  1872. const detailStyle = computed(() => {
  1873. if (fixedLocationReason.value) return {}
  1874. const layout = anchorLayout.value
  1875. // 暂隐:`visibility` 而不是 `display:none` —— 元素仍在 DOM 里,恢复时能直接量到自然高度
  1876. // (`display:none` 会让 `scrollHeight` 变 0,恢复后面板会先塌成 1px)。
  1877. // **必须同时关掉 `pointer-events`**:本组件是 `pointer-events: auto` 的绝对定位浮层,
  1878. // 只隐藏视觉仍会**拦截它覆盖区域内的地图点击**(看不见却吃掉交互)。
  1879. //
  1880. // 锚定不到(目标还没上图 / 已离开视口)时**暂隐**,由顶栏 `data-anchor-hidden` chip
  1881. // 说明原因并给「重新定位 / 关闭」入口。
  1882. //
  1883. // 这条改了两轮,两个极端都踩过,不要再来回翻:
  1884. // · 2026-12-02 之前直接 `visibility:hidden`,但当时目标根本没能上图,于是面板"渲染了却谁也看不见";
  1885. // · 2026-12-02 改成"退回 CSS 固定位置",把病根挪到了锚定链上——真机表现为
  1886. // **目标离开视口后面板自己固定到一个不该存在的位置**(维护者 2026-12-03 报的正是这条)。
  1887. // 现在图标与锚定都能正常解析,所以恢复"锚不到就暂隐":看不见目标时不该给一张
  1888. // 位置无依据的面板;无地图位置的那一类仍走上面的 `fixedLocationReason` 固定详情。
  1889. if (!layout.visible) return { visibility: 'hidden', pointerEvents: 'none' }
  1890. const origin = anchorOrigin.value
  1891. return {
  1892. left: `${layout.rect.left - origin.left}px`,
  1893. top: `${layout.rect.top - origin.top}px`,
  1894. width: `${layout.rect.width}px`,
  1895. // 内容没超过可读上限就按内容高(不留空白),超了才钉住高度并由卡内滚动接管。
  1896. height: layout.cropped ? `${layout.rect.height}px` : 'auto',
  1897. }
  1898. })
  1899. /** 归属短线:从图标外缘指向卡片面对图标的那条边(不覆盖图标)。 */
  1900. const anchorLeadStyle = computed(() => {
  1901. const line = anchorLayout.value.line
  1902. if (!line) return {}
  1903. // 与卡片同一坐标基准:投影给的是**窗口坐标**,短线与卡片同处 `main` 内(绝对定位),
  1904. // 所以两端都要减掉基准点 —— 只减卡片那一处会让线整体偏出一个顶栏+筛选条的高度。
  1905. const origin = anchorOrigin.value
  1906. const from = { x: line.from.x - origin.left, y: line.from.y - origin.top }
  1907. const to = { x: line.to.x - origin.left, y: line.to.y - origin.top }
  1908. const dx = to.x - from.x
  1909. const dy = to.y - from.y
  1910. const length = Math.hypot(dx, dy)
  1911. const angle = (Math.atan2(dy, dx) * 180) / Math.PI
  1912. return {
  1913. left: `${from.x}px`,
  1914. top: `${from.y}px`,
  1915. width: `${length}px`,
  1916. transform: `rotate(${angle}deg)`,
  1917. }
  1918. })
  1919. /**
  1920. * 详情选择或地图对象变化 → 立即重算一次落位(不等下一帧)。
  1921. * `nextTick` 是等卡片挂载/换内容后再量高度:刚打开时 `scrollHeight` 还是 0,
  1922. * 直接量会把长卡判成"没内容"而永远按 auto 摆放。
  1923. */
  1924. watch(
  1925. [() => selection.value.level, () => selection.value.pointCode, () => selection.value.deviceCode, () => mapStore.summary.objects, () => deviceRows.value, () => entityDetailStore.identity, () => entityDetailStore.detail, () => facilityPointStore.renderPoints],
  1926. () => {
  1927. lastAnchorKey = ''
  1928. nextTick(() => refreshAnchor({ force: true }))
  1929. },
  1930. { deep: false },
  1931. )
  1932. // ---- 共享数据分区(票 05):三条共享详情域分区在筛选条右侧列出状态 ----
  1933. // 标签用短名,状态语义仍由 SectionStateTag + domain/sectionState.js 决定。
  1934. const SECTION_LABELS = {
  1935. mapSnapshot: '地图摘要',
  1936. equipmentAggregate: '设备详情',
  1937. equipmentFreshness: '数据新鲜度',
  1938. }
  1939. const sharedSections = computed(() =>
  1940. Object.keys(SECTION_LABELS).map((name) => ({
  1941. name,
  1942. label: SECTION_LABELS[name],
  1943. section: sections.value[name],
  1944. })),
  1945. )
  1946. /**
  1947. * 票 16 验收第 2 条要求「新鲜、过期、不可用和**部分失败**状态可区分」。
  1948. *
  1949. * 「部分失败」是**跨分区**的性质:单个分区只会说自己那一份(`sectionView`),
  1950. * 谁也不负责说"三块里坏了一块"。所以这里把各分区的四态收上来交给
  1951. * `domain/freshnessModel.js` 的 `overallFreshness()`,由它给出整体结论 ——
  1952. * 判据只有一份,界面不自己数数。
  1953. */
  1954. const overallFreshnessState = computed(() =>
  1955. overallFreshness(sharedSections.value.map((item) => viewFromSectionState(sectionStateOf(item.section)))),
  1956. )
  1957. const overallFreshnessLabel = computed(() => overallFreshnessText(overallFreshnessState.value))
  1958. // ---- 地图摘要渐进加载(票 08):顶栏只展示状态与一个动作,分页/快照参数都在适配层 ----
  1959. const mapSummaryView = computed(() => mapStore.view)
  1960. // 票 08:右上既有摘要区把「命中/已加载/可上图/当前符号」分开报;未知总数保持未知。
  1961. const mapSummaryCountsText = computed(() => {
  1962. const counts = mapSummaryView.value.counts || {}
  1963. const total = Number.isFinite(mapStore.summary.total) ? mapStore.summary.total : '—'
  1964. const loaded = Number.isFinite(counts.loaded) ? counts.loaded : '—'
  1965. const mappable = Number.isFinite(counts.mappable) ? counts.mappable : '—'
  1966. const displayed = Number.isFinite(counts.displayed) ? counts.displayed : '—'
  1967. return '命中 ' + total + ' · 已加载 ' + loaded + ' · 可上图 ' + mappable + ' · 符号 ' + displayed
  1968. })
  1969. const mapSummaryPartial = computed(() => mapSummaryView.value.counts && mapSummaryView.value.counts.partial === true)
  1970. /** 收起态只留一条最新状态,展开态才显示全部诊断字段。 */
  1971. const statusSummaryText = computed(() => {
  1972. if (overallFreshnessState.value === 'partial') return overallFreshnessLabel.value
  1973. if (['empty', 'stale', 'unavailable'].includes(runtimeStore.freshness.view)) return runtimeStore.freshness.text
  1974. if (runtimeStore.status.state !== 'open') return runtimeStore.statusText
  1975. if (['idle', 'loading', 'empty', 'failed', 'expired'].includes(mapSummaryView.value.phase)) return mapSummaryView.value.label
  1976. return `更新 ${runtimeStore.freshness.lastSuccessClock}`
  1977. })
  1978. const statusSummaryTone = computed(() => {
  1979. if (overallFreshnessState.value === 'partial') return 'is-warning'
  1980. if (['empty', 'stale', 'unavailable'].includes(runtimeStore.freshness.view)) return 'is-warning'
  1981. if (runtimeStore.status.state !== 'open') return 'is-warning'
  1982. if (['idle', 'loading', 'empty', 'failed', 'expired'].includes(mapSummaryView.value.phase)) return 'is-warning'
  1983. return 'is-ok'
  1984. })
  1985. /**
  1986. * 票 61:统一刷新 —— 一次动作同时刷新**地图摘要**与**当前一级模式的全部分区**。
  1987. *
  1988. * 旧版这里有两套:按钮走 `refreshMapSnapshot()`(只换地图快照),新鲜度轮询自己再走一遍
  1989. * 「换快照 + 刷面板」。同一个「刷新」两种做法,用户点按钮时面板不跟着动(票 61 的动机)。
  1990. * 现在按钮与轮询都只调 `requestRefresh()`;编排(并发、单飞、逐项成败)在
  1991. * `stores/refreshStore.js`,判据与文案在 `domain/refreshRun.js` —— 本文件只递接缝、绑入口。
  1992. */
  1993. const refreshStore = useRefreshStore()
  1994. refreshStore.configure({
  1995. // 地图摘要:换新快照(mapStore 的装载链自动连续分批到完成),再把装载状态同步成
  1996. // 「地图摘要」分区状态(票 05 的分区板据此变色)。
  1997. refreshMap: async () => {
  1998. const state = await mapStore.refresh()
  1999. detailStore.syncMapSnapshotSection()
  2000. return state
  2001. },
  2002. // 票 03:设施点图层单独一项。手动刷新重取全量(枚举 + 详情),
  2003. // 轮询只补已枚举设施的坐标/状态(facilityMode=details),不重拉运行信息。
  2004. refreshFacilityLayer: async (plan, extra) => facilityPointStore.refresh({ mode: extra && extra.mode }),
  2005. // 面板:取完当前模式的全部分区,回一个「panelId → 分区」查表函数供判据用
  2006. // (判据在 domain/refreshRun.js,外壳不自己数哪块坏)。
  2007. refreshPanels: async () => {
  2008. // 设备状态池跟着同一轮刷新走:顶部状态栏在任何模式下都必须与面板同步。
  2009. await Promise.all([refreshModePanels(), refreshDevicePools()])
  2010. return (panelId) => sectionOf(panelId)
  2011. },
  2012. // 票 61 验收第 4 条:本轮成败记进 freshnessService 那一本账(不另造第二份"最近刷新时间")。
  2013. recordFreshness: (ok, reason) => runtimeStore.recordFreshness(ok, reason),
  2014. })
  2015. /** 按钮与轮询共用的**唯一**刷新入口(票 61 验收第 2 条:刷新动作只有一处入口)。 */
  2016. function requestRefresh(options = {}) {
  2017. return refreshStore.requestRefresh({ mode: mode.value, ...options })
  2018. }
  2019. /**
  2020. * 已取过面板数据的模式集合(2026-10-30 加载优化)。
  2021. *
  2022. * 旧行为:启动计划把**四个模式**的面板全部预加载(19 个请求,基础设施三块各约 0.8s),
  2023. * 首屏实际只需要当前模式,其余请求既占带宽又推迟首屏。
  2024. * 现在:启动只取当前模式;其它模式**首次进入时**再取。筛选变化会失效这里的缓存,
  2025. * 下次进入按最新条件重取;刷新按钮/轮询仍然只刷当前模式(`refreshModePanels`)。
  2026. */
  2027. const loadedPanelModes = new Set()
  2028. /** 首屏帧之后/浏览器空闲时再跑重任务;不支持 requestIdleCallback 时退化为一次短延时。 */
  2029. function scheduleIdle(task) {
  2030. if (typeof window === 'undefined') return
  2031. const run = () => {
  2032. if (!shellDisposed) task()
  2033. }
  2034. if (typeof window.requestIdleCallback === 'function') {
  2035. window.requestIdleCallback(run, { timeout: 1200 })
  2036. } else {
  2037. defer(run, 200)
  2038. }
  2039. }
  2040. /** 某个模式的面板取数(当前筛选条件;不判断缓存)。 */
  2041. function loadPanelsForMode(target) {
  2042. if (target === 'monitoring') {
  2043. return monitoringStore.loadPanels({
  2044. industry: industry.value,
  2045. deviceType: deviceType.value,
  2046. pointStatus: pointStatus.value,
  2047. scope: scope.value,
  2048. })
  2049. }
  2050. if (target === 'infrastructure') {
  2051. return infrastructureStore.loadPanels({ industry: industry.value, scope: scope.value })
  2052. }
  2053. if (target === 'warningResponse') {
  2054. // 票 67:片区也要跟着下(预警分析是事件族里唯一收片区入参的端点)。
  2055. return eventStore.loadPanels({
  2056. mode: eventStore.mode,
  2057. range: eventStore.range,
  2058. industry: industry.value,
  2059. scope: scope.value,
  2060. })
  2061. }
  2062. // 票 89:四模块端点已由后端补齐片区/行业入参 —— 刷新也按当前筛选取数。
  2063. return overviewStore.loadPanels({ industry: industry.value, scope: scope.value })
  2064. }
  2065. /** 首次进入某个模式时取一次面板(已取过就跳过;筛选变化会清缓存)。 */
  2066. function ensureModePanelsLoaded(target = mode.value) {
  2067. if (!lifecycleReady.value || loadedPanelModes.has(target)) return
  2068. loadedPanelModes.add(target)
  2069. loadPanelsForMode(target)
  2070. }
  2071. /** 筛选变化 → 失效缓存;每次进入/刷新都按最新条件重新取。 */
  2072. function invalidateModePanels(target = '') {
  2073. if (target) loadedPanelModes.delete(target)
  2074. else loadedPanelModes.clear()
  2075. }
  2076. /**
  2077. * 当前一级模式的面板取数(票 14 的面板半边)。
  2078. * 面板取数失败不抛(各分区自己收成 FAILED/UNAVAILABLE 并如实标注),
  2079. * 所以一块面板失败不会让本轮刷新整体失败(票 61 验收第 1 条)。
  2080. */
  2081. async function refreshModePanels() {
  2082. loadedPanelModes.add(mode.value)
  2083. await loadPanelsForMode(mode.value)
  2084. }
  2085. // ---- 配置状态(票 04):票 102 起顶栏不再显示配置读数,这里只留判定结果,
  2086. // 供地图配置(mapConfig / uiDebug)与降级说明使用。----
  2087. const configState = ref(null)
  2088. /**
  2089. * 票 17:字体授权门禁的宿主读数(走查断言接缝)。
  2090. * `fontStatus()` 与 `installFontFaces()` 同源——都读统一资产解析层的门禁判定,
  2091. * 所以读数不会与页面实际注入的 @font-face 出现两套说法。
  2092. */
  2093. const cockpitFontStatus = computed(() => fontStatus())
  2094. const fontGate = computed(() => (cockpitFontStatus.value.ok ? 'ok' : cockpitFontStatus.value.code))
  2095. const fontFaceCount = computed(() => String(cockpitFontStatus.value.entries.filter((e) => e.resolvable).length))
  2096. /**
  2097. * 票 17 第七轮:把导航装饰切图(选中态底板 / 选中光晕 / 底边光路)经语义 key 解析成
  2098. * CSS 自定义属性挂在顶栏上——样式文件里只引用 var(),不出现物理路径;
  2099. * manifest 缺条目时变量为 none,对应装饰自动退化(底板退 CSS 渐变、光晕/光路不画)。
  2100. * 票 18(批次 5):新增品牌标题后方光池(icon.brand.pool),同样语义注入、缺失自动不画。
  2101. */
  2102. const navDecorStyle = computed(() => {
  2103. const bg = iconFor('navActiveBg')
  2104. const glow = iconFor('brandGlow')
  2105. const path = iconFor('brandGlowPath')
  2106. const pool = iconFor('brandPool')
  2107. return {
  2108. '--nav-active-bg': bg && bg.url ? `url("${bg.url}")` : 'none',
  2109. '--nav-glow-url': glow && glow.url ? `url("${glow.url}")` : 'none',
  2110. '--brand-path-url': path && path.url ? `url("${path.url}")` : 'none',
  2111. '--brand-pool-url': pool && pool.url ? `url("${pool.url}")` : 'none',
  2112. }
  2113. })
  2114. /**
  2115. * 票 32:UI 形态。配置 `map.ui.debug` 显式给布尔值就听它,否则跟随构建模式
  2116. * —— 开发构建显示诊断信息,生产构建自动收敛成「干净模式」(维护者 2026-09-18 要求)。
  2117. */
  2118. const uiDebug = computed(() => {
  2119. const configured =
  2120. configState.value && configState.value.config && configState.value.config.map && configState.value.config.map.ui
  2121. ? configState.value.config.map.ui.debug
  2122. : null
  2123. if (typeof configured === 'boolean') return configured
  2124. return !!(import.meta.env && import.meta.env.DEV)
  2125. })
  2126. // ---- 进入引导与视角预设(票 30)----
  2127. // 引导默认开着;配置里 map.intro.enabled=false 时直接进系统(其它票的走查用它自隔离)。
  2128. // `intro`/`introVisible` 的声明已上移至 `modeLayerPlan` 之前(TDZ,见上移处的说明)。
  2129. const atHomeView = ref(false)
  2130. const homeView = computed(() => getHomeView())
  2131. const homeTitle = computed(() => `回到${homeLabel(homeView.value)}`)
  2132. // ---- 主场景区:进区锁定与区域限位(票 37 / ADR 0009)----
  2133. //
  2134. // 状态本体在 `filterStore.areaState`(全局视图条件,切一级模式不重置);服务层负责转移。
  2135. // 外壳只做三件它才有资格做的事:顶栏按钮形态、闲置计时、引导页显隐。
  2136. const areaLocked = computed(() => areaState.value === AREA_STATE.LOCKED)
  2137. const areaBar = computed(() => areaBarActions(areaState.value))
  2138. /** 生效限位(区外是宽区间;区内上限=home.range)。按钮提示里读它,不另算一套。 */
  2139. const areaLimits = ref(getAreaLimits())
  2140. /**
  2141. * 进区受阻时的如实提示(主场景区未配置 / 非法)。
  2142. * **不弹窗、不遮罩**:与票 04/05 的立场一致 —— 单个能力不可用只标出来,不挡业务。
  2143. */
  2144. const areaNotice = ref('')
  2145. const homeFlightPending = ref(false)
  2146. let homeFlightToken = 0
  2147. /** 把服务层的区域状态同步回 store(服务层是转移的判定者,store 是持有者)。 */
  2148. function syncAreaState() {
  2149. const next = getAreaState()
  2150. if (next !== areaState.value) filterStore.setAreaState(next)
  2151. areaLimits.value = getAreaLimits()
  2152. fogReadout.value = getFogState()
  2153. }
  2154. // ---- 票 38:自建视距雾的可观测读数 ----
  2155. //
  2156. // 外壳**只读**服务层的读数,不自己算强度/支持度(策略与生命周期归 mapService)。
  2157. const fogReadout = ref(getFogState())
  2158. /** 芯片文案:支持/可执行/强度三项说清楚;降级时说降级原因。 */
  2159. const fogText = computed(() => {
  2160. const fog = fogReadout.value
  2161. if (fog.state === 'unsupported') return '视距雾不可用 · 无深度支持'
  2162. if (fog.state === 'failed') return '视距雾不可用'
  2163. if (fog.degrade === 'reduced') return `视距雾减弱 · 强度 ${fog.strength.toFixed(2)}`
  2164. if (fog.degrade === 'off') return '视距雾已暂关'
  2165. if (fog.phase === 'global') return '视距雾待命 · 区内生效'
  2166. return `视距雾 ${fog.strength.toFixed(2)} · ${Math.round(fog.startDistance / 1000)}–${Math.round(fog.endDistance / 1000)} km`
  2167. })
  2168. /** 悬停说明:把"就绪不等于已遮住边缘"这条口径写在人能读到的地方。 */
  2169. const fogTitle = computed(() => {
  2170. const fog = fogReadout.value
  2171. const lines = [
  2172. `雾色 ${fog.color}`,
  2173. `起雾 ${Math.round(fog.startDistance)} m · 完全遮蔽 ${Math.round(fog.endDistance)} m`,
  2174. `阶段 ${fog.phase} · 强度 ${fog.strength}`,
  2175. '「就绪」只表示处理级可执行,不代表矩形边缘已被遮住',
  2176. ]
  2177. if (fog.reason) lines.push(fog.reason)
  2178. return lines.join(';')
  2179. })
  2180. /**
  2181. * 返回全球(ADR 0009):解除限位 + 阻尼飞到程序初始态全景,之后完全自由。
  2182. * 引擎未就绪时服务层返回 `applied: false` —— 如实不生效,不假装飞了。
  2183. */
  2184. function returnToGlobal() {
  2185. homeFlightToken += 1
  2186. homeFlightPending.value = false
  2187. areaNotice.value = ''
  2188. // 返回全球:先隐藏业务标记并作废未完成的显示计划(迟到批次不得把它们补回来)。
  2189. hideDisplayGate()
  2190. const result = setAreaState('returnGlobal')
  2191. syncAreaState()
  2192. if (result.applied) {
  2193. // 回全球后不久就该由闲置计时接管(回引导页),先把按钮状态刷一次。
  2194. defer(refreshHomeState, 900)
  2195. }
  2196. return result
  2197. }
  2198. /** 相机能接受飞行后才移走地球引导;等待期间同一次点击只保留一个重试。 */
  2199. function flyHome({ fromIntro = false } = {}) {
  2200. if (homeFlightPending.value) return
  2201. homeFlightPending.value = true
  2202. areaNotice.value = ''
  2203. const token = ++homeFlightToken
  2204. let tries = 0
  2205. const fly = () => {
  2206. if (token !== homeFlightToken) return
  2207. const applied = goHome({ immediate: false })
  2208. const engine = applied ? 'ready' : getLifecycleStats().engine
  2209. if (applied || (fromIntro && engine === 'disabled')) {
  2210. homeFlightPending.value = false
  2211. if (fromIntro) introVisible.value = false
  2212. armDisplayGateIfHidden()
  2213. refreshHomeState()
  2214. if (applied && !areaLocked.value) areaNotice.value = '主场景区未配置或配置无效 · 区域限位与雾气关闭'
  2215. } else if (engine !== 'failed' && ++tries < 40) {
  2216. defer(fly, 250)
  2217. } else {
  2218. homeFlightPending.value = false
  2219. // 进入动作不该被地图就绪卡死:点过「进入」就结束引导态。
  2220. // 否则 Drawer / 详情浮层这些 v-if="!introVisible" 的节点永远不渲染 ——
  2221. // 表现就是「点什么都打不开详情」,而地图本身稍后仍会就绪(维护者 2026-12-02)。
  2222. if (fromIntro) introVisible.value = false
  2223. areaNotice.value = '地图暂未就绪,请稍后重试'
  2224. }
  2225. }
  2226. fly()
  2227. }
  2228. function enterSystem() {
  2229. flyHome({ fromIntro: true })
  2230. }
  2231. function refreshHomeState() {
  2232. atHomeView.value = atHome()
  2233. // 票 37:区域状态也在这里对齐。服务层是转移的判定者(`goHome` 内部会进区),
  2234. // 而 DEV 把手 `__cockpitMap.goHome()` / `enterArea()` 走的是**服务层直调**,不经过本组件的
  2235. // `enterArea()` —— 不同步的话,走查用把手进区后顶栏仍显示「归位/进入」、也不出「返回全球」,
  2236. // 与实际锁定状态不符(本票真机走查第一次跑就撞上了)。这个 500ms 轮询是既有的,
  2237. // 借用它让两条入口最终一致,不新增定时器。
  2238. syncAreaState()
  2239. // 轮询同样推进显示门控:隐藏标签页里没有渲染帧,靠这条路径把「归位/锁定」状态喂进去。
  2240. tickDisplayGate(false)
  2241. }
  2242. // ---- 本票:显示就绪门控的观测与状态推进 ----
  2243. /** 相机是否已真正停稳(显示门控的「相机真正归位」判据)。
  2244. * 只认 settled,**不要求精确停在 home**:用户在进入飞行途中手动拖动/缩放后,相机不会再回到
  2245. * home;若把「必须在 home」当硬条件,门控会永远停在 WAITING、点位永不加载(人工走查抓到的 bug)。
  2246. * 自动飞行落到 home、以及手动接管后停稳,两者 settled 都为真,都算「真正归位」。
  2247. * 也不等 500ms 轮询的 atHomeView,避免错过「最后一帧已落定」。 */
  2248. function cameraSettled() {
  2249. const state = getCameraState()
  2250. return !!(state && state.settled === true)
  2251. }
  2252. /** 区域是否已就绪:已锁定,或主场景区根本不可用(不因「进不了区」而永远不显示标记)。
  2253. * 用服务层权威状态 getAreaState(),不用 filterStore 派生的 areaLocked —— 后者在
  2254. * setAreaState 的同步 notify 里尚未同步(会滞后一拍),导致返回全球瞬间被误判为「仍锁定」。 */
  2255. function displayAreaReady() {
  2256. if (getAreaState() === AREA_STATE.LOCKED) return true
  2257. const plan = getPrimaryAreaPlan()
  2258. return !(plan && plan.enabled)
  2259. }
  2260. /**
  2261. * 推进显示门控。frame=true 只在**真的渲染了一帧**的 postRender 回调里传——
  2262. * 这是「至少一帧真实渲染」的证据,不靠固定超时、也不靠 settled 标志。
  2263. */
  2264. function tickDisplayGate(frame) {
  2265. if (!intro.value.enabled || isEntryMapPending()) return
  2266. // 兜底:DEV 直接进区等绕过外壳的入口,离开引导且锁区后补一次 arm。
  2267. // 用服务层权威状态 getAreaState(),避免 setAreaState 同步 notify 时 filterStore 还没同步的滞后。
  2268. if (displayGate.value.phase === DISPLAY_GATE.HIDDEN && !introVisible.value && getAreaState() === AREA_STATE.LOCKED) {
  2269. displayGate.value = armDisplayGate(displayGate.value)
  2270. }
  2271. const next = observeDisplayGate(displayGate.value, {
  2272. areaReady: displayAreaReady(),
  2273. cameraSettled: cameraSettled(),
  2274. frame,
  2275. })
  2276. if (next !== displayGate.value) displayGate.value = next
  2277. }
  2278. /** 进入主场景时 arm;已在 READY 就不再 arm(否则退回 WAITING 会让标记闪一下)。 */
  2279. function armDisplayGateIfHidden() {
  2280. // 只有真的离开地球视角(introVisible=false)时才 arm;引导页可见时 arm 会让标记
  2281. // 在引导层背后提前显示,违背「全球视角隐藏业务点位」。
  2282. if (!intro.value.enabled || introVisible.value) return
  2283. if (displayGate.value.phase === DISPLAY_GATE.HIDDEN) {
  2284. displayGate.value = armDisplayGate(displayGate.value)
  2285. }
  2286. }
  2287. /** 返回全球 / 回引导页:disarm(立即隐藏并作废未完成计划)。 */
  2288. function hideDisplayGate() {
  2289. if (displayGate.value.phase === DISPLAY_GATE.HIDDEN) return
  2290. displayGate.value = disarmDisplayGate(displayGate.value)
  2291. }
  2292. /** 归位按钮:引擎未就绪时重试(与进入系统同一条路径)。 */
  2293. function returnHome() {
  2294. entityDetailStore.close()
  2295. flyHome()
  2296. }
  2297. const columns = computed(() => columnsForMode(mode.value))
  2298. /** 面板所在栏(详情浮层贴边方向);判定只在 `panelCatalog` 一处,外壳不自己比数组。 */
  2299. function panelSideOf(panelId) {
  2300. return panelSideFor(mode.value, panelId) || 'right'
  2301. }
  2302. const entityDetailSide = computed(() => entityDetailStore.sourceSide || 'right')
  2303. /**
  2304. * 维护者 2026-10-30 15:57 细节2:台账(左栏)打开且**无地图位置**的设施详情,
  2305. * 固定到台账侧(左),不占右侧那个所有详情共用的固定位。侧别只信
  2306. * entityDetailStore.sourceSide(handleCardAction 已把面板所在栏传进来),外壳不自己判左右;
  2307. * 无位置判定仍走 fixedLocationReason(pending 的"暂时无法锚定"不算无位置,不进固定态)。
  2308. */
  2309. const facilityFixedLeft = computed(() =>
  2310. facilityDetailOpen.value && !!fixedLocationReason.value && entityDetailSide.value === 'left')
  2311. function isExpanded(panelId) {
  2312. return expandedPanelIds.value.includes(panelId)
  2313. }
  2314. // ---- 全球态闲置 → 回程序初始态(票 37 / ADR 0009)----
  2315. //
  2316. // 「全球态闲置 5 秒未操作 → 回程序初始态(星球自转恢复 + 屏幕中央闪烁『点击进入系统』)」。
  2317. // 三条边界都是契约明写的,写在代码里免得日后被"优化"掉:
  2318. // 1. **只在 global 态计时** —— 区内是工作状态,不该被闲置踢回引导页;
  2319. // 2. **任何交互即重置**(指针/滚轮/键盘/点按钮都算);
  2320. // 3. **不重置一级模式与筛选**(只回视角与引导层,不动工作上下文)。
  2321. // `map.intro.enabled=false` 时不发生(没有引导页可回 —— spec 的边缘口径)。
  2322. let idleSince = 0
  2323. let idleTimer = null
  2324. /** 记一次交互(重置闲置计时)。任何用户动作都应调它。 */
  2325. function markActivity() {
  2326. idleSince = Date.now()
  2327. }
  2328. /**
  2329. * 回到程序初始态:相机回初始全景 + 恢复自转 + 显示引导层
  2330. * (不动 mode / 筛选 / 区域状态)。
  2331. *
  2332. * 维护者 2026-09-30 报障:原先只显示引导层 + 起转,**没有把相机送回去** ——
  2333. * 于是画面停在用户最后停留的视角上、地球也不转,除了中央那行字就看不出来"回引导态了"。
  2334. * 现在三件事一起做:`resetToIntroView()` 把角度送回 `0/−60/3×10⁷`,
  2335. * `setGlobeSpin()` 立起自转意图(相机若还在飞,落定后由服务层自动接上)。
  2336. */
  2337. function returnToIntro() {
  2338. // 回引导页:隐藏业务标记并作废未完成的显示计划(迟到批次的落尾在 MapCanvas 侧也会被取消)。
  2339. hideDisplayGate()
  2340. introVisible.value = true
  2341. resetToIntroView()
  2342. setGlobeSpin(intro.value.spinSeconds)
  2343. // 回引导页不等于解除限位:区外本来就是 global,区内不该被动摇(契约只说全球态闲置)。
  2344. markActivity()
  2345. }
  2346. function checkIdle() {
  2347. if (!idleSince) {
  2348. markActivity()
  2349. return
  2350. }
  2351. const elapsed = Date.now() - idleSince
  2352. if (shouldReturnToIntro(elapsed, getAreaState(), { idleMs: GLOBAL_IDLE_MS, introEnabled: intro.value.enabled })) {
  2353. if (!introVisible.value) returnToIntro()
  2354. // 已经在引导页:继续重置,避免每 250ms 重复触发。
  2355. markActivity()
  2356. }
  2357. }
  2358. /**
  2359. * 全局交互监听:任何指针/滚轮/键盘动作都重置闲置计时。
  2360. * 捕获阶段监听,免得被面板自己的 `stopPropagation` 吃掉。
  2361. */
  2362. function onAnyActivity() {
  2363. markActivity()
  2364. }
  2365. // ---- 顶栏时钟:已抽成 <CockpitClock /> 子组件(票 98)----
  2366. // 秒针若留在这里,1Hz 会重渲染整个外壳 —— 而外壳模板里对**每个可见面板**都要调
  2367. // panelViewOf(),基础设施/运行监测这类大视图因此每秒被整体重建一次(维护者报的卡顿)。
  2368. // 时钟关进自己的组件后,1Hz 更新只重渲染那一个 span。
  2369. let homeTimer = null
  2370. /**
  2371. * 票 41:锚定跟随的帧驱动与恢复。
  2372. *
  2373. * `onMapFrame` 走 Cesium 的 `scene.postRender`(**真的渲染了一帧**才回调)——
  2374. * 不是自己再排一个 rAF:隐藏标签页里 rAF 会被冻结,而 `postRender` 只在渲染时触发,
  2375. * 与「每帧最多一次、画面已渲染才投影」的规格口径一致。
  2376. * 这里只对**当前一个**锚点做投影,没有详情时回调本身就是早退(零开销)。
  2377. */
  2378. let stopMapFrame = null
  2379. let stopCameraState = null
  2380. let anchorResizeHandler = null
  2381. onMounted(() => {
  2382. // 顶栏时钟由 <CockpitClock /> 自带计时器(票 98)——外壳不再有 1Hz 重渲染源。
  2383. // 归位按钮的高亮状态跟着相机走(用户手动平移后就不再算"在家")。
  2384. homeTimer = setInterval(refreshHomeState, 500)
  2385. // 票 17:字体面只在这个入口注入一次,随外壳生命周期存亡(幂等,重复调用不会叠加节点)。
  2386. installFontFaces()
  2387. // 票 37:闲置计时只在这个入口挂一次,随外壳生命周期存亡。
  2388. markActivity()
  2389. idleTimer = setInterval(checkIdle, 250)
  2390. for (const domEvent of ['pointerdown', 'pointermove', 'wheel', 'keydown']) {
  2391. window.addEventListener(domEvent, onAnyActivity, { capture: true, passive: true })
  2392. }
  2393. // 票 04:配置只在这个入口载入一次(服务内部有缓存),地图服务按需 await 同一份。
  2394. loadCockpitConfig().then(async (result) => {
  2395. if (shellDisposed) return
  2396. configState.value = result
  2397. // 配置到手才知道引导开关与预设坐标,重新取一次。
  2398. intro.value = getIntroConfig()
  2399. introVisible.value = intro.value.enabled
  2400. // ── 票 14:按**启动计划**执行(规格 09 / 决策票 04)──
  2401. //
  2402. // `dataSource` 只决定 transport,不决定页面生命周期:real 与 mock 产出**同一套动作**
  2403. // (地图装载器、共享分区、四模式面板、WS、新鲜度),差别只剩 mock 分支多一步
  2404. // `register-mocks`。此前的 `if (dataSource === MOCK)` 门让 real 成为空壳——
  2405. // 规格明令移除;失败语义(分区 UNAVAILABLE / NO_BASE_URL)由 requestCockpitJson
  2406. // 与 sectionState 对两种数据源一视同仁,**没有**任何「real 失败回退 mock」的路径。
  2407. // 票 76:DEV 走查桥 —— `?dataSource=mock|real` 覆盖配置(配合 `?scenario=` 出 K>1 聚合场景)。
  2408. // 生产构建里 `import.meta.env.DEV` 为假,helper 原样返回,不改正式路径。
  2409. const plan = planCockpitStartup(
  2410. withUrlDataSourceOverride(result.config, null, !!(import.meta.env && import.meta.env.DEV)),
  2411. )
  2412. // 配置一次下发到四个面板 store:面板改为**按需取数**后,未进入的模式也要能随时被
  2413. // `ensureModePanelsLoaded` 直接取,不再依赖各自的启动分支先 configure。
  2414. overviewStore.configure({ config: result.config })
  2415. infrastructureStore.configure({ config: result.config })
  2416. monitoringStore.configure({ config: result.config })
  2417. eventStore.configure({ config: result.config })
  2418. for (const action of plan.actions) {
  2419. if (shellDisposed) return
  2420. if (action === STARTUP_ACTION.REGISTER_MOCKS) {
  2421. // 只有 mock 模式才需要样例包;real 的首屏不加载它。
  2422. const { ensureCockpitMocks } = await import('./mocks/index.js')
  2423. if (shellDisposed) return
  2424. ensureCockpitMocks()
  2425. continue
  2426. }
  2427. // 2026-10-30 加载优化:启动计划仍产出四个模式的面板动作(契约不变),但执行时
  2428. // **只取当前模式** —— 其余模式首次进入时由 `ensureModePanelsLoaded` 取。
  2429. // 旧行为把 19 个请求全打在启动上(基础设施三块各约 0.8s),首屏并不需要它们。
  2430. if (
  2431. action === STARTUP_ACTION.LOAD_INFRASTRUCTURE_PANELS ||
  2432. action === STARTUP_ACTION.LOAD_MONITORING_PANELS ||
  2433. action === STARTUP_ACTION.LOAD_EVENT_PANELS ||
  2434. action === STARTUP_ACTION.LOAD_OVERVIEW_PANELS
  2435. ) {
  2436. continue
  2437. }
  2438. // 票 18:**先把筛选交给地图**,再让共享分区去取第 1 页(顺序纪律不变)。
  2439. // 若筛选晚于它,第 1 页就带着空筛选发出去 —— 那正是"筛了但第一屏没筛上"的经典来源。
  2440. // (`mapStore.setup()` 是合并语义,所以后到的调用不会抹掉这里的条件。)
  2441. // 票 14:refresh 链会**自动分批加载到完成**(决策 02 的 Q24)。
  2442. if (action === STARTUP_ACTION.LOAD_MAP_SUMMARY) {
  2443. mapStore.setup({
  2444. config: result.config,
  2445. industry: industry.value,
  2446. scope: scope.value,
  2447. deviceType: deviceType.value,
  2448. pointStatus: pointStatus.value,
  2449. })
  2450. continue
  2451. }
  2452. if (action === STARTUP_ACTION.LOAD_SHARED_SECTIONS) {
  2453. // 票 14:共享分区预载也吃**同一份**启动配置。`loadSharedSections` 内部会对
  2454. // mapStore 再做一次合并式 setup —— 不显式下发的话,`shared = { config: undefined }`
  2455. // 会把 LOAD_MAP_SUMMARY 刚合并进 mapStore 的 config 键覆盖掉(合并语义下
  2456. // `undefined` 也是一次写入),real 下首批摘要请求就只能靠配置缓存兜底了。
  2457. detailStore.loadSharedSections({ config: result.config })
  2458. // 票 24/68:设施点位与管线是**跨模式共享**的图层(不随一级模式切换重取)。
  2459. // 2026-10-30 加载优化:几何一次约 6MB、设施点还要逐条补详情,属于首屏之后
  2460. // 才看得见的重图层 —— 放到浏览器空闲时再取,先让外壳/面板/引导页完成首帧。
  2461. // 地图侧仍按 store 数据到达后同步图层,不会漏画。
  2462. scheduleIdle(() => {
  2463. // 票 67 更正:片区也要交给管线图层(本地按编码前缀裁剪,不额外发请求)。
  2464. pipeNetworkStore.load({ industry: industry.value, scope: scope.value, config: result.config })
  2465. // 票 68:行业/片区/设施类型筛选都在 store 的 `filtered` 里本地生效。
  2466. facilityPointStore.load({ config: result.config })
  2467. })
  2468. continue
  2469. }
  2470. // 票 15:状态推送。外壳只说"用配置启动"——地址、凭据与 mock/real 的连接方式
  2471. // 都由 runtimeStore 决定(页面因此不认识凭据,也不认识假连接)。
  2472. // 没配地址时服务进 `disabled`,界面如实说"未配置",不假装连上。
  2473. if (action === STARTUP_ACTION.START_WEBSOCKET) {
  2474. runtimeStore.startWithConfig(result.config, {
  2475. scenario: (typeof window !== 'undefined' && window.__COCKPIT_WS_SCENARIO__) || 'success',
  2476. })
  2477. continue
  2478. }
  2479. // 票 16/14:刷新周期(决策地图票 07 Q3 = 前端轮询 + WS 断线也算失败周期)。
  2480. // 规格 09 的 tick 全套:地图摘要刷新 + **当前模式面板取数**,成败交给新鲜度记账;
  2481. // 连续两个周期失败即过期(有旧值)或不可用(从未取到)。
  2482. // `__COCKPIT_FRESHNESS_FAIL__` 让走查/人工演示"周期一直失败"这条路径。
  2483. if (action === STARTUP_ACTION.START_FRESHNESS) {
  2484. const failForever = typeof window !== 'undefined' && window.__COCKPIT_FRESHNESS_FAIL__ === true
  2485. let firstFreshnessTick = true
  2486. runtimeStore.startFreshness({
  2487. refreshSeconds: result.config.runtime ? result.config.runtime.refreshSeconds : undefined,
  2488. // 票 61:轮询与按钮共用同一个刷新入口(不再有第二套「换快照 + 刷面板」)。
  2489. // 本轮记账仍归 freshnessService 的周期(同一本账、同一判据),所以传 account:false
  2490. // 避免同一轮记两次;取数成败在 refreshStore.lastRun 里如实留痕。
  2491. // 启动首轮紧跟首屏设施点加载:跳过 details,避免同一批实体详情被取两遍。
  2492. tick: () => {
  2493. if (failForever) return { ok: false, reason: '演示:取数持续失败' }
  2494. const facilityMode = firstFreshnessTick ? 'skip' : 'details'
  2495. firstFreshnessTick = false
  2496. return requestRefresh({ account: false, facilityMode })
  2497. },
  2498. })
  2499. }
  2500. }
  2501. if (shellDisposed) return
  2502. // 票 02:泵站类型字典独立于面板取数;只在成功后注入,失败保持「类型未发布」不猜。
  2503. fetchPumpStationTypeDict({ config: result.config }).then((section) => {
  2504. if (section.state === 'success') setPumpTypeLabels(section.data)
  2505. })
  2506. // 票 07:六类业务字典 —— 先用持久化快照顶上,再并发刷新并覆盖快照。
  2507. // 单类失败不牵连其它类;全部失败时保留快照与内存,界面继续用上一次可用标签。
  2508. loadDictionaries({ config: result.config }).catch(() => {})
  2509. lifecycleReady.value = true
  2510. // 首屏只取当前模式;其它模式在第一次切过去时再取(筛选变化会清缓存)。
  2511. ensureModePanelsLoaded(mode.value)
  2512. // 状态池与一级模式无关,首屏即取一次(顶部状态栏在四个模式都常驻)。
  2513. refreshDevicePools()
  2514. })
  2515. // 引导期间显示自转;进入后停(引擎就绪前调用会被忽略,等引擎 ready 再兜一次)。
  2516. if (intro.value.enabled) {
  2517. setGlobeSpin(intro.value.spinSeconds)
  2518. clearSpinTimer()
  2519. spinTimer = setInterval(() => {
  2520. if (!introVisible.value || setGlobeSpin(intro.value.spinSeconds)) clearSpinTimer()
  2521. }, 600)
  2522. } else {
  2523. // 票 37:`intro.enabled=false`(走查自隔离)时**按 global 自由视角启动、不弹引导页**
  2524. // (ADR 0009 的边缘口径)。这里显式同步一次状态,免得服务层与 store 各持一个初值。
  2525. syncAreaState()
  2526. }
  2527. // 票 41:锚定跟随。帧驱动走地图的已渲染帧回调;尺寸变化与详情选择变化各补一次立即重算
  2528. // (规格:恢复或尺寸变化后立即重算,不等下一帧)。
  2529. // 本票:postRender 是「真的渲染了一帧」的唯一可靠证据——顺手推进显示门控(frame=true)。
  2530. stopMapFrame = onMapFrame(() => {
  2531. refreshAnchor()
  2532. tickDisplayGate(true)
  2533. })
  2534. // 相机状态变化也重算(隐藏标签页里渲染帧不触发,这条才是可靠的跟随路径;见 mapService 的注释)。
  2535. // 恢复为逐帧 force:维护者反馈"点位摘要/设备详情面板不跟手",锚定必须与镜头同帧对齐。
  2536. // 本票:相机状态变化由渲染循环驱动(cameraControl.render → onStateChange),
  2537. // 因此「正在停稳」这一刻本身就伴随一帧渲染;把 settled=true 当作该帧证据,
  2538. // 保证自动飞行落定或手动接管停稳后**当帧即可放行**,不会因后续没有新帧而卡住。
  2539. stopCameraState = onCameraStateChange((state) => {
  2540. refreshAnchor({ force: true })
  2541. tickDisplayGate(Boolean(state && state.settled === true))
  2542. })
  2543. anchorResizeHandler = () => refreshAnchor({ force: true })
  2544. window.addEventListener('resize', anchorResizeHandler)
  2545. // 票 41:把统一选择入口递给 DEV 把手(走查/人工演示走同一条路径,不另造定位入口)。
  2546. publishPointSelectionHandle(selectMonitoringPoint)
  2547. // 票 43:设备选中/hover 的 DEV 把手也走 store(避免服务层与 store 出现两套选中真相)。
  2548. publishDeviceSelectionHandle({
  2549. selectDevice: (code) => deviceLayerStore.selectDevice(code),
  2550. hoverDevice: (code) => deviceLayerStore.hoverDevice(code),
  2551. backToPointLevel: () => deviceLayerStore.backToPointLevel(),
  2552. })
  2553. refreshAnchor({ force: true })
  2554. // 票 42:三类触发都接上(选择 / 详情到达 / 快照变化)。
  2555. // 选择与详情分开监听是有意的:选择变化要**立即**撤旧图层,而详情到达只需重算同一份计划。
  2556. stopDeviceWatches.push(
  2557. watch(() => [selection.value.pointCode, selection.value.level], () => syncDeviceLayer({ force: true }), { deep: false }),
  2558. watch(modeAbnormalDevices, () => syncDeviceLayer(), { deep: false }),
  2559. watch(() => sections.value.pointDetail, () => syncDeviceLayer(), { deep: false }),
  2560. watch(() => mapStore.summary.batchUpdatedAt, (stamp) => syncDeviceLayerForSnapshot(stamp), { deep: false }),
  2561. // A filter reload can retain the backend timestamp while changing device membership.
  2562. watch(() => mapStore.summary.objects, () => syncDeviceLayer(), { deep: false }),
  2563. // 票 42(规格 14:刷新核对链)——三个时刻:
  2564. // ① 刷新**发起**:立即挂起设备图层(规格「先撤下」,不等首页返回);
  2565. // ② 快照**失效**:expired 相位不改 batchUpdatedAt,必须单独触发撤层;
  2566. // ③ 链条 **settled**:对挂起中的所选点位核对收口(找到重载 / 完整找不到关闭 / 失败保持待核对)。
  2567. watch(() => mapStore.refreshing, (on) => {
  2568. if (!on) {
  2569. if (snapshotPending.value && mapStore.settled) void reconcileSnapshotSelection()
  2570. else if (!snapshotPending.value) detailRefreshState.value = null
  2571. return
  2572. }
  2573. detailRefreshState.value = { key: detailViewKey.value, visible: selectionVisibleInMode.value, target: detailTarget.value }
  2574. deviceLayerStore.suspendForSnapshot()
  2575. snapshotAbsentNote.value = ''
  2576. snapshotPending.value = Boolean(selection.value.pointCode || selection.value.deviceCode)
  2577. }, { deep: false, flush: 'sync' }),
  2578. watch(() => mapStore.summary.phase, (phase) => {
  2579. if (phase !== MAP_SUMMARY_PHASE.EXPIRED || !selection.value.pointCode) return
  2580. deviceLayerStore.suspendForSnapshot()
  2581. snapshotPending.value = true
  2582. }, { deep: false }),
  2583. watch(() => mapStore.settled, (settled) => {
  2584. if (settled && snapshotPending.value) reconcileSnapshotSelection()
  2585. }, { deep: false }),
  2586. // 一级模式变化只改**可见性与选择态**(不换快照、不重建地图):
  2587. // 先按矩阵执行选择态语义(总览↔分项保留 / 分项↔分项清空),再重算设备图层计划。
  2588. watch(mode, (next, prev) => {
  2589. if (!facilityDetailOpen.value) entityDetailStore.close()
  2590. applyModeSelectionTransition(prev, next)
  2591. syncDeviceLayer({ force: true })
  2592. // 面板按需取:第一次进入该模式时补一次;已取过则由筛选变化负责失效。
  2593. ensureModePanelsLoaded(next)
  2594. }, { deep: false }),
  2595. // 票 46:引导态只负责关闭详情;业务图层显隐改由「显示就绪」displayEntered 驱动(见下方)。
  2596. watch(introVisible, (next) => {
  2597. if (next && !facilityDetailOpen.value) entityDetailStore.close()
  2598. }, { deep: false }),
  2599. // 本票:真正决定业务标记/图例/图层显隐的是显示就绪门控,而不是「是否离开引导态」。
  2600. // WAITING→READY 时补一次图层同步;READY→HIDDEN(返回全球/回引导)时撤下图层。
  2601. watch(displayEntered, (next) => {
  2602. syncLayersForEntered(next)
  2603. }, { deep: false }),
  2604. // 票 43:详情层级写进宿主 `data-map-panel-selection`,并把层级对照同步给设备图层 store
  2605. // (镜头联动判"该怎么动"要拿它当"变化前")。
  2606. watch(
  2607. () => [selection.value.level, selection.value.deviceCode],
  2608. ([level, deviceCode]) => {
  2609. setPanelSelectionLevel(level)
  2610. deviceLayerStore.noteLevel(level, deviceCode)
  2611. },
  2612. { deep: false, immediate: true },
  2613. ),
  2614. )
  2615. })
  2616. /**
  2617. * 票 17:全局行业筛选变化 → 重取四块面板(CONTEXT.md:行业筛选是作用于整个驾驶舱的全局条件,
  2618. * 所以它必须真的作用到面板数据上,而不只是记在 store 里)。
  2619. *
  2620. * 只在 mock 取数已就绪后跟随:配置还没落地时 store 里还没有 config,
  2621. * 这时抢跑会带着空配置发请求(票 04 的「没有显式配置就不发请求」)。
  2622. */
  2623. watch(industry, (next) => {
  2624. if (!lifecycleReady.value) return
  2625. // 2026-10-30 加载优化:只立即重取**当前模式**;其它模式失效缓存,切过去时按新条件取。
  2626. invalidateModePanels()
  2627. refreshModePanels()
  2628. // 票 24:行业筛选同样作用到管线与构件图层。几何是**全量取回、本地裁剪**,
  2629. // 所以切行业只改本地筛选条件、不重新发请求(切换必须即时,不等一个往返)。
  2630. pipeNetworkStore.setIndustry(next)
  2631. refreshMapForFilters({ industry: next })
  2632. })
  2633. /**
  2634. * 片区筛选变化:地图、监测分布、基础档案、管理计数、概览片区分布与**预警处置四块**同步刷新。
  2635. *
  2636. * 票 67 补的不是"所有面板都跟着变",而是**"该跟着变的都跟着变、不该变的都说明白"**;
  2637. * 票 79/80 按部署后的实测把事件族补齐;票 89 把后端已补齐入参的 9 个端点一次接线:
  2638. * - 真收片区入参的端点:`map-snapshot` / 基础档案 / 管理信息 / 监测分布 / **事件族四块**
  2639. * (`/events/*`)/ **监测概览、运行概况、运行信息、应急保障、概览四块、全量工单列表**
  2640. * → 在这里与 store/service 里接线,切片区就重取;
  2641. * - 界面上原先「本面板不随当前范围变化」的缺口句已随 2026-10-27 部署实测撤除
  2642. * (9 个端点非法值 400、合法值读数不同,两轴都真的生效);口径单源在
  2643. * `domain/filterCaliber.js`,那张表现在是空表。
  2644. * `eventStore` 原本整条旁路:切片区后预警处置四块面板一个请求都不发(票 67 的缺口 2)。
  2645. */
  2646. watch(scope, (next) => {
  2647. if (!lifecycleReady.value) return
  2648. // 2026-10-30 加载优化:同行业筛选 —— 只刷当前模式,其它模式切过去时再取。
  2649. invalidateModePanels()
  2650. refreshModePanels()
  2651. // 票 67 更正(维护者 2026-10-23):管线与构件**也能按片区筛** —— 片区从设施编码前缀推
  2652. // (片区+行业+时间编码)。几何是全量取回、本地裁剪,所以这里只改条件、不重新发请求。
  2653. pipeNetworkStore.setScope(next)
  2654. refreshMapForFilters({ scope: next })
  2655. })
  2656. /**
  2657. * 票 14:点位状态筛选变化 → 面板与**一张图**都跟随(决策 02/规格 07 冻结的契约:
  2658. * `map-snapshot` 收多值 `pointStatus`,旧「状态筛选不作用到一张图」的缺口已关闭)。
  2659. * 状态栏点选 → 这里换新快照重载(自动分批到完成)+ 运行监测面板跟随。
  2660. */
  2661. watch(pointStatus, (next) => {
  2662. if (!lifecycleReady.value) return
  2663. // 只有运行监测吃点位状态;当前不在该模式时只失效缓存,切过去再取。
  2664. invalidateModePanels('monitoring')
  2665. if (mode.value === 'monitoring') refreshModePanels()
  2666. refreshMapForFilters({ pointStatus: next })
  2667. })
  2668. /**
  2669. * 票 37:设备类型筛选变化 → 运行监测面板与**一张图**都跟随。
  2670. *
  2671. * 三个端点(overview/distribution/situation)都收 `deviceType` 入参(services/monitoringApi.js
  2672. * 逐行读过),所以三块一起重取;`map-snapshot` 同样收(票 25 第 3 节冻结的路径)。
  2673. * 切模式不重置(deviceType 是 filterStore 的全局条件,与行业/片区同层)。
  2674. */
  2675. watch(deviceType, (next) => {
  2676. if (!lifecycleReady.value) return
  2677. invalidateModePanels('monitoring')
  2678. if (mode.value === 'monitoring') refreshModePanels()
  2679. refreshMapForFilters({ deviceType: next })
  2680. })
  2681. /**
  2682. * 取一次全局设备状态池(首屏 / 筛选变化 / 统一刷新共用)。
  2683. *
  2684. * 它是**全站口径**:顶部状态栏在四个一级模式里都常驻,所以不能等「运行监测」的分区
  2685. * 来喂,否则不进那个模式就不更新(维护者 2026-11-04 指出的缺陷)。
  2686. */
  2687. function refreshDevicePools() {
  2688. return deviceStatusStore.refresh({
  2689. industry: industry.value,
  2690. scope: scope.value,
  2691. deviceType: deviceType.value,
  2692. })
  2693. }
  2694. /** 把筛选条件下给地图并**换新快照重载**(票 08 的快照一致性:一次加载只对应一份数据)。 */
  2695. function refreshMapForFilters(next) {
  2696. // 行业/片区/类型/状态任何一个变化都同时重取状态池(它按行业+片区+类型取数)。
  2697. refreshDevicePools()
  2698. mapStore
  2699. .applyFilters(next)
  2700. .then(() => detailStore.syncMapSnapshotSection())
  2701. }
  2702. onBeforeUnmount(() => {
  2703. shellDisposed = true
  2704. entityDetailStore.close()
  2705. if (homeTimer) clearInterval(homeTimer)
  2706. clearSpinTimer()
  2707. clearDeferredTimers()
  2708. // 票 41:锚定跟随的帧订阅与尺寸监听必须拆掉(与票 15/37 的"漏取消定时器"是同一个坑)。
  2709. if (stopMapFrame) {
  2710. stopMapFrame()
  2711. stopMapFrame = null
  2712. }
  2713. if (stopCameraState) {
  2714. stopCameraState()
  2715. stopCameraState = null
  2716. }
  2717. // 票 41:DEV 把手随外壳一起摘掉(与 mapSummary 把手同款)。
  2718. publishPointSelectionHandle(null)
  2719. // 票 43:设备把手一并摘掉。
  2720. publishDeviceSelectionHandle(null)
  2721. // 票 42:设备图层的四个监听一并拆掉(票 15/37 的"漏取消"是同一个坑)。
  2722. for (const stop of stopDeviceWatches) stop()
  2723. stopDeviceWatches.length = 0
  2724. deviceLayerStore.reset()
  2725. pipeEnhancementStore.clear()
  2726. enhancementDevicesStore.clear()
  2727. if (anchorResizeHandler) {
  2728. window.removeEventListener('resize', anchorResizeHandler)
  2729. anchorResizeHandler = null
  2730. }
  2731. lastAnchorKey = ''
  2732. // 票 37:闲置计时器与全局交互监听必须拆掉 —— 与票 15 的"漏取消定时器"是同一个坑。
  2733. if (idleTimer) clearInterval(idleTimer)
  2734. for (const domEvent of ['pointerdown', 'pointermove', 'wheel', 'keydown']) {
  2735. window.removeEventListener(domEvent, onAnyActivity, { capture: true })
  2736. }
  2737. setGlobeSpin(0)
  2738. // 票 15:连接是模块级单例,离开外壳必须停掉(否则重连定时器会跟着页面跑下去)。
  2739. runtimeStore.stop()
  2740. // 票 16:刷新周期的定时器同理必须停(票 15 刚在"漏取消定时器"上栽过一次)。
  2741. runtimeStore.stopFreshness()
  2742. // 票 61:统一刷新态不留在 store 里跟着页面跑(与上面几个「离开必须停/清」同一条纪律)。
  2743. refreshStore.reset()
  2744. // 票 38:定位反馈的自动收起定时器同理必须拆——离开外壳后它不该再去动 store 状态。
  2745. if (locateDismissTimer) {
  2746. window.clearTimeout(locateDismissTimer)
  2747. locateDismissTimer = null
  2748. }
  2749. })
  2750. // ---- 票 25:状态面板里的地图信息读数 ----
  2751. // 计数一律取自**同一份模式图层计划**(`modeLayerPlan`),不另开一份真相;
  2752. // 署名与底图措辞取自 mapService(与真正建图层用的是同一批计划)。
  2753. const mapMarkerCount = computed(() => modeLayerPlan.value.markers.length)
  2754. const mapMarkerStatusText = computed(() => {
  2755. const byStatus = modeLayerPlan.value.byStatus || {}
  2756. const keys = Object.keys(byStatus).sort()
  2757. return keys.length ? keys.map((key) => `${key} ${byStatus[key]}`).join(' · ') : '等待分页数据'
  2758. })
  2759. const mapCoordinateOverview = computed(() => mapStore.coordinate)
  2760. const mapBasemapLabel = computed(() => getBasemapLabel())
  2761. const mapDataSourceCredits = computed(() => getDataSourceCredits())
  2762. </script>
  2763. <style scoped>
  2764. /* 组件内自带的盒模型重置(原型图靠全局 `*` 重置,我们这里不依赖全局样式)。
  2765. 缺了它,铺满容器的外壳加上 padding 会撑出滚动条。 */
  2766. .cockpit-shell,
  2767. .cockpit-shell *,
  2768. .cockpit-shell *::before,
  2769. .cockpit-shell *::after {
  2770. box-sizing: border-box;
  2771. }
  2772. /* ============================================================
  2773. 骨架尺寸
  2774. 主题令牌(颜色 / 字号 / 间距 / 层级)集中在 styles/tokens.css,
  2775. 本文件不再声明;--u 是「设计像素」:1920 宽时为 1px,随视口线性放大、
  2776. 封顶 2px(4K 时正好一倍),小于 1920 时不再缩小。这样 4K 大屏不显空旷,
  2777. 同时页面仍是铺满而非等比留边。
  2778. ============================================================ */
  2779. /* 填满**所在容器**,而不是按 100vh 铺(票 28):宿主布局在顶部留了页头时(`npm run pre.dev`
  2780. 的 TvT 演示站是 54px 固定页头;将来 qiankun 主应用也可能套壳),100vh 会把外壳顶出容器
  2781. 底部——底部内容被裁、容器还多出一条纵向滚动条。改成 absolute inset:0 贴着最近的定位容器,
  2782. 容器多高就多高;窗口 resize 由 CSS 自己跟随,不需要挂载时量一次。 */
  2783. .cockpit-shell {
  2784. position: absolute;
  2785. inset: 0;
  2786. display: grid;
  2787. /* 顶栏 / 筛选条 / 主体:两条横栏压矮,把高度让给真正展示信息的主体 */
  2788. grid-template-rows: calc(52 * var(--u)) calc(34 * var(--u)) minmax(0, 1fr);
  2789. gap: calc(4 * var(--u));
  2790. overflow: hidden;
  2791. padding: calc(8 * var(--u)) calc(12 * var(--u)) calc(12 * var(--u));
  2792. color: var(--text);
  2793. font: var(--fs-body) / 1.45 var(--font);
  2794. }
  2795. /* 全局氛围底:径向辉光 + 细网格(原型 body::before / ::after 的等价实现)。
  2796. 用 absolute 而不是 fixed:随外壳自己的范围铺,宿主页头那一带不归驾驶舱画。 */
  2797. .cockpit-shell__atmosphere {
  2798. position: absolute;
  2799. inset: 0;
  2800. z-index: 0;
  2801. pointer-events: none;
  2802. background:
  2803. radial-gradient(1500px 760px at 50% -12%, rgba(0, 82, 168, 0.4), transparent 62%),
  2804. radial-gradient(1000px 620px at 4% 108%, rgba(0, 82, 168, 0.2), transparent 62%),
  2805. radial-gradient(1000px 620px at 96% 108%, rgba(0, 82, 168, 0.2), transparent 62%),
  2806. radial-gradient(760px 460px at 50% 46%, rgba(0, 61, 133, 0.3), transparent 70%),
  2807. linear-gradient(180deg, var(--bg-0, #010514) 0%, var(--bg-1, #02091b) 42%, var(--bg-0, #010514) 100%);
  2808. }
  2809. .cockpit-shell__atmosphere::after {
  2810. content: "";
  2811. position: absolute;
  2812. inset: 0;
  2813. opacity: 0.5;
  2814. background-image:
  2815. linear-gradient(rgba(1, 171, 234, 0.045) 1px, transparent 1px),
  2816. linear-gradient(90deg, rgba(1, 171, 234, 0.045) 1px, transparent 1px);
  2817. background-size: 56px 56px, 56px 56px;
  2818. mask-image: radial-gradient(120% 90% at 50% 30%, #000 30%, transparent 88%);
  2819. }
  2820. /* 只给真正的网格项加定位;不要用 `.cockpit-shell > *`,
  2821. 否则会以同权重覆盖 .cockpit-shell__atmosphere 的 position: fixed。 */
  2822. .cockpit-shell__topbar,
  2823. .cockpit-shell__scope,
  2824. .cockpit-shell__main {
  2825. position: relative;
  2826. z-index: 1;
  2827. min-width: 0;
  2828. }
  2829. /* ============================================================
  2830. 顶栏(压矮:56 设计像素)
  2831. ============================================================ */
  2832. /* 顶栏三列:品牌 / 一级模式 / 状态区。
  2833. 票 102:右列的 `min-content` 兜底**保留**,但让它先变成「与秒针无关」的常量。
  2834. 维护者 2026-11-02 报障「时间一跳,按钮就跟着挪」:右列宽度按内容最小宽度兜底,
  2835. 而内容里的时钟读数每换一次数字宽度就变一次(字体长短不平均),列宽随之改写,
  2836. 中列(一级模式)被推着左右移动。
  2837. 真凶是**时钟的不定宽**,不是 min-content 本身 —— 时钟改成固定宽度数字槽位(见
  2838. .cockpit-shell__clock)后,这一列的 min-content 只剩按钮标签与槽位这两个常量,
  2839. 不再随时间变化;于是两条要求同时成立:
  2840. - 位置稳定:列宽要么取这个常量下限、要么取 1fr 等分,两者都不看秒针脸色;
  2841. - 不压到菜单:下限仍在,窄视口下内容超宽时不会像票 37 那样向左溢出压住「预警处置」
  2842. (最宽内容 = 归位/进入 + 返回全球 + 128u 槽位 + 间隙与内边距 ≈ 293u;最紧的一档
  2843. 1024×640(--u 落到 1px 下限)等分给到 314px > 293px,取的是等分而不是下限)。
  2844. 曾试过把它改成 `minmax(0, 1fr)`:抖动同样消除,但顺手撤掉了票 37 的溢出兜底,
  2845. 窄视口会退回「归位压预警处置」那个老问题,故不取。 */
  2846. .cockpit-shell__topbar {
  2847. display: grid;
  2848. grid-template-columns: minmax(240px, 1fr) auto minmax(240px, 1fr);
  2849. align-items: center;
  2850. gap: calc(12 * var(--u));
  2851. height: calc(52 * var(--u));
  2852. /* 票 103(维护者 2026-11-02):
  2853. ① 一级菜单在票 102 的 -32u 基础上**再左移整页宽的 5%**(5vw,按页面宽度算);
  2854. ② 「归位 / 返回全球 / 时钟」整栏左移,**右侧留出整页宽的 15% 空白**。
  2855. (2026-11-02 三轮反馈:留白 25% → 10% → 定稿 15%;菜单位移 10% → 定稿 5%。)
  2856. 两个位移会互相牵制:菜单往左跑的同时状态栏也在往左跑,窄屏上就会撞在一起
  2857. (票 37 记录的「归位压住预警处置」正是这个形状)。所以两条位移都由这里
  2858. 统一声明,并各自带**收敛条件**——宁可少移,也不许两栏重叠:
  2859. --topbar-nav-shift:取「-32u - 5vw」,但当它会让菜单左缘撞进品牌标题文字带时,
  2860. 收敛到标题右缘。506.6u = 标题图起点 6u + 404u×92%(图内最右不透明列 90.4%,
  2861. 再留 2u 余量)+ 顶栏 12u 列间距;0.5*w 是菜单几何中心。
  2862. --topbar-status-inset:状态栏右缘离页面右缘的距离,取 15vw(再让 12u 内边距),
  2863. 但当它会让状态栏左缘压到菜单右缘时,收敛到「菜单右缘 + 12u 间距」。 */
  2864. --topbar-nav-shift: max(
  2865. calc(-5vw - 32 * var(--u)),
  2866. calc(506.6 * var(--u) - 50vw)
  2867. );
  2868. /* 状态栏内缩的三条约束,取其中**最小**的一条(min() 天然就是「谁最紧听谁」)。
  2869. 注意 inset 语义:inset 越大,状态栏越靠左。所以「不压菜单」给出的是 inset 的
  2870. **上界**,正好对应 min() 里取更小的那个:
  2871. ① 15vw - 12u:要求值的常态,右缘停在 85% 处;
  2872. ② 50vw - 510u - 位移:不得压住菜单。代数推导(全部换成 u 单位):
  2873. 菜单右缘 mR = 0.5W + 186u + 位移(W 为页宽、位移为负)
  2874. 状态右缘 sr = W - 12u - inset,状态左缘 sl = sr - 300u
  2875. 要求 sl ≥ mR + 12u
  2876. ⇒ W - 12u - inset - 300u ≥ 0.5W + 186u + 位移 + 12u
  2877. ⇒ inset ≤ 0.5W - 510u - 位移 (510 = 12 内边距 + 300 状态栏 + 186 半菜单宽 + 12 间距)
  2878. 1152×720 校验:上界 = 135.4u,15% 要 160.8u,min 取 135.4u ⇒ 状态栏停在菜单右侧
  2879. 12u 处(而非压上去 13px)。
  2880. ③ 50vw - 180u:不得超出页面右缘(= 半页宽减内边距),窄屏兜底。
  2881. 三条取 min 之后,「不压菜单」与「不出界」都不会被违反,代价只是较窄的视口上
  2882. 右侧留白达不到 15% —— 两条要求冲突时以不重叠、不出界为先。 */
  2883. --topbar-status-inset: min(
  2884. calc(15vw - 12 * var(--u)),
  2885. calc(50vw - 510 * var(--u) - var(--topbar-nav-shift)),
  2886. calc(50vw - 180 * var(--u))
  2887. );
  2888. /* 票 17 第八轮 R2:基线(标题光带最低线 = path 最低线,即顶栏底)之上留 10u 保护区——
  2889. 内容实际可用高度 42u,按钮行(34u)在其中垂直居中,底边离基线 4u 出血,
  2890. **任何文字与按钮不得压到基线**。时钟 var(--num) 显式声明优先,不受继承影响。
  2891. 票 17 第九轮 R3:min-width: 0 —— 窄视口下让品牌列可收缩(标题切图 max-width 让位),
  2892. 避免 grid 把中列菜单挤到换行(按钮 nowrap 后溢出裁切)。 */
  2893. min-width: 0;
  2894. padding-bottom: calc(10 * var(--u));
  2895. font-family: var(--font-topbar);
  2896. }
  2897. .cockpit-shell__topbar-bg {
  2898. position: absolute;
  2899. inset: 0;
  2900. pointer-events: none;
  2901. background:
  2902. linear-gradient(180deg, rgba(0, 31, 92, 0.58) 0%, rgba(2, 9, 27, 0.12) 62%, transparent 100%),
  2903. radial-gradient(560px 92px at 50% 6%, rgba(1, 171, 234, 0.4), transparent 72%);
  2904. clip-path: polygon(0 0, 100% 0, 100% 74%, calc(100% - 46px) 74%, calc(100% - 62px) 100%, 62px 100%, 46px 74%, 0 74%);
  2905. }
  2906. /* 票 17 第十一轮:底边光路 = 裁切窗口。窗口从标题右侧(430u)铺到屏幕右缘、贴基线;
  2907. 背景把切图放大到 230% 窗口宽(画布列 22.9%–62% 的可见线段恰铺满窗口),
  2908. position 38.4% 100% = 线段左端对窗口左缘、亮线贴窗口底(=基线,与标题光带共线)。
  2909. 第九轮的 right-shift 方案失败原因:整图拉伸 100% 宽时线段按百分比映射视口,
  2910. 挪图片盒子改变不了线段落在标题上的事实。 */
  2911. /* 票 17 第十二轮:窗口左缘 430u → 340u——线段起点钻进标题光带尾部 ~90u,
  2912. 营造"光线从标题延伸出来"的衔接感;仍避开文字带(文字带右缘 ≈12%+75%×404 ≈ 315u)。 */
  2913. .cockpit-shell__topbar-path {
  2914. position: absolute;
  2915. left: calc(340 * var(--u));
  2916. right: 0;
  2917. bottom: 0;
  2918. height: calc(19 * var(--u));
  2919. background-image: var(--brand-path-url, none);
  2920. background-repeat: no-repeat;
  2921. background-size: 230% 100%;
  2922. background-position: 38.4% 100%;
  2923. pointer-events: none;
  2924. }
  2925. /* 票 17 第八轮 R2:两根背景装饰线挪出文字区——
  2926. 原来固定在 top:50% 且横跨 50%±400px,正好横穿菜单文字。
  2927. 现改为:垂直方向贴顶栏底部(top: 58%,在基线上方、不越过),水平方向
  2928. 一根贴最左(品牌区左侧空白)、一根贴最右(状态区右侧空白),不进文字带。 */
  2929. .cockpit-shell__wing {
  2930. position: absolute;
  2931. top: 58%;
  2932. width: calc(170 * var(--u));
  2933. height: 2px;
  2934. pointer-events: none;
  2935. background: linear-gradient(90deg, transparent, rgba(1, 171, 234, 0.75));
  2936. box-shadow: 0 0 12px rgba(1, 171, 234, 0.55);
  2937. opacity: 0.55;
  2938. }
  2939. .cockpit-shell__wing::after {
  2940. content: "";
  2941. position: absolute;
  2942. right: 0;
  2943. top: -3px;
  2944. width: 8px;
  2945. height: 8px;
  2946. background: var(--cyan);
  2947. transform: rotate(45deg);
  2948. box-shadow: 0 0 12px var(--cyan);
  2949. }
  2950. .cockpit-shell__wing.is-left { left: 0; }
  2951. .cockpit-shell__wing.is-right {
  2952. right: 0;
  2953. transform: scaleX(-1);
  2954. }
  2955. /* 票 17 第十一轮(结构性根因修复):品牌列**定高 + 绝对定位标题**。
  2956. 此前标题切图(高 98u)是 grid 项内容,把顶栏整行撑到 98u——菜单按钮"垂直居中"
  2957. 是相对 98u 行居中的,底边正好落在基线上(宽屏菜单"串在底线上"的真因;
  2958. 窄屏切图被 max-width 缩小、行变矮,菜单反而正常——与维护者观察完全一致)。
  2959. 现在:品牌列 height 52u + overflow visible,标题绝对定位溢出显示,
  2960. grid 行高恢复 52u,菜单/状态区真正在 42u 内容区里居中。 */
  2961. .cockpit-shell__brand {
  2962. position: relative;
  2963. height: calc(52 * var(--u));
  2964. min-width: 0;
  2965. padding-left: calc(6 * var(--u));
  2966. }
  2967. /* 标题切图(brand-title.png 940×228):绝对定位于品牌列、顶部对齐。
  2968. 宽 404u → 高 98u:亮线(画布 53.1%)= 顶栏底 52u,与底边光路共线;
  2969. 文字带 ≈53u 在亮线上。溢出顶栏的淡晕不占布局,由下方筛选条承接。
  2970. 窄视口让位:max-width 以品牌列宽为上限(min-width:0 生效后 = 可用宽),等比缩。 */
  2971. .cockpit-shell__mark {
  2972. position: absolute;
  2973. top: 0;
  2974. left: calc(6 * var(--u));
  2975. max-width: calc(100% - 12 * var(--u));
  2976. height: auto;
  2977. }
  2978. /* 票 18(批次 5):品牌标题后方光池(蓝湖 D6「光」层,设计 realFrame 489×128 @ (-19,-1),
  2979. 即相对品牌标题左上偏移 -19,-1——左缘超出标题 19/489 ≈ 3.9%,上缘超 1 设计像素)。
  2980. 复杂位图光效不可 CSS 无损复现(规格 03 判据),按设计 frame 铺在标题下层:
  2981. 锚点与标题切图同(left 6u),宽 = 标题 404u × 489/470 ≈ 1.0404 倍,
  2982. translateX(-3.885%) 抵消设计稿左偏(百分比对自身宽,即 -19/489)。
  2983. max-width 随标题的让位上限同步放大 1.0404 倍,窄视口一起缩。
  2984. 纯装饰(aria-hidden 层内的 ::before)、pointer-events:none,不参与拾取与命名;
  2985. manifest 缺条目时 --brand-pool-url 为 none,自动不画。 */
  2986. .cockpit-shell__brand::before {
  2987. content: '';
  2988. position: absolute;
  2989. top: calc(-1 * var(--u));
  2990. left: calc(6 * var(--u));
  2991. width: calc(404 * var(--u) * 1.0404);
  2992. max-width: calc((100% - 12 * var(--u)) * 1.0404);
  2993. aspect-ratio: 489 / 128;
  2994. transform: translateX(-3.885%);
  2995. background-image: var(--brand-pool-url, none);
  2996. background-repeat: no-repeat;
  2997. background-size: 100% 100%;
  2998. pointer-events: none;
  2999. }
  3000. /* 视觉隐藏但保留给读屏与走查断言(切图 aria-hidden,可访问名靠这里)。 */
  3001. .cockpit-shell__sr-only {
  3002. position: absolute;
  3003. width: 1px;
  3004. height: 1px;
  3005. overflow: hidden;
  3006. clip: rect(0 0 0 0);
  3007. white-space: nowrap;
  3008. }
  3009. .cockpit-shell__modes {
  3010. display: flex;
  3011. gap: calc(4 * var(--u));
  3012. justify-content: center;
  3013. position: relative;
  3014. /* 票 102/103(维护者:菜单要在「居中偏左」,在当前位置上略微左移,不与背景装饰线条重合;
  3015. 2026-11-02 定稿:再左移整页宽的 5%):整组平移,不写回列宽 —— 位移只影响这一格自己,
  3016. 不重新参与 grid 分配,所以选中态切换、内容变化都改不了按钮位置。
  3017. 用 transform 而不是 margin:margin 会把中列让出的空位再分给左右两列,
  3018. 等于把「谁推菜单」的裁决权交还给内容;translateX 是纯视觉偏移,几何仍居中。
  3019. 位移量的唯一来源是顶栏上的 --topbar-nav-shift(含票 102 的 -32u、票 103 的 -5vw
  3020. 与撞标题时的收敛条件),这里只引用,不再自带第二份公式。 */
  3021. transform: translateX(var(--topbar-nav-shift));
  3022. }
  3023. .cockpit-shell__mode {
  3024. position: relative;
  3025. height: calc(34 * var(--u));
  3026. padding: 0 calc(17 * var(--u));
  3027. border: 0;
  3028. /* 票 17 第七轮(按蓝湖 D2 nav 取证重做):设计稿里菜单就是「纯文字 + 选中态底板」——
  3029. 未选中 #00b8ff 常规字重(PingFang 14px,Apple 系统字体走回退栈),选中白色 + Semibold,
  3030. 底板 = `nav/title-bg` 切图(顶部青色亮线 + 向下衰减浅蓝板,90×34@2x)。
  3031. 此前的切角梯形 + 深蓝渐变 + 下划线 + 无界黑均非设计稿所有,全部撤除。
  3032. 票 17 第九轮 R3:white-space: nowrap —— 窄视口下 grid 挤压中列会让文字换行、
  3033. 34u 定高裁掉第二行(实测只剩"总/基/运"单字);菜单文字永不换行,
  3034. 顶栏三列改为允许纵向压缩而不是挤压按钮。 */
  3035. color: var(--cyan-hi);
  3036. font-size: var(--fs-body, 14px);
  3037. white-space: nowrap;
  3038. background: transparent;
  3039. cursor: pointer;
  3040. transition: color 0.18s, filter 0.18s;
  3041. }
  3042. .cockpit-shell__mode:hover {
  3043. color: var(--text-strong);
  3044. filter: brightness(1.15);
  3045. }
  3046. .cockpit-shell__mode:focus-visible {
  3047. outline: 1px solid var(--cyan);
  3048. outline-offset: 2px;
  3049. }
  3050. .cockpit-shell__mode.is-active {
  3051. color: var(--text-strong);
  3052. font-weight: 600;
  3053. /* 底板切图经语义 key 注入(--nav-active-bg,见模板 header 绑定);素材缺失时退化为
  3054. 设计稿主蓝的极淡渐变,选中态仍可辨。 */
  3055. background-image: var(--nav-active-bg, none),
  3056. linear-gradient(180deg, rgba(1, 171, 234, 0.28), transparent);
  3057. background-repeat: no-repeat;
  3058. background-size: 100% 100%;
  3059. }
  3060. /* 票 17 第七轮:选中按钮下方的光晕(设计稿 D2 `光 x=906 y=49 w=221 h=35`——实测中心 x=1016
  3061. 正对选中按钮「预警处置」中心 x=1017,即**光带跟着选中按钮走**,不是挂在 nav 中间)。
  3062. 票 17 第八轮:光晕主体(亮线在图片 44%)随基线上移——bottom 对齐基线上方 4u,
  3063. 光晕亮线压在按钮文字底下而不越过基线(R2:随 10u 保护区微调,top 100%−8u)。 */
  3064. .cockpit-shell__mode.is-active::after {
  3065. content: "";
  3066. position: absolute;
  3067. top: calc(100% - 8 * var(--u));
  3068. left: 50%;
  3069. transform: translateX(-50%);
  3070. width: calc(221 * var(--u));
  3071. height: calc(35 * var(--u));
  3072. background-image: var(--nav-glow-url, none);
  3073. background-repeat: no-repeat;
  3074. background-position: center;
  3075. background-size: contain;
  3076. pointer-events: none;
  3077. }
  3078. /* 票 103(维护者 2026-11-02:「归位、返回全球、时间这一栏需要整体向左移动,
  3079. 给页面右侧留出空隙」,留白定稿为整页宽的 15%):状态栏脱离 grid 居中流程,
  3080. 改为**绝对定位**。仍留在 grid 里的话,它左移只会把中列(菜单)挤走 ——
  3081. 那正是票 37 的旧形状;脱流后位移不再参与列宽分配,菜单位置只由
  3082. --topbar-nav-shift 决定,互不推挤。
  3083. right 取值 = --topbar-status-inset(15vw,撞到菜单或要出界时收敛),与菜单位移同源。
  3084. top 50% + translateY(-50%):按钮行仍在原有的 42u 内容区里垂直居中,
  3085. 底边离基线 4u 出血的关系不变(票 17 第八轮 R2)。 */
  3086. .cockpit-shell__top-meta {
  3087. position: absolute;
  3088. top: calc(50% - 5 * var(--u));
  3089. right: var(--topbar-status-inset);
  3090. transform: translateY(-50%);
  3091. display: flex;
  3092. align-items: center;
  3093. justify-content: flex-end;
  3094. gap: calc(10 * var(--u));
  3095. color: var(--text-2);
  3096. font-size: var(--fs-body, 14px);
  3097. white-space: nowrap;
  3098. }
  3099. /* 票 102(维护者:时间字体长短不平均,秒针一跳按钮就跟着左右挪):
  3100. 时钟改为**固定宽度的数字槽位**,槽位内右对齐 + 等宽数字(tabular-nums + tnum 兜底)。
  3101. 宽度按 2384×1160 截图实测:`--u` 在该视口 ≈1.433px(0.1235vh),一次读数 `21:22:22`
  3102. 的字形跨度 145px ≈ 101u,取 128u(+27% 余量)覆盖「把 1 换成 8」的最宽读数与字体回退
  3103. (Rajdhani → Bahnschrift → Segoe,等宽数字不被支持时)—— 槽位只要不吃到内容宽度,
  3104. 宽度就恒由这条声明决定:秒针跳动只改槽位内的字形,不再改动任何布局宽度。
  3105. flex: 0 0 auto —— 槽位不参与挤压,右列内容再多也不会压缩它。 */
  3106. .cockpit-shell__clock {
  3107. display: inline-block;
  3108. flex: 0 0 auto;
  3109. min-width: calc(128 * var(--u));
  3110. text-align: right;
  3111. font-variant-numeric: tabular-nums;
  3112. font-feature-settings: 'tnum' 1;
  3113. font-family: var(--num);
  3114. font-size: var(--fs-body, 14px);
  3115. letter-spacing: 0.06em;
  3116. color: var(--text-strong);
  3117. text-shadow: 0 0 12px rgba(1, 171, 234, 0.55);
  3118. }
  3119. /* ============================================================
  3120. 全局筛选条(压矮:38 设计像素)
  3121. ============================================================ */
  3122. .cockpit-shell__scope {
  3123. z-index: 3;
  3124. display: flex;
  3125. align-items: center;
  3126. justify-content: space-between;
  3127. gap: calc(10 * var(--u));
  3128. overflow: visible;
  3129. padding: 0 calc(10 * var(--u));
  3130. border: 1px solid rgba(1, 171, 234, 0.24);
  3131. background: linear-gradient(180deg, rgba(0, 31, 92, 0.72), rgba(0, 15, 52, 0.88));
  3132. box-shadow: inset 0 1px 0 rgba(1, 171, 234, 0.1), var(--shadow);
  3133. /* 票 17:第二行筛选条与顶栏同属"顶部菜单栏",字体保持一致(系统黑体),
  3134. 否则两行按钮字体一细一粗更难看。此处全为中文标签,无 --num 数字依赖。 */
  3135. font-family: var(--font-topbar);
  3136. }
  3137. .cockpit-shell__scope-left,
  3138. .cockpit-shell__scope-right {
  3139. display: flex;
  3140. align-items: center;
  3141. gap: calc(6 * var(--u));
  3142. white-space: nowrap;
  3143. min-width: 0;
  3144. }
  3145. .cockpit-shell__scope-left {
  3146. flex: 1 1 auto;
  3147. overflow-x: auto;
  3148. overflow-y: hidden;
  3149. scrollbar-width: none;
  3150. }
  3151. .cockpit-shell__scope-left::-webkit-scrollbar {
  3152. display: none;
  3153. }
  3154. .cockpit-shell__scope-right {
  3155. flex: 0 1 auto;
  3156. justify-content: flex-end;
  3157. max-width: 46%;
  3158. }
  3159. /* 票 67:管线/构件的片区口径说明(状态详情里的一条 chip,允许换行、限宽)。 */
  3160. .cockpit-shell__pipe-scope {
  3161. display: inline-block;
  3162. max-width: 46ch;
  3163. white-space: normal;
  3164. line-height: 1.35;
  3165. text-align: left;
  3166. }
  3167. .cockpit-shell__scope-label {
  3168. color: var(--muted);
  3169. font-size: var(--fs-caption, 11.5px);
  3170. letter-spacing: 0.08em;
  3171. }
  3172. .cockpit-shell__chips {
  3173. display: flex;
  3174. gap: calc(4 * var(--u));
  3175. }
  3176. .cockpit-shell__divider {
  3177. width: 1px;
  3178. height: calc(16 * var(--u));
  3179. margin: 0 calc(3 * var(--u));
  3180. background: linear-gradient(180deg, transparent, rgba(1, 171, 234, 0.5), transparent);
  3181. }
  3182. /* 范围 / 行业按钮:作用于整个驾驶舱的全局条件(切模式不重置) */
  3183. .cockpit-shell__chip {
  3184. display: inline-flex;
  3185. align-items: center;
  3186. padding: calc(2 * var(--u)) calc(9 * var(--u));
  3187. border: 1px solid rgba(1, 171, 234, 0.32);
  3188. background: rgba(0, 20, 72, 0.6);
  3189. color: var(--text-2);
  3190. font: inherit;
  3191. /* 2026-10-12:走查反馈偏小,由 10.5 上调到 11.5。 */
  3192. font-size: var(--fs-caption, 11.5px);
  3193. letter-spacing: 0.04em;
  3194. white-space: nowrap;
  3195. clip-path: polygon(4px 0, 100% 0, 100% calc(100% - 4px), calc(100% - 4px) 100%, 0 100%, 0 4px);
  3196. cursor: pointer;
  3197. transition: all 0.16s;
  3198. }
  3199. /* 批次 1:行业筛选按钮的图标。用 margin 而非 gap —— 只有带图标的按钮才需要间距,
  3200. 不改通用 chip 的排版,避免影响范围/视图等其他同款按钮。 */
  3201. .cockpit-shell__industry-icon {
  3202. flex: none;
  3203. margin-right: calc(4 * var(--u));
  3204. text-shadow: none;
  3205. }
  3206. .cockpit-shell__chip:hover {
  3207. color: var(--text-strong);
  3208. border-color: rgba(1, 171, 234, 0.6);
  3209. background: rgba(0, 82, 168, 0.62);
  3210. }
  3211. .cockpit-shell__chip:focus-visible {
  3212. outline: 1px solid var(--cyan);
  3213. outline-offset: 2px;
  3214. }
  3215. .cockpit-shell__chip.is-active {
  3216. color: var(--text-strong);
  3217. border-color: rgba(0, 184, 255, 0.85);
  3218. background: linear-gradient(180deg, rgba(1, 171, 234, 0.85), rgba(0, 82, 168, 0.85));
  3219. box-shadow: inset 0 0 16px rgba(1, 171, 234, 0.35), 0 0 14px rgba(1, 171, 234, 0.35);
  3220. text-shadow: 0 0 10px rgba(180, 240, 255, 0.9);
  3221. }
  3222. .cockpit-shell__scope-note {
  3223. color: var(--muted);
  3224. font-size: var(--fs-caption, 11.5px);
  3225. letter-spacing: 0.04em;
  3226. }
  3227. /* 票 08:地图摘要仍是状态详情的一行,收起时由上层摘要按钮替代其横向占位。 */
  3228. .cockpit-shell__map-summary {
  3229. display: flex;
  3230. align-items: center;
  3231. gap: calc(5 * var(--u));
  3232. min-width: 0;
  3233. overflow: hidden;
  3234. flex-wrap: wrap;
  3235. }
  3236. .cockpit-shell__map-summary-counts {
  3237. min-width: 0;
  3238. max-width: min(420px, 40vw);
  3239. overflow: hidden;
  3240. color: var(--muted);
  3241. font-size: var(--fs-caption, 10.5px);
  3242. letter-spacing: 0.02em;
  3243. text-overflow: ellipsis;
  3244. white-space: nowrap;
  3245. }
  3246. .cockpit-shell__status-summary {
  3247. position: relative;
  3248. flex: 0 1 auto;
  3249. min-width: min(220px, 28vw);
  3250. max-width: min(520px, 42vw);
  3251. }
  3252. .cockpit-shell__status-toggle {
  3253. display: flex;
  3254. align-items: center;
  3255. gap: calc(6 * var(--u));
  3256. width: 100%;
  3257. min-height: calc(28 * var(--u));
  3258. padding: calc(3 * var(--u)) calc(8 * var(--u));
  3259. border: 1px solid rgba(1, 171, 234, 0.32);
  3260. background: rgba(0, 20, 72, 0.72);
  3261. color: var(--text-2);
  3262. font: inherit;
  3263. font-size: var(--fs-caption, 11.5px);
  3264. text-align: left;
  3265. cursor: pointer;
  3266. clip-path: polygon(5px 0, 100% 0, 100% calc(100% - 5px), calc(100% - 5px) 100%, 0 100%, 0 5px);
  3267. }
  3268. .cockpit-shell__status-toggle:hover,
  3269. .cockpit-shell__status-toggle:focus-visible {
  3270. border-color: rgba(1, 171, 234, 0.75);
  3271. color: var(--text-strong);
  3272. outline: none;
  3273. }
  3274. .cockpit-shell__status-toggle [data-status-summary] {
  3275. flex: 1;
  3276. min-width: 0;
  3277. overflow: hidden;
  3278. text-overflow: ellipsis;
  3279. white-space: nowrap;
  3280. }
  3281. .cockpit-shell__status-dot {
  3282. width: calc(7 * var(--u));
  3283. height: calc(7 * var(--u));
  3284. flex: none;
  3285. border-radius: 50%;
  3286. background: var(--muted, #5680b0);
  3287. box-shadow: 0 0 8px currentColor;
  3288. }
  3289. .cockpit-shell__status-dot.is-ok {
  3290. background: var(--lv4, #27d17a);
  3291. color: var(--lv4, #27d17a);
  3292. }
  3293. .cockpit-shell__status-dot.is-warning {
  3294. background: var(--lv2, #ffb020);
  3295. color: var(--lv2, #ffb020);
  3296. }
  3297. .cockpit-shell__status-chevron {
  3298. color: var(--cyan, #01abea);
  3299. font-size: var(--fs-body, 14px);
  3300. line-height: 1;
  3301. }
  3302. .cockpit-shell__status-details {
  3303. position: absolute;
  3304. z-index: 20;
  3305. top: calc(100% + 5 * var(--u));
  3306. right: 0;
  3307. display: grid;
  3308. gap: calc(6 * var(--u));
  3309. width: min(560px, 48vw);
  3310. max-width: calc(100vw - 24 * var(--u));
  3311. max-height: min(62vh, 520px);
  3312. /* 2026-10-13:严格只竖向滚动(状态详情浮层同理)。 */
  3313. overflow-y: auto;
  3314. overflow-x: hidden;
  3315. padding: calc(9 * var(--u));
  3316. border: 1px solid rgba(1, 171, 234, 0.42);
  3317. border-radius: calc(8 * var(--u, 1px));
  3318. background: rgba(1, 5, 20, 0.96);
  3319. box-shadow: 0 14px 32px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(130, 230, 255, 0.1);
  3320. }
  3321. .cockpit-shell__status-details > * {
  3322. min-width: 0;
  3323. }
  3324. .cockpit-shell__refresh-action {
  3325. flex: none;
  3326. min-width: calc(58 * var(--u));
  3327. justify-content: center;
  3328. gap: calc(5 * var(--u));
  3329. }
  3330. .cockpit-shell__refresh-glyph {
  3331. font-size: var(--fs-title, 15.5px);
  3332. line-height: 1;
  3333. }
  3334. /* 票 61:统一刷新进行中 —— 图标转动 + 一行「刷新中」小字(可见进度),
  3335. 按钮同时 :disabled + aria-busy(走查断言面 data-refresh-state)。 */
  3336. .cockpit-shell__refresh-action.is-refreshing .cockpit-shell__refresh-glyph {
  3337. animation: refresh-action-spin 0.9s linear infinite;
  3338. }
  3339. .cockpit-shell__refresh-progress {
  3340. font-size: var(--fs-meta, 9.5px);
  3341. line-height: 1;
  3342. color: var(--cyan, #01abea);
  3343. white-space: nowrap;
  3344. }
  3345. @keyframes refresh-action-spin {
  3346. to {
  3347. transform: rotate(360deg);
  3348. }
  3349. }
  3350. /* 状态点:加载中呼吸、完成转绿、失败/过期转红 —— 颜色语义与小胶囊共存。 */
  3351. .cockpit-shell__map-summary-dot {
  3352. flex: none;
  3353. width: calc(6 * var(--u));
  3354. height: calc(6 * var(--u));
  3355. border-radius: 50%;
  3356. background: var(--lv2, #ffb020);
  3357. animation: map-summary-breathe 1.8s ease-in-out infinite;
  3358. }
  3359. .cockpit-shell__map-summary[data-map-summary-phase='complete'] .cockpit-shell__map-summary-dot {
  3360. background: var(--lv4, #27d17a);
  3361. animation: none;
  3362. }
  3363. .cockpit-shell__map-summary[data-map-summary-phase='failed'] .cockpit-shell__map-summary-dot,
  3364. .cockpit-shell__map-summary[data-map-summary-phase='expired'] .cockpit-shell__map-summary-dot {
  3365. background: var(--lv1, #ff3b52);
  3366. animation: none;
  3367. }
  3368. @keyframes map-summary-breathe {
  3369. 0%, 100% { opacity: 1; }
  3370. 50% { opacity: 0.3; }
  3371. }
  3372. .cockpit-shell__map-summary-text {
  3373. max-width: calc(150 * var(--u));
  3374. overflow: hidden;
  3375. color: var(--text-2);
  3376. font-size: var(--fs-caption, 11.5px);
  3377. letter-spacing: 0.03em;
  3378. text-overflow: ellipsis;
  3379. white-space: nowrap;
  3380. }
  3381. /* 加载中 / 快照失效时给状态词换色,让「还能不能继续取」一眼可辨。 */
  3382. .cockpit-shell__map-summary[data-map-summary-phase='expired'] .cockpit-shell__map-summary-text,
  3383. .cockpit-shell__map-summary[data-map-summary-phase='failed'] .cockpit-shell__map-summary-text {
  3384. color: var(--lv1);
  3385. }
  3386. .cockpit-shell__map-summary[data-map-summary-phase='complete'] .cockpit-shell__map-summary-text {
  3387. color: var(--lv4);
  3388. }
  3389. /* 票 05:共享分区状态板。横向排列、可换行;空间不够时先压这一块,不去挤筛选按钮。 */
  3390. .cockpit-shell__sections {
  3391. display: flex;
  3392. align-items: center;
  3393. gap: calc(4 * var(--u));
  3394. flex-wrap: nowrap;
  3395. /* 票 08:显式允许收缩——筛选条在 1280 宽时靠它和地图摘要块一起让位。 */
  3396. flex-shrink: 1;
  3397. min-width: 0;
  3398. overflow: hidden;
  3399. }
  3400. /* 票 17:定位失败反馈。用范围色(不是错误色)——「不在已加载范围内」是提示,不是故障。 */
  3401. .cockpit-shell__locate {
  3402. color: var(--lv2, #ffb020);
  3403. border-color: rgba(255, 176, 32, 0.5);
  3404. }
  3405. /*
  3406. 票 38(第 5 条):定位失败的可见反馈浮层。挂在 `<main>` 底部居中——
  3407. 两张面板栏之间、地图之上,不随「状态详情」的折叠而消失(那正是「点了没反应」的来源)。
  3408. pointer-events 只给关闭按钮以外的胶囊本体与边框(浮层不该挡地图操作)。
  3409. */
  3410. .cockpit-shell__notice {
  3411. position: absolute;
  3412. z-index: 6;
  3413. /*
  3414. * 票 48:本浮层与底部图例同处一张图的底部带,必须起算在图例**之上**,
  3415. * 否则图例贴底后会被这条反馈压住(或互相叠字)。偏移量读共享的
  3416. * --map-bottom-band,而不是在这里另写一个数——两处各写魔法数是漂移的根。
  3417. */
  3418. bottom: calc(var(--map-bottom-band) + 4 * var(--u));
  3419. left: 50%;
  3420. transform: translateX(-50%);
  3421. display: flex;
  3422. align-items: center;
  3423. gap: calc(6 * var(--u));
  3424. /* 让位宽度用 --rail-w(宽屏时是两条栏宽),不用 --column-w —— 否则宽屏下浮层压面板。 */
  3425. max-width: min(72%, calc(100% - 2 * var(--rail-w)));
  3426. pointer-events: none;
  3427. }
  3428. .cockpit-shell__notice-chip {
  3429. min-width: 0;
  3430. padding: calc(4 * var(--u)) var(--space-2);
  3431. border: 1px solid rgba(255, 176, 32, 0.5);
  3432. border-radius: calc(8 * var(--u));
  3433. background: rgba(2, 10, 20, 0.88);
  3434. box-shadow: var(--shadow);
  3435. font-family: var(--font-topbar);
  3436. font-size: var(--fs-caption, 11.5px);
  3437. white-space: nowrap;
  3438. overflow: hidden;
  3439. text-overflow: ellipsis;
  3440. }
  3441. .cockpit-shell__notice-close {
  3442. pointer-events: auto;
  3443. padding: calc(3 * var(--u)) calc(8 * var(--u));
  3444. border: 1px solid rgba(1, 171, 234, 0.4);
  3445. border-radius: calc(8 * var(--u));
  3446. background: rgba(2, 10, 20, 0.88);
  3447. color: var(--text-2, #88b7e8);
  3448. font-family: var(--font-topbar);
  3449. font-size: var(--fs-caption, 11.5px);
  3450. cursor: pointer;
  3451. }
  3452. .cockpit-shell__notice-close:hover {
  3453. color: var(--text-strong);
  3454. border-color: rgba(1, 171, 234, 0.7);
  3455. }
  3456. /* 票 15:状态推送连接状态。连上时是常态色(正常运行),未连上/鉴权失败转告警色。 */
  3457. .cockpit-shell__ws {
  3458. color: var(--muted, #5680b0);
  3459. }
  3460. /* 票 38:自建雾读数。生效/待命用常态色;不可用或降级转注意色(**不使用错误色** ——
  3461. 雾不可用属"能力降级、业务照常",不是故障;与票 05 的分区状态同一条立场)。 */
  3462. .cockpit-shell__fog {
  3463. color: var(--muted, #5680b0);
  3464. }
  3465. .cockpit-shell__fog[data-fog-state='ready'][data-fog-phase='locked'] {
  3466. color: var(--lv3, #01abea);
  3467. border-color: rgba(1, 171, 234, 0.4);
  3468. }
  3469. .cockpit-shell__fog[data-fog-degrade='reduced'],
  3470. .cockpit-shell__fog[data-fog-degrade='off'],
  3471. .cockpit-shell__fog.is-bad {
  3472. color: var(--lv2, #ffb020);
  3473. border-color: rgba(255, 176, 32, 0.45);
  3474. }
  3475. .cockpit-shell__ws[data-ws-state='open'] {
  3476. color: var(--lv4, #27d17a);
  3477. border-color: rgba(53, 227, 154, 0.4);
  3478. }
  3479. .cockpit-shell__ws.is-bad {
  3480. color: var(--lv1, #ff3b52);
  3481. border-color: rgba(255, 59, 82, 0.45);
  3482. }
  3483. /* 票 16:新鲜度。新鲜=常态色;**过期必须显眼**(保留旧值但不能被当成实时);不可用=告警色。 */
  3484. .cockpit-shell__freshness[data-freshness='current'] {
  3485. color: var(--lv4, #27d17a);
  3486. }
  3487. .cockpit-shell__freshness[data-freshness='empty'] {
  3488. color: var(--muted, #5680b0);
  3489. }
  3490. .cockpit-shell__freshness.is-stale {
  3491. color: var(--lv2, #ffb020);
  3492. border-color: rgba(255, 176, 32, 0.55);
  3493. }
  3494. .cockpit-shell__freshness.is-bad {
  3495. color: var(--lv1, #ff3b52);
  3496. border-color: rgba(255, 59, 82, 0.45);
  3497. }
  3498. /* 「部分失败」的补充说明:同一枚胶囊里再补一句,不另起一块浮层压住一张图。 */
  3499. .cockpit-shell__freshness-extra {
  3500. color: var(--lv2, #ffb020);
  3501. font-weight: 700;
  3502. }
  3503. /* ============================================================
  3504. 主体:一张图铺满背景,左右两栏浮在图上
  3505. ============================================================ */
  3506. .cockpit-shell__main {
  3507. position: relative;
  3508. min-height: 0;
  3509. }
  3510. .cockpit-shell__map {
  3511. position: absolute;
  3512. inset: 0;
  3513. z-index: var(--z-map);
  3514. }
  3515. /* 局部增强允许覆盖一张图,保持外壳交互层高于两侧业务栏。
  3516. 票 90:宽高**只在组件里声明一处**(它相对一张图自适应);这条只管层级与命中,
  3517. 不再重复写尺寸 —— 两处各写一份正是「改一处、另一处不跟着变」的来源。 */
  3518. .cockpit-shell__main > .cockpit-shell__enhancement {
  3519. z-index: calc(var(--z-columns) + 1);
  3520. pointer-events: auto;
  3521. }
  3522. .cockpit-shell__column {
  3523. position: absolute;
  3524. top: 0;
  3525. bottom: 0;
  3526. z-index: var(--z-columns);
  3527. display: flex;
  3528. flex-direction: column;
  3529. gap: calc(8 * var(--u));
  3530. /* 栏宽是共享的布局尺寸:两级详情浮层要贴着它让位(见 styles/tokens.css 的 --column-w)。 */
  3531. width: var(--column-w);
  3532. min-height: 0;
  3533. pointer-events: none;
  3534. }
  3535. .cockpit-shell__column > * {
  3536. pointer-events: auto;
  3537. }
  3538. .cockpit-shell__column.is-left { left: 0; }
  3539. .cockpit-shell__column.is-right { right: 0; }
  3540. /* ============================================================
  3541. 超宽屏(长宽比 >= 3:1):**只改栏内的排列方向,不动两栏的位置**
  3542. ============================================================
  3543. 维护者 2026-10-23(第二次澄清):面板宽度还是固定的,且依然将面板进行左右分区、
  3544. 留出中间的一张图部分;只是在屏幕比例由 16:9 变为超宽屏(3:1)时,两侧面板由
  3545. 分别的上下排列变为左右排列,其依然分布在屏幕两侧。
  3546. 这里**不**把两栏挪去上下半屏(那是更早一版的理解错误),只做两件事:
  3547. 1. 两栏仍在左右两侧、中央留出一张图(位置规则不变);
  3548. 2. 栏**内**两块面板由竖排改并排 —— 否则两块会在一条窄栏里各自挤成细条。
  3549. **判据改用视口媒体查询**(比例取自维护者给的实例 3456×1239,约 2.79)。
  3550. 不再用 @container 的两个理由:
  3551. · 换算要扣顶栏/筛选条/内边距,扣多少还随高度变,门槛值会漂移;
  3552. · @container 的**查询容器不能被自己的查询命中** —— 早先把 --rail-w 写在
  3553. `.cockpit-shell__main` 上,那条规则从未生效,栏宽一直是 --column-w,
  3554. 于是栏内两块面板要么被压窄、要么溢出(前几轮全部翻车于此)。
  3555. 代价:微前端宿主里量的是视口而非外壳;本驾驶舱是整页应用,可接受。
  3556. **并排的唯一规则:每块面板宽度 = 竖排时的一条栏宽(--column-w),一分不差。**
  3557. (维护者 2026-10-23 澄清两次后的定稿:宽度观感必须与并排前一致,
  3558. 相当于「收起一块、另一块独占一整条」。)
  3559. 这条规则把前几轮的错误都排除掉:
  3560. · 不给面板百分比 basis(那会随栏宽变化而收窄);
  3561. · 不设栏宽上限(百分比/像素上限一旦生效,就只剩「把面板压窄」一条路);
  3562. · 不用宽度门槛去拒绝并排(观感一致性不该取决于屏幕多宽)。
  3563. 栏宽自然变成「两块原宽 + 间隙」,中央一张图让出这一段,仍夹在两栏之间。
  3564. 注意 --u 已改为**按视口高度**缩放(tokens.css):只加宽不加高的屏上元素不再放大,
  3565. 所以「两块原宽」在超宽屏上是 2×440px 这类绝对宽度,并排后不会挤占中央。 */
  3566. /* 3456×1239 约等于 2.79:维护者给出的实例宽度比 —— 到此比例开始并排。 */
  3567. @media (min-aspect-ratio: 3456 / 1239) {
  3568. /*
  3569. 栏内改并排。**每块面板的宽度与竖排时完全相同**(都是一条 --column-w)——
  3570. 维护者 2026-10-23 澄清两次后定稿的语义:
  3571. 「变为并排后,面板的宽度观感应与并排前一致,不应变为收窄的观感
  3572. (类似于将同侧一块面板收起而独占一整条的观感)」。
  3573. 栏的位置(left/right)仍不动,中央一张图照旧夹在中间。
  3574. */
  3575. /* 让位宽度随之翻倍(中央浮层/事件详情/详情卡都吃这一条)。
  3576. 正常比例回落到 tokens 的 `--rail-w: var(--column-w)`。
  3577. 现在写在外壳自己身上是**安全的**:媒体查询不要求「查询容器不能被自身命中」,
  3578. 而早先用 @container 时这条规则对容器自身不生效 —— 那正是「面板被压窄 / 出框」的根因。 */
  3579. .cockpit-shell__main {
  3580. --rail-w: calc(2 * var(--column-w) + calc(8 * var(--u, 1px)));
  3581. }
  3582. .cockpit-shell__column {
  3583. flex-direction: row;
  3584. /* 栏宽 = 两块面板原宽 + 间隙(此时每块正好回到 --column-w 的设计观感)。 */
  3585. width: var(--rail-w);
  3586. }
  3587. /* 收起时整栏内容朝**外缘**靠齐:左栏贴左、右栏贴右 ——
  3588. 收起留下的空白落在靠中央一侧,于是原先被遮住的一张图在那里露出来。 */
  3589. .cockpit-shell__column.is-left { justify-content: flex-start; }
  3590. .cockpit-shell__column.is-right { justify-content: flex-end; }
  3591. .cockpit-shell__column > .cockpit-panel {
  3592. min-width: 0;
  3593. /* 并排后每块的宽度**就等于一条栏宽 --column-w** —— 维护者 2026-10-23 原话:
  3594. 「变为并排后,面板的宽度观感应与并排前一致,不应变为收窄的观感
  3595. (类似于将同侧一块面板收起而独占一整条的观感)」。
  3596. 所以写死 0 0 var(--column-w):不放大、不收缩、不吃百分比。
  3597. 栏宽随之变成「两块原宽 + 间隙」,两边正好铺满,中央留一整条给一张图。
  3598. grow 与 shrink 都是 0:宁可让栏超出容器被裁,也不把面板压窄 ——
  3599. 压窄的同时 --u 的字号不变,观感就是「变窄、变形」。 */
  3600. flex: 0 0 var(--column-w);
  3601. }
  3602. /* 收起态:缩成**固定宽度的书签**,并把整块连背景板一起收窄
  3603. (旧版只写 `flex: 0 0 auto`,而标题栏自然宽度接近一整条栏宽 —— 宽屏下看起来毫无变化,
  3604. 这正是维护者反馈「宽屏收起不生效」的根因)。
  3605. 书签贴外缘:左栏的收起面板排到最前(order:-1),右栏的排到最后(order:1);
  3606. 同侧未收起的面板因此向该侧靠齐,让出靠中央的空间给一张图。 */
  3607. .cockpit-shell__column > .cockpit-panel.is-collapsed {
  3608. flex: 0 0 var(--bookmark-w);
  3609. width: var(--bookmark-w);
  3610. min-width: var(--bookmark-w);
  3611. max-width: var(--bookmark-w);
  3612. }
  3613. .cockpit-shell__column.is-left > .cockpit-panel.is-collapsed { order: -1; }
  3614. .cockpit-shell__column.is-right > .cockpit-panel.is-collapsed { order: 1; }
  3615. }
  3616. /* 票 10:两级详情浮层。贴在两栏之间的空档里、右栏左侧,
  3617. 宽度与栏同量级;高度由内容决定、超长时卡片自己滚动。
  3618. 2026-10-13 维护者反馈设备详情面板太窄:340→380u(上限 420→460px)。
  3619. 2026-11-05 维护者要求采集记录表不横向滚动:480→520u(上限 560→620px),所有详情面板同宽。 */
  3620. .cockpit-shell__detail {
  3621. position: absolute;
  3622. z-index: var(--z-columns);
  3623. top: 0;
  3624. /* 让位宽度用 --rail-w:宽屏时右栏是两条栏宽,详情卡要避开整条栏。 */
  3625. right: calc(var(--rail-w) + var(--space-2));
  3626. /* 宽度上限同时受 rail-w 约束:宽屏时两条栏宽之外才是留给详情的空间。 */
  3627. width: min(calc(100% - 2 * var(--rail-w) - 24px), clamp(460px, calc(520 * var(--u)), 620px));
  3628. max-height: 100%;
  3629. min-height: 0;
  3630. display: flex;
  3631. flex-direction: column;
  3632. pointer-events: auto;
  3633. }
  3634. /* 票 41:锚定形态。层级**低于**四个详情窗(R-3:允许被侧栏遮盖),
  3635. 只避开画布边缘、允许被画布裁切(R-2),唯一隐藏条件是窗口完全离开画面(R-4)。 */
  3636. .cockpit-shell__detail.is-anchored {
  3637. z-index: 1;
  3638. right: auto;
  3639. /* 内容不足时按内容高(不留空白);超长时由 JS 钉住高度、卡内滚动接管。 */
  3640. max-height: min(80%, 100%);
  3641. /* 允许被画布边缘裁切:不因此整体消失(规格 R-2)。 */
  3642. overflow: hidden;
  3643. border: 1px solid var(--panel-line-hi, #01abea);
  3644. border-radius: calc(8 * var(--u, 1px));
  3645. /* 2026-10-23:背景与磨砂归**内层卡片**(.point-detail)单层持有 ——
  3646. 外层再叠一份渐变会双层相加(有效不透明度 ≈0.96),比两侧面板实得多;
  3647. 去掉后锚定/固定两态与两侧面板完全同款(半透明 token 背景 + 16px 磨砂)。 */
  3648. box-shadow: var(--shadow, 0 18px 44px rgba(0, 0, 0, 0.55));
  3649. }
  3650. /* 维护者 2026-10-30 15:57 细节2:台账(左栏)打开且无地图位置的设施详情固定到台账侧 ——
  3651. 镜像右侧固定位的让位方式(--rail-w + --space-2),宽度仍由基类 .cockpit-shell__detail 给。 */
  3652. .cockpit-shell__detail.is-fixed-left {
  3653. right: auto;
  3654. left: calc(var(--rail-w) + var(--space-2));
  3655. }
  3656. /* 归属短线:从图标外缘指向卡片,`transform-origin` 在左端,长度由 JS 给。 */
  3657. .cockpit-shell__anchor-lead {
  3658. position: absolute;
  3659. z-index: 1;
  3660. height: 1px;
  3661. transform-origin: 0 50%;
  3662. background: linear-gradient(90deg, rgba(1, 171, 234, 0.85), rgba(1, 171, 234, 0.25));
  3663. box-shadow: 0 0 6px rgba(1, 171, 234, 0.5);
  3664. pointer-events: none;
  3665. }
  3666. /* 暂隐时的顶栏入口:与其它 chip 同形,动作按钮收在文字后面。 */
  3667. .cockpit-shell__anchor-status {
  3668. color: var(--lv2, #ffb020);
  3669. border-color: rgba(255, 176, 32, 0.5);
  3670. display: inline-flex;
  3671. align-items: center;
  3672. gap: calc(4 * var(--u));
  3673. }
  3674. .cockpit-shell__anchor-status button {
  3675. padding: 0 calc(4 * var(--u));
  3676. border: 1px solid rgba(255, 176, 32, 0.5);
  3677. border-radius: calc(8 * var(--u, 1px));
  3678. background: rgba(0, 20, 72, 0.6);
  3679. color: inherit;
  3680. font: inherit;
  3681. cursor: pointer;
  3682. }
  3683. .cockpit-shell__anchor-status button:hover,
  3684. .cockpit-shell__anchor-status button:focus-visible {
  3685. color: var(--text-strong);
  3686. border-color: rgba(255, 176, 32, 0.9);
  3687. outline: none;
  3688. }
  3689. .cockpit-shell__event-detail {
  3690. position: absolute;
  3691. z-index: 5;
  3692. top: 24px;
  3693. left: calc(var(--rail-w) + 24 * var(--u));
  3694. width: min(480px, calc(100% - var(--rail-w) - 48 * var(--u)));
  3695. max-height: calc(100% - 48px);
  3696. overflow-y: auto;
  3697. overflow-x: hidden;
  3698. border: 1px solid var(--panel-line, rgba(1, 171, 234, 0.35));
  3699. border-radius: calc(8 * var(--u, 1px));
  3700. /* 票 69:与两侧面板同一套「半透明三停 + 磨砂」语言,逐值同源(token + 16px 同值)。
  3701. 此前这里是不透明 `linear-gradient(--panel-top, --panel-bot), var(--bg-0)`,再叠内层卡片自己的
  3702. 深色渐变 —— 两层相加后比两侧面板实得多,就是「CockpitPanel 一句话、事件详情另一样」的来源。
  3703. 背景与磨砂**只在这一层持有**,内层卡片(EventDetailCard)必须保持透明,否则又变双层。 */
  3704. background: linear-gradient(
  3705. 180deg,
  3706. var(--panel-top, rgba(2, 9, 27, 0.28)) 0%,
  3707. var(--panel-mid, rgba(0, 53, 156, 0.2)) 26%,
  3708. var(--panel-bot, rgba(0, 15, 52, 0.38)) 100%
  3709. );
  3710. backdrop-filter: blur(16px) saturate(115%);
  3711. -webkit-backdrop-filter: blur(16px) saturate(115%);
  3712. box-shadow: var(--shadow);
  3713. }
  3714. </style>