diff --git a/src/utils/mapLabels.js b/src/utils/mapLabels.js new file mode 100644 index 0000000..15ff5a6 --- /dev/null +++ b/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 */ + } + } +} diff --git a/src/views/MonitorView/MonitorView.vue b/src/views/MonitorView/MonitorView.vue index 4e63097..3c2c86a 100644 --- a/src/views/MonitorView/MonitorView.vue +++ b/src/views/MonitorView/MonitorView.vue @@ -1535,6 +1535,7 @@ function startCommandProgress(cmd, title, deviceName) { if (Date.now() > deadline) { clearInterval(commandPollTimer) commandPollTimer = null + commandProgressEpoch += 1 if (!COMMAND_STATUS[commandProgress.status]?.terminal) { commandProgress.error = '等待超时,请稍后在操作记录查看' commandProgress.step = 3