feat(entry): 建立 MVVM+data 分层骨架,接入 V2 状态管理与 Navigation 路由
This commit is contained in:
30
entry/src/main/ets/router/AppRouter.ets
Normal file
30
entry/src/main/ets/router/AppRouter.ets
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* 应用级导航封装:持有全局 NavPathStack,页面通过静态方法导航。
|
||||
*/
|
||||
export class AppRouter {
|
||||
private static stack: NavPathStack | null = null;
|
||||
|
||||
static init(stack: NavPathStack): void {
|
||||
AppRouter.stack = stack;
|
||||
}
|
||||
|
||||
static push(name: string, param?: Object): void {
|
||||
AppRouter.stack?.pushPathByName(name, param);
|
||||
}
|
||||
|
||||
static replace(name: string, param?: Object): void {
|
||||
AppRouter.stack?.replacePathByName(name, param);
|
||||
}
|
||||
|
||||
static pop(): void {
|
||||
AppRouter.stack?.pop();
|
||||
}
|
||||
|
||||
static popToName(name: string): void {
|
||||
AppRouter.stack?.popToName(name);
|
||||
}
|
||||
|
||||
static clear(): void {
|
||||
AppRouter.stack?.clear();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user