diff --git a/docs/api.md b/docs/api.md index 6cbc47f..1bc9e4b 100644 --- a/docs/api.md +++ b/docs/api.md @@ -18,10 +18,11 @@ GET /api/game/{clientId} "code": "OK", "gameConfig": { "strength": { - "minStrength": 1, // 最小随机强度 - "maxStrength": 10, // 最大随机强度 + "strength": 1, // 基础强度 + "randomStrength": 10, // 随机强度,最终强度 = 基础强度 + random(0, 随机强度) "minInterval": 10, // 最小随机间隔 - "maxInterval": 15 // 最大随机间隔 + "maxInterval": 15, // 最大随机间隔 + "bChannelMultiplier": 1.0, // B通道强度倍数,如果存在此参数,则会启动B通道 }, "pulseId": "pulse-1" // 脉冲ID }, @@ -78,8 +79,8 @@ GET /api/game/{clientId}/strength_info "status": 1, "code": "OK", "strengthConfig": { // 强度配置,同上 - "minStrength": 5, - "maxStrength": 10, + "strength": 5, + "randomStrength": 10, "minInterval": 10, "maxInterval": 15 } @@ -101,16 +102,15 @@ POST /api/game/{clientId}/strength_info ```typescript type SetStrengthConfigRequest = { - minStrength?: { - add?: number; // 增加最低随机强度(基础强度) + strength?: { + add?: number; // 增加基础强度 sub?: number; // 减少强度 set?: number; // 设置强度 }, - maxStrength?: { - add?: number; // 增加最高随机强度 + randomStrength?: { + add?: number; // 增加随机强度 sub?: number; // 减少强度 set?: number; // 设置强度 - keep?: boolean; // 是否保持最低强度不变,默认会根据最低强度的变化调整最高强度 }, minInterval?: { set?: number; // 设置最低随机间隔 @@ -125,7 +125,7 @@ type SetStrengthConfigRequest = { ```json5 { - "minStrength": { + "strength": { "add": 1 } } diff --git a/frontend/src/apis/socketApi.ts b/frontend/src/apis/socketApi.ts index 64bd832..b2e6017 100644 --- a/frontend/src/apis/socketApi.ts +++ b/frontend/src/apis/socketApi.ts @@ -28,16 +28,16 @@ export type StrengthInfo = { limit: number; }; -export type RandomStrengthConfig = { - minStrength: number; - maxStrength: number; +export type GameStrengthConfig = { + strength: number; + randomStrength: number; minInterval: number; maxInterval: number; bChannelMultiplier?: number; } export type CoyoteLiveGameConfig = { - strength: RandomStrengthConfig; + strength: GameStrengthConfig; pulseId: string; } diff --git a/frontend/src/pages/Controller.vue b/frontend/src/pages/Controller.vue index b679830..933186d 100644 --- a/frontend/src/pages/Controller.vue +++ b/frontend/src/pages/Controller.vue @@ -9,9 +9,9 @@ import { handleApiResponse } from '../utils/response'; const CLIENT_ID_STORAGE_KEY = 'liveGameClientId'; const state = reactive({ - valLow: 5, - valHigh: 10, - valLimit: 50, + strengthVal: 5, + randomStrengthVal: 5, + strengthLimit: 20, randomFreqLow: 10, randomFreqHigh: 15, @@ -43,8 +43,8 @@ const gameConfig = computed({ get: () => { return { strength: { - minStrength: state.valLow, - maxStrength: state.valHigh, + strength: state.strengthVal, + randomStrength: state.randomStrengthVal, minInterval: state.randomFreqLow, maxInterval: state.randomFreqHigh, bChannelMultiplier: state.bChannelEnabled ? state.bChannelMultiple : undefined, @@ -53,8 +53,8 @@ const gameConfig = computed({ }; }, set: (value) => { - state.valLow = value.strength.minStrength; - state.valHigh = value.strength.maxStrength; + state.strengthVal = value.strength.strength; + state.randomStrengthVal = value.strength.randomStrength; state.randomFreqLow = value.strength.minInterval; state.randomFreqHigh = value.strength.maxInterval; state.bChannelEnabled = typeof value.strength.bChannelMultiplier === 'number'; @@ -63,6 +63,12 @@ const gameConfig = computed({ } }); +const chartVal = computed(() => ({ + valLow: state.strengthVal, + valHigh: Math.min(state.strengthVal + state.randomStrengthVal, state.strengthLimit), + valLimit: state.strengthLimit, +})) + const randomFreq = computed({ get: () => { return [state.randomFreqLow, state.randomFreqHigh]; @@ -142,7 +148,7 @@ const initWebSocket = async () => { }); wsClient.on('strengthChanged', (strength) => { - state.valLimit = strength.limit; + state.strengthLimit = strength.limit; }); wsClient.on('configUpdated', (config) => { @@ -324,7 +330,7 @@ watch(gameConfig, () => {
- +
@@ -359,11 +365,8 @@ watch(gameConfig, () => {