Browse Source

fix: 入库 mapLabels 并阻断超时后的在途轮询回写

补交 MonitorView 依赖的 mapLabels 模块;客户端 deadline
到达时递增 commandProgressEpoch,避免迟到响应清掉超时文案。
main
xiaosi 3 weeks ago
parent
commit
a62f7ff10f
  1. 33
      src/utils/mapLabels.js
  2. 1
      src/views/MonitorView/MonitorView.vue

33
src/utils/mapLabels.js

@ -0,0 +1,33 @@
/**
* Prefer Simplified Chinese labels on Mapbox basemap symbol layers.
* Falls back to name_zh / name when localized fields are absent.
*/
export function applyChineseLabels(map) {
if (!map?.getStyle) return
let layers = []
try {
layers = map.getStyle()?.layers || []
} catch (_) {
return
}
const textField = [
'coalesce',
['get', 'name_zh-Hans'],
['get', 'name_zh'],
['get', 'name'],
]
for (const layer of layers) {
if (layer?.type !== 'symbol') continue
if (!layer.layout?.['text-field']) continue
// Keep app-owned overlays (device/route labels) on their own text-field
const id = String(layer.id || '')
if (id.startsWith('laic-') || id.startsWith('monitor-') || id.startsWith('route-')) continue
try {
map.setLayoutProperty(layer.id, 'text-field', textField)
} catch (_) {
/* layer may not support text-field mutation */
}
}
}

1
src/views/MonitorView/MonitorView.vue

@ -1535,6 +1535,7 @@ function startCommandProgress(cmd, title, deviceName) {
if (Date.now() > deadline) { if (Date.now() > deadline) {
clearInterval(commandPollTimer) clearInterval(commandPollTimer)
commandPollTimer = null commandPollTimer = null
commandProgressEpoch += 1
if (!COMMAND_STATUS[commandProgress.status]?.terminal) { if (!COMMAND_STATUS[commandProgress.status]?.terminal) {
commandProgress.error = '等待超时,请稍后在操作记录查看' commandProgress.error = '等待超时,请稍后在操作记录查看'
commandProgress.step = 3 commandProgress.step = 3

Loading…
Cancel
Save