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

@@ -18,6 +18,7 @@ export interface HeartRateInputControllerDebugState {
mockBridgeConnected: boolean
mockBridgeStatusText: string
mockBridgeUrlText: string
mockChannelIdText: string
mockHeartRateText: string
}
@@ -55,6 +56,7 @@ export class HeartRateInputController {
sourceMode: HeartRateSourceMode
mockBridgeStatusText: string
mockBridgeUrl: string
mockChannelId: string
mockBpm: number | null
constructor(callbacks: HeartRateInputControllerCallbacks) {
@@ -62,6 +64,7 @@ export class HeartRateInputController {
this.sourceMode = 'real'
this.mockBridgeUrl = DEFAULT_MOCK_HEART_RATE_BRIDGE_URL
this.mockBridgeStatusText = `未连接 (${this.mockBridgeUrl})`
this.mockChannelId = 'default'
this.mockBpm = null
const realCallbacks: HeartRateControllerCallbacks = {
@@ -194,6 +197,7 @@ export class HeartRateInputController {
mockBridgeConnected: this.mockBridge.connected,
mockBridgeStatusText: this.mockBridgeStatusText,
mockBridgeUrlText: this.mockBridgeUrl,
mockChannelIdText: this.mockChannelId,
mockHeartRateText: formatMockHeartRateText(this.mockBpm),
}
}
@@ -269,6 +273,16 @@ export class HeartRateInputController {
this.emitDebugState()
}
setMockChannelId(channelId: string): void {
const normalized = String(channelId || '').trim() || 'default'
this.mockChannelId = normalized
this.mockBridge.setChannelId(normalized)
if (this.sourceMode === 'mock') {
this.callbacks.onStatus(`模拟心率通道已切换到 ${normalized}`)
}
this.emitDebugState()
}
connectMockBridge(url = DEFAULT_MOCK_HEART_RATE_BRIDGE_URL): void {
if (this.mockBridge.connected || this.mockBridge.connecting) {
if (this.sourceMode === 'mock') {