zengy 7 часов назад
Родитель
Сommit
2edf7a4c34

+ 46 - 13
src/modules/cockpit/CockpitShell.vue

@@ -955,6 +955,35 @@ const locateFeedback = computed(() => {
     return current
 })
 
+/** 离开 /cockpit 后不再启动延迟任务(重图层空闲加载可能晚于卸载)。 */
+let shellDisposed = false
+
+/**
+ * 统一登记的延迟回调:视图切换重试、进区/归位重试、900ms 状态刷新等。
+ * 卸载时一律清掉,避免离开后仍写 store / 操作相机。
+ */
+const deferredTimers = new Set()
+function defer(task, ms) {
+    const id = window.setTimeout(() => {
+        deferredTimers.delete(id)
+        if (!shellDisposed) task()
+    }, ms)
+    deferredTimers.add(id)
+    return id
+}
+function clearDeferredTimers() {
+    for (const id of deferredTimers) window.clearTimeout(id)
+    deferredTimers.clear()
+}
+
+let spinTimer = null
+function clearSpinTimer() {
+    if (spinTimer !== null) {
+        window.clearInterval(spinTimer)
+        spinTimer = null
+    }
+}
+
 /**
  * 票 38:反馈浮层自动收起。失败提示要**当场看得见**(不再藏在折叠面板里),
  * 但也不能常驻——值班人员接着点下一个点位时,上一条的说明早该走了。
@@ -1138,7 +1167,7 @@ function switchViewMode(next) {
             areaLimits.value = getAreaLimits()
             return
         }
-        window.setTimeout(apply, 250)
+        defer(apply, 250)
     }
     apply()
 }
@@ -1846,9 +1875,6 @@ function requestRefresh(options = {}) {
  */
 const loadedPanelModes = new Set()
 
-/** 离开 /cockpit 后不再启动延迟任务(重图层空闲加载可能晚于卸载)。 */
-let shellDisposed = false
-
 /** 首屏帧之后/浏览器空闲时再跑重任务;不支持 requestIdleCallback 时退化为一次短延时。 */
 function scheduleIdle(task) {
     if (typeof window === 'undefined') return
@@ -1858,7 +1884,7 @@ function scheduleIdle(task) {
     if (typeof window.requestIdleCallback === 'function') {
         window.requestIdleCallback(run, { timeout: 1200 })
     } else {
-        window.setTimeout(run, 200)
+        defer(run, 200)
     }
 }
 
@@ -2025,7 +2051,7 @@ function returnToGlobal() {
     syncAreaState()
     if (result.applied) {
         // 回全球后不久就该由闲置计时接管(回引导页),先把按钮状态刷一次。
-        window.setTimeout(refreshHomeState, 900)
+        defer(refreshHomeState, 900)
     }
     return result
 }
@@ -2056,13 +2082,13 @@ function enterSystem() {
     const fly = () => {
         tries += 1
         if (goHome({ immediate: false }) || tries >= 40) {
-            window.setTimeout(refreshHomeState, 900)
+            defer(refreshHomeState, 900)
             return
         }
-        window.setTimeout(fly, 250)
+        defer(fly, 250)
     }
     fly()
-    window.setTimeout(refreshHomeState, 900)
+    defer(refreshHomeState, 900)
 }
 
 function refreshHomeState() {
@@ -2146,10 +2172,10 @@ function returnHome() {
     const fly = () => {
         tries += 1
         if (goHome({ immediate: false }) || tries >= 40) {
-            window.setTimeout(refreshHomeState, 900)
+            defer(refreshHomeState, 900)
             return
         }
-        window.setTimeout(fly, 250)
+        defer(fly, 250)
     }
     fly()
 }
@@ -2266,6 +2292,7 @@ onMounted(() => {
 
     // 票 04:配置只在这个入口载入一次(服务内部有缓存),地图服务按需 await 同一份。
     loadCockpitConfig().then(async (result) => {
+        if (shellDisposed) return
         configState.value = result
         // 配置到手才知道引导开关与预设坐标,重新取一次。
         intro.value = getIntroConfig()
@@ -2290,9 +2317,11 @@ onMounted(() => {
         monitoringStore.configure({ config: result.config })
         eventStore.configure({ config: result.config })
         for (const action of plan.actions) {
+            if (shellDisposed) return
             if (action === STARTUP_ACTION.REGISTER_MOCKS) {
                 // 只有 mock 模式才需要样例包;real 的首屏不加载它。
                 const { ensureCockpitMocks } = await import('./mocks/index.js')
+                if (shellDisposed) return
                 ensureCockpitMocks()
                 continue
             }
@@ -2370,6 +2399,7 @@ onMounted(() => {
                 })
             }
         }
+        if (shellDisposed) return
         // 票 02:泵站类型字典独立于面板取数;只在成功后注入,失败保持「类型未发布」不猜。
         fetchPumpStationTypeDict({ config: result.config }).then((section) => {
             if (section.state === 'success') setPumpTypeLabels(section.data)
@@ -2384,8 +2414,9 @@ onMounted(() => {
     // 引导期间显示自转;进入后停(引擎就绪前调用会被忽略,等引擎 ready 再兜一次)。
     if (intro.value.enabled) {
         setGlobeSpin(intro.value.spinSeconds)
-        const spinTimer = setInterval(() => {
-            if (!introVisible.value || setGlobeSpin(intro.value.spinSeconds)) clearInterval(spinTimer)
+        clearSpinTimer()
+        spinTimer = setInterval(() => {
+            if (!introVisible.value || setGlobeSpin(intro.value.spinSeconds)) clearSpinTimer()
         }, 600)
     } else {
         // 票 37:`intro.enabled=false`(走查自隔离)时**按 global 自由视角启动、不弹引导页**
@@ -2581,6 +2612,8 @@ onBeforeUnmount(() => {
     entityDetailStore.close()
 
     if (homeTimer) clearInterval(homeTimer)
+    clearSpinTimer()
+    clearDeferredTimers()
     // 票 41:锚定跟随的帧订阅与尺寸监听必须拆掉(与票 15/37 的"漏取消定时器"是同一个坑)。
     if (stopMapFrame) {
         stopMapFrame()

+ 3 - 3
src/modules/cockpit/stores/deviceLayerStore.js

@@ -15,7 +15,7 @@
  *      翻页只往合并态追加对象;**同一点位、同一份清单**算出的计划不变,就不重画
  *      (见 `lastPlanKey`),所以翻页不会让设备图层闪烁或重取。
  */
-import { ref } from 'vue'
+import { markRaw, ref, shallowRef } from 'vue'
 import { defineStore } from 'pinia'
 import {
     DEVICE_LAYER_KIND,
@@ -60,7 +60,7 @@ export const useDeviceLayerStore = defineStore('deviceLayerStore', () => {
     const pointCode = ref('')
 
     /** 全部关联设备行(**保留全部**,含不上图的;界面清单与计数都读它)。 */
-    const rows = ref([])
+    const rows = shallowRef([])
 
     /** 互斥计数(`drawn`/`no-location`/`hidden`/`pending`/`inconsistent`/`unavailable`)。 */
     const counts = ref({})
@@ -248,7 +248,7 @@ export const useDeviceLayerStore = defineStore('deviceLayerStore', () => {
         })
 
         pointCode.value = code
-        rows.value = withAssets
+        rows.value = markRaw(withAssets)
         counts.value = plan.counts
         // 总数=当前快照去重 deviceCodes 条数(**不是** rows.length:清单含详情独有那几行)。
         total.value = plan.total

+ 25 - 10
src/modules/cockpit/stores/eventStore.js

@@ -22,7 +22,7 @@
  * ② 定时刷新/同条件重取**不复位**(条文 6 的反面),越界由回显夹回最后一页;
  * ③ 翻一页只重取该分区(不牵连另外三块面板),并用同一 token 作废迟到的页响应。
  */
-import { computed, ref } from 'vue'
+import { computed, ref, shallowRef } from 'vue'
 import { defineStore } from 'pinia'
 import { SECTION_STATE, section } from '../domain/sectionState.js'
 import { REQUEST_REASON } from '../domain/requestReason.js'
@@ -37,6 +37,7 @@ import { eventTimeWindow, historyWindows } from '../domain/eventRange.js'
 import { fetchEventAnalysis, fetchEventHistory, fetchHandlingEfficiency, fetchIncidentTrend } from '../services/warningResponseApi.js'
 import { fetchWorkOrderList } from '../services/detailApi.js'
 import { PAGE_SIZE, serverPageView } from '../domain/pagination.js'
+import { createViewMemo } from '../domain/panelViewCache.js'
 
 /**
  * 会触发「回第 1 页」的条件键(条文 5/6;定时刷新不经过这里)。
@@ -108,7 +109,7 @@ export const useEventStore = defineStore('eventStore', () => {
     const warningTypeFilter = ref({ code: '', label: '' })
 
     /** 当前事件分区(`/events/current` 的整体响应;成败由内部事件分区状态表达)。 */
-    const sections = ref(initialSections())
+    const sections = shallowRef(initialSections())
 
     /** 预警处置三块聚合面板共享的时间范围,默认近 7 天。 */
     const range = ref('7d')
@@ -139,7 +140,7 @@ export const useEventStore = defineStore('eventStore', () => {
     const efficiencyPage = ref(1)
 
     /** 最后一个「当前事件分区的领域对象」(视图层读它,避免每次都重解构 section)。 */
-    const currentDomain = ref(null)
+    const currentDomain = shallowRef(null)
 
     /** 当前打开的事件详情与地图定位结果;返回时不重取列表,保留 mode/筛选/分页上下文。 */
     const selectedEvent = ref(null)
@@ -272,21 +273,35 @@ export const useEventStore = defineStore('eventStore', () => {
 
     // 只传有效类型码;label 单独重命名不应使同批成员资格重扫。
     const effectiveWarningType = computed(() => mode.value === EVENT_FAMILY.WARNING ? warningTypeFilter.value.code : '')
+    const eventViewMemo = createViewMemo()
     const preparedCurrentEvents = computed(() => {
         const domain = currentDomain.value
-        return prepareCurrentEventItems(domain, domain ? undefined : sections.value.currentEvents, effectiveWarningType.value)
+        const fallback = domain ? undefined : sections.value.currentEvents
+        const type = effectiveWarningType.value
+        return eventViewMemo.read('prepared', [domain, fallback, type], () =>
+            prepareCurrentEventItems(domain, fallback, type))
     })
 
     /** 当前「事件 + 切换」视图(领域层现算;组件与走查都读它)。 */
     const view = computed(() => {
         // G11:类型筛选只在预警族生效(报警列表没有这套类型码)。
-        const filter = mode.value === EVENT_FAMILY.WARNING ? warningTypeFilter.value : { code: '', label: '' }
+        const warning = mode.value === EVENT_FAMILY.WARNING
+        const filter = warning ? warningTypeFilter.value : { code: '', label: '' }
+        const type = filter.code
+        const typeLabel = filter.label
         // 页码是**前端**状态(取全后按可见行分页),所以这里要把它交给视图。
-        const options = { warningType: filter.code, warningTypeLabel: filter.label, page: currentPage.value }
-        // 已取到数据:从领域对象读事件分区(行 + 内部状态)。
-        if (currentDomain.value) return currentEventsView(currentDomain.value, undefined, options, preparedCurrentEvents.value)
-        // 还没取过 / 整体失败:用整个分区驱动占位措辞(pending → 正在取数;failed → 加载失败)。
-        return currentEventsView(null, sections.value.currentEvents, options, preparedCurrentEvents.value)
+        const page = currentPage.value
+        const domain = currentDomain.value
+        const section = sections.value.currentEvents
+        const prepared = preparedCurrentEvents.value
+        return eventViewMemo.read('view', [mode.value, domain, section, prepared, type, typeLabel, page], () => {
+            const options = { warningType: type, warningTypeLabel: typeLabel, page }
+            // 已取到数据:从领域对象读事件分区(行 + 内部状态)。
+            // 还没取过 / 整体失败:用整个分区驱动占位措辞(pending → 正在取数;failed → 加载失败)。
+            return domain
+                ? currentEventsView(domain, undefined, options, prepared)
+                : currentEventsView(null, section, options, prepared)
+        })
     })
 
     /**

+ 13 - 8
src/modules/cockpit/stores/facilityPointStore.js

@@ -7,7 +7,7 @@
  * 失败纪律沿用全舱:几何/台账取不到只让**设施点图层**降级(图例说「未取到」),
  * 不牵连监测点、设备、管线与面板;也绝不回退 mock。
  */
-import { computed, ref } from 'vue'
+import { computed, ref, shallowRef } from 'vue'
 import { defineStore, acceptHMRUpdate } from 'pinia'
 import { SECTION_STATE, section } from '../domain/sectionState.js'
 import { facilityInventory, filterFacilityPoints } from '../domain/facilityPoints.js'
@@ -19,6 +19,7 @@ import { useDetailStore } from './detailStore.js'
 import { sameEntity } from '../domain/entityDetail.js'
 import { facilityIdentity, resolveFacilityPoint, mergeFacilitySelectionPoints } from '../domain/facilitySelection.js'
 import { locateFailureText } from '../domain/mapLocate.js'
+import { createViewMemo } from '../domain/panelViewCache.js'
 import { TERRAIN_LOCATE_REASON } from '../domain/pointLocate.js'
 import { cancelPointLocate, locateFacilityPoint } from '../services/mapService.js'
 
@@ -35,7 +36,7 @@ function pending() {
 export const useFacilityPointStore = defineStore('facilityPointStore', () => {
     // 设施筛选是**全局条件**(filterStore 持有唯一一份),本 store 只读不写。
     const filterStore = useFilterStore()
-    const layer = ref(pending())
+    const layer = shallowRef(pending())
     let requestOptions = {}
     const entityStore = useEntityDetailStore()
     const pipeStore = usePipeNetworkStore()
@@ -112,12 +113,16 @@ export const useFacilityPointStore = defineStore('facilityPointStore', () => {
      * 当前筛选下的设施点:设施类型(本票的独立维度)+ 全局行业/片区(与管线图层同一条纪律)。
      * **只裁设施点**;点位/设备状态筛选是另一个维度,两类对象不重叠、互不改写。
      */
-    const filtered = computed(() => (points.value
-        ? filterFacilityPoints(points.value, filterStore.facilityTypes, {
-            industry: filterStore.industry,
-            scope: filterStore.scope,
-        })
-        : null))
+    const filteredMemo = createViewMemo()
+    const filtered = computed(() => {
+        const rows = points.value
+        const types = filterStore.facilityTypes
+        const industry = filterStore.industry
+        const scope = filterStore.scope
+        return filteredMemo.read('facility-points', [rows, types, industry, scope], () => (rows
+            ? filterFacilityPoints(rows, types, { industry, scope })
+            : null))
+    })
 
     async function load(options = {}) {
         if (Object.keys(options).length) configure(options)

+ 48 - 32
src/modules/cockpit/stores/mapStore.js

@@ -38,6 +38,7 @@ import { usePipeNetworkStore } from './pipeNetworkStore.js'
 import { useFacilityPointStore } from './facilityPointStore.js'
 import { applyPointStates as applyStatusToObjects } from '../domain/statusPush.js'
 import { fetchMapSnapshot } from '../services/mapApi.js'
+import { createViewMemo } from '../domain/panelViewCache.js'
 
 /** 快照装载的请求页大小(后端默认 500、上限 1000)。票 109:实测全量约 26 个对象,
  *  2 → 100 让每轮装载(30s tick / 统一刷新)从 10–12 次串行往返收敛为 1 次。
@@ -51,6 +52,8 @@ export const AUTO_BATCH_GAP_MS = 120
 /** 走查兼容开关:置 true 后 refresh 不自动连翻(老走查用 DEV 把手逐页驱动)。 */
 export const MANUAL_PAGES_KEY = '__COCKPIT_MAP_MANUAL_PAGES__'
 
+const EMPTY_OBJECTS = []
+
 /** 批间等待(可注入:逻辑闸门传即刻 resolve 的假等待)。 */
 let batchWait = (ms) => new Promise((resolve) => setTimeout(resolve, ms))
 
@@ -235,6 +238,9 @@ export const useMapStore = defineStore('mapStore', () => {
         return runLoadChain('refresh')
     }
 
+    /** 高频视图的输入快照缓存:统计轴与坐标准览只在稳定输入变化时重建。 */
+    const mapViewMemo = createViewMemo()
+
     /** 界面用的文案与色键(`domain/mapSummary.js` 的 `summaryView`)。 */
     const view = computed(() => summaryView(summary.value))
 
@@ -257,31 +263,34 @@ export const useMapStore = defineStore('mapStore', () => {
      * 这里仅按 kind 分桶,保证顶部图例能同时显示「报警 1」与「预警 3 / 工单 1 / 离线 3」的并行事实。
      */
     const statusAxes = computed(() => {
-        const distribution = statusDistribution.value
-        const objects = summary.value.objects || []
-        const businessCounts = {}
-        const attachmentCounts = { UNASSOCIATED: 0 }
-        for (const item of objects) {
-            if (!item || !item.kind) continue
-            if (item.kind === MAP_OBJECT_KIND.UNASSOCIATED_EQUIPMENT) {
-                // 未关联设备同时属于附加轴和业务轴:deviceStatus 仍必须计入业务状态。
-                attachmentCounts.UNASSOCIATED += 1
-                const status = item.status || 'UNKNOWN'
-                businessCounts[status] = (businessCounts[status] || 0) + 1
-            } else if (item.kind === MAP_OBJECT_KIND.MONITORING_POINT) {
-                const status = item.status || 'UNKNOWN'
-                businessCounts[status] = (businessCounts[status] || 0) + 1
+        const distribution = summary.value.statusDistribution || null
+        const objects = summary.value.objects || EMPTY_OBJECTS
+        return mapViewMemo.read('status-axes', [distribution, objects], () => {
+            const source = distribution || { available: false, counts: {}, businessCounts: {}, attachmentCounts: {} }
+            const businessCounts = {}
+            const attachmentCounts = { UNASSOCIATED: 0 }
+            for (const item of objects) {
+                if (!item || !item.kind) continue
+                if (item.kind === MAP_OBJECT_KIND.UNASSOCIATED_EQUIPMENT) {
+                    // 未关联设备同时属于附加轴和业务轴:deviceStatus 仍必须计入业务状态。
+                    attachmentCounts.UNASSOCIATED += 1
+                    const status = item.status || 'UNKNOWN'
+                    businessCounts[status] = (businessCounts[status] || 0) + 1
+                } else if (item.kind === MAP_OBJECT_KIND.MONITORING_POINT) {
+                    const status = item.status || 'UNKNOWN'
+                    businessCounts[status] = (businessCounts[status] || 0) + 1
+                }
             }
-        }
-        return {
-            available: distribution.available,
-            businessCounts: distribution.available && Object.keys(businessCounts).length === 0
-                ? distribution.businessCounts || {}
-                : businessCounts,
-            attachmentCounts: distribution.available && attachmentCounts.UNASSOCIATED === 0
-                ? distribution.attachmentCounts || {}
-                : attachmentCounts,
-        }
+            return {
+                available: source.available,
+                businessCounts: source.available && Object.keys(businessCounts).length === 0
+                    ? source.businessCounts || {}
+                    : businessCounts,
+                attachmentCounts: source.available && attachmentCounts.UNASSOCIATED === 0
+                    ? source.attachmentCounts || {}
+                    : attachmentCounts,
+            }
+        })
     })
 
     /**
@@ -310,14 +319,21 @@ export const useMapStore = defineStore('mapStore', () => {
      * 设施点(票 68)与管线/构件是两份附加项(各自有独立的筛选条件),合并只做加法:
      * 管线一份照旧、设施点一份新增,两边都按各自当前筛选裁剪。
      */
-    const coordinate = computed(() => coordinateOverview(
-        summary.value.objects,
-        summary.value.coordinateSummary,
-        mergeCoordinateExtras(
-            facilityCoordinateExtra(usePipeNetworkStore().filtered),
-            facilityPointCoordinateExtra(useFacilityPointStore().filtered),
-        ),
-    ))
+    const coordinate = computed(() => {
+        const objects = summary.value.objects
+        const coordinateSummary = summary.value.coordinateSummary
+        const pipeFiltered = usePipeNetworkStore().filtered
+        const facilityFiltered = useFacilityPointStore().filtered
+        return mapViewMemo.read('coordinate', [objects, coordinateSummary, pipeFiltered, facilityFiltered], () =>
+            coordinateOverview(
+                objects,
+                coordinateSummary,
+                mergeCoordinateExtras(
+                    facilityCoordinateExtra(pipeFiltered),
+                    facilityPointCoordinateExtra(facilityFiltered),
+                ),
+            ))
+    })
 
     /**
      * 票 41:某个编码的坐标准入结论。**判定在 `domain/coordinate.js` 的 `locationVerdict()`**

+ 6 - 6
src/modules/cockpit/stores/monitoringStore.js

@@ -20,7 +20,7 @@
  * ④ **异常设备定位**:复用票 17 立的那条共享接缝(`domain/mapLocate.js`),
  *    不新写一套判定。
  */
-import { computed, reactive, ref } from 'vue'
+import { computed, ref, shallowRef } from 'vue'
 import { defineStore } from 'pinia'
 import { SECTION_STATE, section } from '../domain/sectionState.js'
 import { REQUEST_REASON } from '../domain/requestReason.js'
@@ -98,7 +98,7 @@ export const useMonitoringStore = defineStore('monitoringStore', () => {
      * 台账分区(`sections.monitoringPointLedger`)由它派生 —— 分区仍是界面读的那一份,
      * 装载链是它的数据来源,两者不再各持一套进度。
      */
-    const ledger = reactive({ state: null })
+    const ledger = shallowRef(null)
 
     /** 当前生效的行业筛选(**前端键**;到后端码的映射归 services)。 */
     const industry = ref('')
@@ -254,7 +254,7 @@ export const useMonitoringStore = defineStore('monitoringStore', () => {
 
     /** 合并态 → 台账分区(界面读的还是同一个 `sections.monitoringPointLedger`)。 */
     function syncLedgerSection(state) {
-        ledger.state = state
+        ledger.value = state
         const view = ledgerView(state)
         const data = {
             // 兼容既有面板视图的字段名(`points`/`equipment`/`pagination` 是它读的那几个)。
@@ -335,7 +335,7 @@ export const useMonitoringStore = defineStore('monitoringStore', () => {
      */
     async function reuseLedgerSnapshot() {
         if (!sameInputs(ledgerInputs, monitoringDistributionInputs({ ...activeOptions(), page: 1 }))) return loadLedgerChain('refresh')
-        const state = ledger.state
+        const state = ledger.value
         if (!state) return loadLedgerChain('refresh')
         if (ledgerSettledForAuto(state)) return sections.value.monitoringPointLedger
         return loadLedgerChain('reuse')
@@ -347,7 +347,7 @@ export const useMonitoringStore = defineStore('monitoringStore', () => {
      * @returns {Promise<object>} 台账分区
      */
     async function loadMoreLedger() {
-        const state = ledger.state
+        const state = ledger.value
         if (!state) return sections.value.monitoringPointLedger
         if (!sameInputs(ledgerInputs, monitoringDistributionInputs({ ...activeOptions(), page: 1 }))) return loadLedgerChain('refresh')
         if (ledgerSettledForAuto(state)) return sections.value.monitoringPointLedger
@@ -456,7 +456,7 @@ export const useMonitoringStore = defineStore('monitoringStore', () => {
         ledgerEpoch += 1
         ledgerLoader = null
         ledgerInputs = null
-        ledger.state = null
+        ledger.value = null
         sections.value = Object.fromEntries(MONITORING_PANEL_IDS.map((panelId) => [panelId, pending()]))
         badges.value = {}
         badgeInFlight.value = {}

+ 11 - 5
src/modules/cockpit/stores/pipeNetworkStore.js

@@ -7,11 +7,12 @@
  * 失败纪律沿用全舱:几何取不到只让**设施/管线图层**降级,不牵连监测点、设备与面板,
  * 也绝不回退 mock(票 04 的 real 纪律)。
  */
-import { computed, ref } from 'vue'
+import { computed, ref, shallowRef } from 'vue'
 import { defineStore } from 'pinia'
 import { SECTION_STATE, section } from '../domain/sectionState.js'
 import { REQUEST_REASON } from '../domain/requestReason.js'
 import { filterPipeNetwork } from '../domain/pipeNetwork.js'
+import { createViewMemo } from '../domain/panelViewCache.js'
 import { fetchPipeNetwork } from '../services/pipeLayerService.js'
 
 /** 未取数时的分区(与其它 store 同形,`loaded:false` 表示"还没请求过")。 */
@@ -22,7 +23,7 @@ function pending() {
 const EMPTY_LAYER = { pipes: [], components: [], blocked: [], coverage: {}, counts: {}, districtApplied: false, districtUnresolvedCount: 0 }
 
 export const usePipeNetworkStore = defineStore('pipeNetworkStore', () => {
-    const layer = ref(pending())
+    const layer = shallowRef(pending())
     const industry = ref('all')
 
     /**
@@ -46,9 +47,14 @@ export const usePipeNetworkStore = defineStore('pipeNetworkStore', () => {
     }
 
     /** 当前行业 + 片区筛选下的图层(图层过滤只此一处,引擎与组件都不做第二次过滤)。 */
-    const filtered = computed(() =>
-        filterPipeNetwork(layer.value.data || EMPTY_LAYER, { industry: industry.value, scope: scope.value }),
-    )
+    const filteredMemo = createViewMemo()
+    const filtered = computed(() => {
+        const data = layer.value.data || EMPTY_LAYER
+        const activeIndustry = industry.value
+        const activeScope = scope.value
+        return filteredMemo.read('pipe-network', [data, activeIndustry, activeScope], () =>
+            filterPipeNetwork(data, { industry: activeIndustry, scope: activeScope }))
+    })
 
     /** 取数成功(含真实为空)才交数组;**失败或还没取过一律交 `null`**。 */
 function layerOrNull(list) {

+ 15 - 2
src/modules/cockpit/stores/runtimeStore.js

@@ -48,6 +48,9 @@ import {
     stopPolling,
 } from '../services/freshnessService.js'
 
+/** 本次连接内保留的最近变更点位数:只用于排查展示,不能无界增长。 */
+const MAX_CHANGED_POINTS = 200
+
 export const useRuntimeStore = defineStore('runtimeStore', () => {
     /** 连接状态(服务推送;界面只读它)。 */
     const status = ref(getSocketStatus())
@@ -64,9 +67,17 @@ export const useRuntimeStore = defineStore('runtimeStore', () => {
     /** 被丢弃的条数(旧消息/缺编码/缺状态),排查用。 */
     const dropped = ref(0)
 
-    /** 本次连接收到的增量里,实际改动了点位状态的编码(去重)。 */
+    /** 本次连接收到的增量里,实际改动了点位状态的编码(去重,有上限)。 */
     const changedPoints = ref([])
 
+    function appendChangedPoints(changed) {
+        if (!Array.isArray(changed) || !changed.length) return
+        const merged = [...new Set([...changedPoints.value, ...changed])]
+        changedPoints.value = merged.length > MAX_CHANGED_POINTS
+            ? merged.slice(-MAX_CHANGED_POINTS)
+            : merged
+    }
+
     /**
      * 票 16:统一新鲜度现态(最后成功时间、连续失败次数、成功次数)。
      * 轮询每跑一个周期写一次;推送到达时也写(事件驱动同样说明链路活着)。
@@ -175,7 +186,7 @@ export const useRuntimeStore = defineStore('runtimeStore', () => {
             const mapStore = useMapStore()
             const changed = mapStore.applyPointStates(result.state.pointStates)
             if (changed.length) {
-                changedPoints.value = [...new Set([...changedPoints.value, ...changed])]
+                appendChangedPoints(changed)
             }
             // 票 07:服务端桶的状态摘要是快照内口径,收到 WS 后该类别立即回退本地聚合;
             // 等快照版本变化再重新信任桶,绝不用旧摘要覆盖刚推来的状态。
@@ -233,6 +244,7 @@ export const useRuntimeStore = defineStore('runtimeStore', () => {
      * @param {object} [options] `{ url, token, socketFactory, reconnect, setTimeout, clearTimeout }`
      */
     function start(options = {}) {
+        changedPoints.value = []
         bind()
         const next = connectSocket(options)
         // 服务建连是同步的:先把状态落到响应式,不等事件回来(避免首帧显示 idle)。
@@ -242,6 +254,7 @@ export const useRuntimeStore = defineStore('runtimeStore', () => {
 
     /** 断开并停止重连。 */
     function stop() {
+        changedPoints.value = []
         const next = disconnectSocket()
         status.value = next
         return next