M0: App 入口与路由壳(T-M0-07)

框架 §4 路由骨架,Navigation + NavPathStack:
- AppRoutes:路由名(Splash/BridgeGame/GenericWeb)、容器参数类型、前后台事件名
- Index:@Entry 导航宿主,初始进 Splash,navDestination 按名分发
- SplashPage:启动引导壳(weclomeactivity1),replacePathByName 进大厅
- BridgeGameContainer:大厅容器壳(webviewActivity),pushPathByName+onPop 演示
  打开通用网页并接收 101 回传
- GenericWebContainer:通用网页容器壳(openwebActivity1),pop(result) 模拟
  backgameData 带数据返回(§11.2 结果码 101 语义)
- EntryAbility:onForeground/onBackground 经 EventBus 广播应用前后台事件
  (M3 容器订阅后 callHandler('appservice','1'/'2'))
- build 编译通过

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
lanterngamescn
2026-06-25 07:44:57 +08:00
co-authored by Claude Opus 4.8
parent f89275ea4b
commit 7fb0c194f7
6 changed files with 191 additions and 18 deletions
@@ -0,0 +1,43 @@
import { RouteName, BridgeGameParams, GenericWebParams, GenericWebResult } from '../routes/AppRoutes';
/**
* 大厅/子游戏容器壳(对应 webviewActivity,框架 §7.1)。
* M0:仅路由壳,演示打开通用网页容器并接收 101 回传。
* M2:填入 Web 组件 + BridgeController(桥协议 + §8/§9 handler)。
*/
@Component
export struct BridgeGameContainer {
pathStack: NavPathStack = new NavPathStack();
params: BridgeGameParams = { entryUrl: '', launchType: '0' };
@State private lastWebResult: string = '(无)';
/** 打开通用网页容器(§11.2 路径 B),onPop 接收子页回传(结果码 101 语义)。 */
private openGenericWeb(): void {
const params: GenericWebParams = { url: '', title: '活动页', data: 'hello', orientation: '0' };
this.pathStack.pushPathByName(RouteName.GENERIC_WEB, params, (popInfo: PopInfo) => {
const result = popInfo.result as GenericWebResult;
this.lastWebResult = result !== undefined ? result.data : '(空)';
}, false);
}
build() {
NavDestination() {
Column({ space: 16 }) {
Text('BridgeGameContainer 壳')
.fontSize(20)
.fontWeight(FontWeight.Bold)
Text(`launchType=${this.params.launchType}`)
.fontSize(14)
.fontColor(Color.Gray)
Text(`通用网页回传:${this.lastWebResult}`)
.fontSize(14)
Button('打开通用网页(测回传)')
.onClick(() => this.openGenericWeb())
}
.width('100%')
.height('100%')
.justifyContent(FlexAlign.Center)
}
.hideTitleBar(true)
}
}