feat: 收敛玩法运行时配置并加入故障恢复
This commit is contained in:
@@ -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') {
|
||||
|
||||
Reference in New Issue
Block a user