feat(framework): config 调试 profiles + ?profile= 切换

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-28 16:38:44 +08:00
co-authored by Claude Opus 4.8
parent 119a457c59
commit 231e9ee31c
2 changed files with 56 additions and 0 deletions
@@ -0,0 +1,29 @@
import type { ChannelIdentity } from './identity.ts';
export interface DebugProfile {
name: string;
server?: string; // 显式 ws 调试服地址(给定则跳过远程抓取)
gameserver?: string; // 远程配置 txt URL(不含防缓存串)
identity?: Partial<ChannelIdentity>; // 调试用渠道身份覆盖
isDebugger?: boolean; // 收发包日志开关(替代旧 Game_Config.Debugger.isDebugger)
}
/** 正式 gameserver:原 00_SubGame_Config.js:11。 */
export const DEFAULT_GAMESERVER = 'http://ylyxservice1.0791ts.cn/config/update_json.txt';
/** 测试 gameserver:原 00_SubGame_Config.js:9 注释。 */
const STAGING_GAMESERVER = 'http://testgame.youlehdyx.com/update_json/ceshi_json.txt';
export const PROFILES: Record<string, DebugProfile> = {
prod: { name: 'prod', gameserver: DEFAULT_GAMESERVER, isDebugger: false },
staging: { name: 'staging', gameserver: STAGING_GAMESERVER, isDebugger: true },
local: { name: 'local', server: 'ws://127.0.0.1:3088', isDebugger: true },
};
/** 发布只需保持 'prod'。 */
export const ACTIVE_PROFILE = 'prod';
/** 解析当前 profile:ACTIVE_PROFILE 为基线,?profile=<name> 临时切换;未知名回退 ACTIVE_PROFILE。 */
export function resolveActiveProfile(search: string): DebugProfile {
const name = new URLSearchParams(search).get('profile') || ACTIVE_PROFILE;
return PROFILES[name] ?? PROFILES[ACTIVE_PROFILE];
}