refactor: 应用参考工程代码模式,优化启动流程和架构

- 新增 SplashPage:启动页,2秒后跳转到 Index
- 新增 MainPage:独立主页组件,含 Tab 导航 + 宽屏/窄屏自适应
- 简化 Index.ets:纯路由入口,初始化数据库,加载 MainPage
- EntryAbility:加载 SplashPage 而非直接加载 Index
- 新增 PageContext:NavPathStack 路由管理(参考工程模式)
- 新增 BreakpointSystem:响应式断点系统 xs/sm/md/lg/xl
- 新增 BaseViewModel:ViewModel 基类,含 attach/detach/dispose 生命周期
- 更新 common/Index.ets 导出新模块
- 更新 main_pages.json 注册 SplashPage 和 MainPage
This commit is contained in:
root
2026-05-01 09:15:36 +08:00
parent 5916d2749c
commit ab3d910387
9 changed files with 325 additions and 112 deletions

View File

@ -0,0 +1,52 @@
import { BreakpointType, WidthBreakpoint } from '../util/BreakpointSystem';
export interface VMEvent {
}
export class BaseViewModel {
protected isAttached: boolean = false;
protected isDisposed: boolean = false;
protected currentBreakpoint: WidthBreakpoint = WidthBreakpoint.WIDTH_MD;
attach(): void {
if (this.isAttached) {
return;
}
this.isAttached = true;
this.onAttach();
}
detach(): void {
if (!this.isAttached) {
return;
}
this.isAttached = false;
this.onDetach();
}
dispose(): void {
if (this.isDisposed) {
return;
}
this.isDisposed = true;
this.detach();
this.onDispose();
}
protected onAttach(): void {
}
protected onDetach(): void {
}
protected onDispose(): void {
}
public get attached(): boolean {
return this.isAttached;
}
public get disposed(): boolean {
return this.isDisposed;
}
}