CockpitShell.vue 194 KB

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