feat: tighten ArkTS shell demo closure and runtime entry hints

This commit is contained in:
OpenClaw committed 2026-03-09 18:48:20 +08:00
1 parent a14b10d62f
commit bde990ac82
4 files changed
+102 -10

No files matched your search

@@ -0,0 +1,82 @@
# ArkTS 壳层最小可演示闭环说明 v1
项目:mrp-simulator-harmonyos
## 1. 运行入口在哪里
运行入口在:
- `entry/src/main/ets/pages/ShellRootPage.ets`
- `entry/src/main/ets/pages/AppListPage.ets`
当前可见入口:
1. App 启动进入 `ShellRootPage`
2. 默认路由进入 `AppListPage`
3. 用户点击 **“可运行”应用卡片**
4. 通过 `onNavigateRun(appId)` 切到 `RunPage`
## 2. 页面流如何走
当前最小页面流:
- `AppListPage -> ImportPage -> AppListPage`
- `AppListPage -> RunPage -> AppListPage`
具体链路:
1. **列表页**
- 展示应用列表
- 展示运行入口提示
- 点击“导入应用”进入 `ImportPage`
- 点击“可运行”卡片进入 `RunPage`
2. **导入页**
- 选择文件
- 展示预览
- 点击“开始导入”
- 导入成功后返回列表页
- 返回列表页时触发列表刷新 token
3. **运行页**
- 进入时根据 `appId` 发起 `startSession(appId)`
- 状态从 `starting -> running`
- 点击退出后回到列表页
## 3. 哪些接口已经为 NAPI 预留
### 3.1 App 列表相关
- `entry/src/main/ets/adapters/NativeAppAdapter.ts`
- `listInstalledApps()`
### 3.2 导入相关
- `entry/src/main/ets/adapters/NativeImportAdapter.ts`
- `pickFile()`
- `inspectPackage(fileUri)`
- `importPackage(fileUri)`
### 3.3 运行时相关
- `entry/src/main/ets/adapters/NativeRuntimeAdapter.ts`
- `startSession(appId)`
- `restartSession(appId)`
- `stopSession()`
- `notifyPageShow()`
- `notifyPageHide()`
### 3.4 Service 收口层
- `entry/src/main/ets/services/AppService.ts`
- `entry/src/main/ets/services/ImportService.ts`
- `entry/src/main/ets/services/RuntimeService.ts`
说明:
- 后续 NAPI 接入时,优先替换 Adapter 内部实现
- 页面层和 Store 层不直接碰 native 细节
## 4. 当前可见结果
当前已经具备:
- 列表页可见运行入口与导入入口
- 导入成功后返回列表并刷新
- 运行页可见 `starting / running / stopped` 状态展示
- 运行页工具栏根据状态控制按钮可用性
## 5. 本轮不做的事
本轮不继续扩大量新页面/组件,只收口:
- 现有页面可见闭环
- 现有 Adapter/NAPI 接缝
- 现有运行入口与状态提示
@@ -3,6 +3,8 @@ export struct RuntimeToolbar {
onBack?: () => void onBack?: () => void
onRestart?: () => void onRestart?: () => void
onExit?: () => void onExit?: () => void
@Prop canRestart: boolean = true
@Prop canExit: boolean = true
build() { build() {
Row({ space: 12 }) { Row({ space: 12 }) {
@@ -11,16 +13,20 @@ export struct RuntimeToolbar {
this.onBack() this.onBack()
} }
}) })
Button('重启').onClick(() => { Button('重启')
if (this.onRestart) { .enabled(this.canRestart)
this.onRestart() .onClick(() => {
} if (this.onRestart) {
}) this.onRestart()
Button('退出').onClick(() => { }
if (this.onExit) { })
this.onExit() Button('退出')
} .enabled(this.canExit)
}) .onClick(() => {
if (this.onExit) {
this.onExit()
}
})
} }
.padding(16) .padding(16)
} }
+2
View File
@@ -65,6 +65,7 @@ export struct AppListPage {
Column() { Column() {
Text(`${this.refreshTick}-${this.refreshToken}`).fontSize(1).opacity(0) Text(`${this.refreshTick}-${this.refreshToken}`).fontSize(1).opacity(0)
PageHeader({ title: '应用列表' }) PageHeader({ title: '应用列表' })
StatusBanner({ text: '运行入口:点击“可运行”应用卡片进入运行页;导入入口:点击下方“导入应用”。' })
if (this.selectedAppId) { if (this.selectedAppId) {
StatusBanner({ text: `已选择应用:${this.selectedAppId}` }) StatusBanner({ text: `已选择应用:${this.selectedAppId}` })
} }
@@ -81,6 +82,7 @@ export struct AppListPage {
items: this.store.items, items: this.store.items,
onItemTap: (appId: string) => this.openRunPage(appId) onItemTap: (appId: string) => this.openRunPage(appId)
}) })
ImportEntryButton({ onTap: () => this.openImportPage() })
} }
} }
.width('100%') .width('100%')
+2
View File
@@ -64,6 +64,8 @@ export struct RunPage {
StatusBanner({ text: this.store.error.message }) StatusBanner({ text: this.store.error.message })
} }
RuntimeToolbar({ RuntimeToolbar({
canRestart: this.store.canRestart,
canExit: this.store.canExit,
onBack: () => this.onBackClick(), onBack: () => this.onBackClick(),
onRestart: () => this.onRestart(), onRestart: () => this.onRestart(),
onExit: () => this.onExit() onExit: () => this.onExit()