CockpitShell.vue 187 KB

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