CockpitShell.vue 191 KB

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