|
|
@@ -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()
|