refactor(config): 七牛/微信密钥外置——AK/SK+微信AppID 入本地 app_config, domain/bucket 走远程配置
- app_config.json + AppConfig: qiniu_access_key/qiniu_secret_key/wechat_app_id/wechat_app_secret(扁平snake_case) - RemoteConfig.VersionFields + audio_domain/audio_bucket(4层可携带), VersionDecision + audioDomain/audioBucket - VersionResolver.resolve 复用 pickStr 解析 audioDomain/audioBucket(4层逐级回退) - QiniuToken.uploadToken(accessKey,secretKey,bucket) 改传参,去掉硬编码常量 - AudioProvider.doUpload: AK/SK取本地配置, domain/bucket取远程配置(cfg.resolve), URL用远程domain - WeChatApi.configure(appId) 注入AppID(去WX_APP_ID常量), EntryAbility.onCreate 从配置注入 - 更新 QiniuToken 单测传参 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
e5d8eeb3b1
commit
c39d8eb400
@@ -29,6 +29,14 @@ export interface AppConfig {
|
||||
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 归一化)。 */
|
||||
@@ -44,6 +52,10 @@ export interface AppConfigRaw {
|
||||
gameconfig?: string;
|
||||
other?: string;
|
||||
tuiguang?: string;
|
||||
qiniu_access_key?: string;
|
||||
qiniu_secret_key?: string;
|
||||
wechat_app_id?: string;
|
||||
wechat_app_secret?: string;
|
||||
}
|
||||
|
||||
/** 把可选解析体归一化为完整 AppConfig(缺失键 → 空串)。 */
|
||||
@@ -60,5 +72,9 @@ export function normalizeConfig(raw: AppConfigRaw): AppConfig {
|
||||
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 ?? '',
|
||||
};
|
||||
}
|
||||
|
||||
@@ -34,6 +34,10 @@ export interface VersionFields {
|
||||
game_zip?: string;
|
||||
game_size?: string;
|
||||
showmessage?: string;
|
||||
/** 录音上传七牛回放域名(4 层可携带,逐级回退)。 */
|
||||
audio_domain?: string;
|
||||
/** 录音上传七牛 bucket(4 层可携带,逐级回退)。 */
|
||||
audio_bucket?: string;
|
||||
}
|
||||
|
||||
/** 市场层(marketid 数字命中;携带 app 升级 + 可选资源覆盖)。 */
|
||||
@@ -87,4 +91,8 @@ export interface VersionDecision {
|
||||
gameVersion: number;
|
||||
gameDownload: string;
|
||||
gameSize: string;
|
||||
/** 录音上传七牛回放域名(来源 audio_domain,4 层回退)。 */
|
||||
audioDomain: string;
|
||||
/** 录音上传七牛 bucket(来源 audio_bucket,4 层回退)。 */
|
||||
audioBucket: string;
|
||||
}
|
||||
|
||||
@@ -94,6 +94,8 @@ export class VersionResolver {
|
||||
gameVersion: VersionResolver.pickVer(layers, (n: VersionFields) => n.game_version),
|
||||
gameDownload: VersionResolver.pickStr(layers, (n: VersionFields) => n.game_zip),
|
||||
gameSize: VersionResolver.pickStr(layers, (n: VersionFields) => n.game_size),
|
||||
audioDomain: VersionResolver.pickStr(layers, (n: VersionFields) => n.audio_domain),
|
||||
audioBucket: VersionResolver.pickStr(layers, (n: VersionFields) => n.audio_bucket),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user