feat: 收敛玩法运行时配置并加入故障恢复

This commit is contained in:
2026-04-01 13:04:26 +08:00
parent 1635a11780
commit 3ef841ecc7
73 changed files with 8820 additions and 2122 deletions

View File

@@ -12,6 +12,7 @@ export interface LocationControllerDebugState {
mockBridgeConnected: boolean
mockBridgeStatusText: string
mockBridgeUrlText: string
mockChannelIdText: string
mockCoordText: string
mockSpeedText: string
}
@@ -70,12 +71,14 @@ export class LocationController {
sourceMode: LocationSourceMode
mockBridgeStatusText: string
mockBridgeUrl: string
mockChannelId: string
constructor(callbacks: LocationControllerCallbacks) {
this.callbacks = callbacks
this.sourceMode = 'real'
this.mockBridgeUrl = DEFAULT_MOCK_LOCATION_BRIDGE_URL
this.mockBridgeStatusText = `未连接 (${this.mockBridgeUrl})`
this.mockChannelId = 'default'
const sourceCallbacks: LocationSourceCallbacks = {
onLocation: (sample) => {
@@ -129,6 +132,7 @@ export class LocationController {
mockBridgeConnected: this.mockBridge.connected,
mockBridgeStatusText: this.mockBridgeStatusText,
mockBridgeUrlText: this.mockBridgeUrl,
mockChannelIdText: this.mockChannelId,
mockCoordText: formatMockCoordText(this.mockSource.lastSample),
mockSpeedText: formatMockSpeedText(this.mockSource.lastSample),
}
@@ -187,6 +191,14 @@ export class LocationController {
this.emitDebugState()
}
setMockChannelId(channelId: string): void {
const normalized = String(channelId || '').trim() || 'default'
this.mockChannelId = normalized
this.mockBridge.setChannelId(normalized)
this.callbacks.onStatus(`模拟定位通道已切换到 ${normalized}`)
this.emitDebugState()
}
connectMockBridge(url = DEFAULT_MOCK_LOCATION_BRIDGE_URL): void {
if (this.mockBridge.connected || this.mockBridge.connecting) {
this.callbacks.onStatus('模拟定位源已连接')