feat(framework): config 调试登录账号进 profile(DebugAccount)

- DebugProfile 加 account?: DebugAccount(openid 等登录字段,仅 debug 模式生效)
- resolveBootstrap 结果加 account:debug 取 profile.account,release 恒 undefined
- staging profile 留占位 account 待填真值;接入处 setIdentity 合并 identity+account
- 同步指南

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-28 19:57:41 +08:00
co-authored by Claude Opus 4.8
parent 51a4ee57ac
commit d461578d6e
4 changed files with 46 additions and 4 deletions
@@ -3,7 +3,7 @@ import { resolveIdentity } from './identity.ts';
import { BUILD_IDENTITY } from './sources/defaults.ts';
import { queryStringSource } from './sources/query-string.ts';
import { nativeSettingsSource, type NativeHost } from './sources/native-settings.ts';
import { resolveActiveProfile, PROFILES, type DebugProfile } from './profiles.ts';
import { resolveActiveProfile, PROFILES, type DebugProfile, type DebugAccount } from './profiles.ts';
import { resolveServers, type ConfigFetcher, type RemoteConfig, ConfigFetchError } from './remote-config.ts';
import type { RuntimeMode } from './runtime-mode.ts';
@@ -20,6 +20,7 @@ export interface BootstrapResult {
mode: RuntimeMode;
isDebugger: boolean; // = (mode === 'debug')
identity: ChannelIdentity;
account?: DebugAccount; // 调试登录账号(仅 debug 模式有值;release 恒 undefined)
servers: string[];
rawConfig: RemoteConfig | null;
profile: DebugProfile;
@@ -47,7 +48,9 @@ export async function resolveBootstrap(opts: BootstrapOptions): Promise<Bootstra
nativeSettingsSource(opts.win), // release:身份只取原生,URL 一律无效
]);
const resultBase = { mode: opts.mode, isDebugger: isDebug, identity, profile };
// 调试账号只在 debug 模式从 profile 取;release 不读调试配置账号。
const account = isDebug ? profile.account : undefined;
const resultBase = { mode: opts.mode, isDebugger: isDebug, identity, account, profile };
// 服务器决策:profile 显式 server 直连捷径
if (profile.server) {
@@ -1,10 +1,22 @@
import type { ChannelIdentity } from './identity.ts';
/** 调试用登录玩家档案(player_login 中除渠道身份外的字段)。仅 debug 模式生效。 */
export interface DebugAccount {
openid: string; // 服务器据此标识玩家(必填)
nickname?: string;
avatar?: string;
sex?: number;
province?: string;
city?: string;
unionid?: string | number;
}
export interface DebugProfile {
name: string;
server?: string; // 显式 ws 调试服地址(给定则跳过远程抓取)
gameserver?: string; // 远程配置 txt URL(不含防缓存串)
identity?: Partial<ChannelIdentity>; // 调试用渠道身份覆盖
account?: DebugAccount; // 调试用登录账号(仅 debug 模式生效)
isDebugger?: boolean; // 收发包日志开关(替代旧 Game_Config.Debugger.isDebugger)
}
@@ -15,7 +27,13 @@ const STAGING_GAMESERVER = 'https://tsgames.daoqi88.cn/config_test/beta_update_j
export const PROFILES: Record<string, DebugProfile> = {
prod: { name: 'prod', gameserver: DEFAULT_GAMESERVER, isDebugger: false },
staging: { name: 'staging', gameserver: STAGING_GAMESERVER, isDebugger: true },
staging: {
name: 'staging',
gameserver: STAGING_GAMESERVER,
isDebugger: true,
// 调试登录账号:联调前替换为真实测试账号(openid 必填)。仅 debug 模式生效。
account: { openid: 'REPLACE_ME_test_openid', nickname: '测试号', avatar: '', sex: 0, province: '', city: '', unionid: '' },
},
local: { name: 'local', server: 'ws://127.0.0.1:3088', isDebugger: true },
};