/** * 本地配置(契约 §4.2,框架 §8.2)。 * * Android 用"目录名编码",本平台改为随包内置 rawfile/app_config.json(KV), * 只要提供同名配置值即可,H5 完全无感知。本仓库实测值见 rawfile/app_config.json。 */ /** 本地配置(全键,§4.2)。 */ export interface AppConfig { /** 代理商 ID(分层匹配 key)。 */ agent: string; /** 渠道 ID(分层匹配 key)。 */ channel: string; /** 资源解压父目录名。 */ gamedir: string; /** 资源解压后的游戏目录名(大厅入口所在,通常 gamehall)。 */ gamestart: string; /** App 版本号(与远程 app_version 比较)。 */ appversion: string; /** 市场 ID(分层匹配 key;也经桥 getmarketname 暴露 H5)。 */ market: string; /** 游戏 ID(空时回退用 version.xml game id)。 */ gameid: string; /** 大厅 H5 远程地址;空 → 本地 file:// 加载。 */ weburl: string; /** 远程配置地址('-'→'/' 后拼 .txt)。 */ gameconfig: string; /** 业务自定义值(经桥 getOther/getothername 暴露 H5)。 */ other: string; /** 推广/邀请码(写入 app_data.js 的 app_invitationcode)。 */ tuiguang: string; /** 七牛 AccessKey(录音上传 token 签名;随包内置,不写死在源码)。 */ qiniuAccessKey: string; /** 七牛 SecretKey(录音上传 token 签名)。 */ qiniuSecretKey: string; /** 微信开放平台 AppID(WeChatApi 创建 WXApi)。 */ wechatAppId: string; /** 微信开放平台 AppSecret(当前端侧不消费,登录走 code+服务端;留位避免硬编码)。 */ wechatAppSecret: string; } /** 解析中间体(字段全可选,用于从 JSON 归一化)。 */ export interface AppConfigRaw { agent?: string; channel?: string; gamedir?: string; gamestart?: string; appversion?: string; market?: string; gameid?: string; weburl?: string; gameconfig?: string; other?: string; tuiguang?: string; qiniu_access_key?: string; qiniu_secret_key?: string; wechat_app_id?: string; wechat_app_secret?: string; } /** 把可选解析体归一化为完整 AppConfig(缺失键 → 空串)。 */ export function normalizeConfig(raw: AppConfigRaw): AppConfig { return { agent: raw.agent ?? '', channel: raw.channel ?? '', gamedir: raw.gamedir ?? '', gamestart: raw.gamestart ?? '', appversion: raw.appversion ?? '', market: raw.market ?? '', gameid: raw.gameid ?? '', weburl: raw.weburl ?? '', gameconfig: raw.gameconfig ?? '', other: raw.other ?? '', tuiguang: raw.tuiguang ?? '', qiniuAccessKey: raw.qiniu_access_key ?? '', qiniuSecretKey: raw.qiniu_secret_key ?? '', wechatAppId: raw.wechat_app_id ?? '', wechatAppSecret: raw.wechat_app_secret ?? '', }; }