M4: 通用网页容器 + SettingsProxy + NavProvider + 子游戏切换
T-M4-01/02/03 GenericWebContainer(§11.3 第二套机制,不挂桥):
- javaScriptProxy 注入 settings 对象 6 方法(SettingsProxy,函数回调避开 ArkTS 对象字面量限制)
- 首次 100% runJavaScript 直调 getWebdata('<data>');返回键 isbackfinishweb→gamebackkeydown /
isexitdialogeshow→退出确认→backgameData();关闭 pop({data}) 101 语义回上层
- orientation "1"竖/其他横(window.setPreferredOrientation);browser 隐式 want
T-M3-06 NavProvider:OpenurlTitleData(开通用容器,onPop→callHandler getWebdata)、
SwitchOverGameData(同容器 loadUrl 切子游戏+重注入 app_data(launchtype'1')+方向+复位首屏标志)、
getGameinstall(同步 1/0 查 <解压根>/<dir>/index.html)、backgameData(重载大厅+待加载后 getWebdata)
导航解耦:common NavEvents(名+具名 payload interface);NavProvider 发 EventBus → BridgeGameContainer 执行
(容器持 pathStack/controller)。EventBus payload 放宽为 Object(ArkTS 禁 Record 字面量),用 GenericEventData
domain AppDataInjector.buildValues 复用(StartupOrchestrator + 子游戏切换共用,去重)
组装根装配 NavProvider
devecocli build 通过。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
import { FileSystem } from 'platform';
|
||||
import { Logger } from 'common';
|
||||
import { AppConfig } from '../config/AppConfig';
|
||||
|
||||
/** app_data.js 全局变量取值(§6)。 */
|
||||
export interface AppDataValues {
|
||||
@@ -41,6 +42,25 @@ export interface AppDataValues {
|
||||
export class AppDataInjector {
|
||||
private static readonly log: Logger = Logger.tag('AppDataInjector');
|
||||
|
||||
/** 由本地配置 + 资源版本 + 启动类型构建 app_data 值(大厅 launchtype='0' / 子游戏 '1')。 */
|
||||
static buildValues(config: AppConfig, version: string, launchtype: string): AppDataValues {
|
||||
return {
|
||||
app_version: version,
|
||||
app_gameconfig: config.gameconfig,
|
||||
app_gamedir: config.gamedir,
|
||||
app_gamestart: config.gamestart,
|
||||
app_agent: config.agent,
|
||||
app_appversion: config.appversion,
|
||||
app_market: config.market,
|
||||
app_channel: config.channel,
|
||||
app_invitationcode: config.tuiguang,
|
||||
app_Launchtype: launchtype,
|
||||
// TODO(M3):app_gamename 源为 version.xml 的 <game name>,当前 VersionXml 仅解析 version。
|
||||
app_gamename: '',
|
||||
app_getwifisignalLevel: '0',
|
||||
};
|
||||
}
|
||||
|
||||
/** 生成 app_data.js 文本(一组全局 var 声明)。 */
|
||||
static buildJs(v: AppDataValues): string {
|
||||
const lines: string[] = [
|
||||
|
||||
@@ -120,24 +120,9 @@ export class StartupOrchestrator {
|
||||
return { enter: false, entryUrl: '', message: '资源准备失败,请检查网络后重试' };
|
||||
}
|
||||
|
||||
// 6) 注入 app_data.js(务必在进大厅之前)
|
||||
// 6) 注入 app_data.js(务必在进大厅之前)。大厅 launchtype='0'
|
||||
this.stage(StartupStage.INJECT_APP_DATA, 90);
|
||||
const values: AppDataValues = {
|
||||
app_version: `${resource.localVersion()}`,
|
||||
app_gameconfig: local.gameconfig,
|
||||
app_gamedir: local.gamedir,
|
||||
app_gamestart: local.gamestart,
|
||||
app_agent: local.agent,
|
||||
app_appversion: local.appversion,
|
||||
app_market: local.market,
|
||||
app_channel: local.channel,
|
||||
app_invitationcode: local.tuiguang,
|
||||
app_Launchtype: '0',
|
||||
// TODO(M3):app_gamename 源为 version.xml 的 <game name>,当前 VersionXml 仅解析 version;
|
||||
// H5 若读 app_gamename 暂为空串。需要时扩展 VersionXml 用 token 回调按标签上下文取 name 属性。
|
||||
app_gamename: '',
|
||||
app_getwifisignalLevel: '0',
|
||||
};
|
||||
const values: AppDataValues = AppDataInjector.buildValues(local, `${resource.localVersion()}`, '0');
|
||||
AppDataInjector.inject(resource.paths().gameDir, values);
|
||||
|
||||
// 7) 进大厅
|
||||
|
||||
Reference in New Issue
Block a user