From 0b20b5dd43dab62c9a121b0ccefbf06c63c722cb Mon Sep 17 00:00:00 2001 From: OpenClaw Date: Mon, 9 Mar 2026 14:42:32 +0800 Subject: [PATCH] feat: wire ArkTS page actions to store placeholders --- .../ARKTS_PAGE_ACTION_WIRING_PROGRESS_V0.md | 26 +++++++++++++++++++ .../components/appList/ImportEntryButton.ets | 7 +++++ .../import/ImportSourceSelector.ets | 7 +++++ .../ets/components/runtime/RuntimeToolbar.ets | 22 +++++++++++++--- entry/src/main/ets/pages/AppListPage.ets | 6 ++++- entry/src/main/ets/pages/ImportPage.ets | 7 ++++- entry/src/main/ets/pages/RunPage.ets | 18 ++++++++++++- 7 files changed, 87 insertions(+), 6 deletions(-) create mode 100644 docs/product/ARKTS_PAGE_ACTION_WIRING_PROGRESS_V0.md diff --git a/docs/product/ARKTS_PAGE_ACTION_WIRING_PROGRESS_V0.md b/docs/product/ARKTS_PAGE_ACTION_WIRING_PROGRESS_V0.md new file mode 100644 index 0000000..fadd78f --- /dev/null +++ b/docs/product/ARKTS_PAGE_ACTION_WIRING_PROGRESS_V0.md @@ -0,0 +1,26 @@ +# ArkTS 页面事件接线进展 v0 + +项目:MRP 模拟器鸿蒙化 +角色:RD Frontend + +## 本轮完成 + +### 1. 组件已补回调入口 +- `ImportEntryButton`:新增 `onTap` +- `ImportSourceSelector`:新增 `onPick` +- `RuntimeToolbar`:新增 `onBack / onRestart / onExit` + +### 2. 页面已接动作占位 +- `AppListPage`:点击导入按钮触发 `openImportPage()` 占位 +- `ImportPage`:点击选择文件后触发 `pickFile() -> analyzeSelectedFile()` +- `RunPage`:工具栏按钮已接 `restartSession()` / `stopSession()` / 返回占位 + +## 当前结论 +- 页面已不再是纯静态组件树 +- 页面意图已开始进入 Store Action +- 当前仍未接真实路由与 ArkTS 响应式刷新机制 + +## 下一步 +1. 给 Store 增加可驱动页面刷新的最小响应式方案 +2. 补 AppList -> RunPage / AppList -> ImportPage 的路由占位 +3. 预留 Adapter 到 NAPI façade 的 mock 结果 diff --git a/entry/src/main/ets/components/appList/ImportEntryButton.ets b/entry/src/main/ets/components/appList/ImportEntryButton.ets index dc58490..eaf698b 100644 --- a/entry/src/main/ets/components/appList/ImportEntryButton.ets +++ b/entry/src/main/ets/components/appList/ImportEntryButton.ets @@ -1,6 +1,13 @@ @Component export struct ImportEntryButton { + onTap?: () => void + build() { Button('导入应用') + .onClick(() => { + if (this.onTap) { + this.onTap() + } + }) } } diff --git a/entry/src/main/ets/components/import/ImportSourceSelector.ets b/entry/src/main/ets/components/import/ImportSourceSelector.ets index 80dcc88..53011f7 100644 --- a/entry/src/main/ets/components/import/ImportSourceSelector.ets +++ b/entry/src/main/ets/components/import/ImportSourceSelector.ets @@ -1,6 +1,13 @@ @Component export struct ImportSourceSelector { + onPick?: () => void + build() { Button('选择本地文件') + .onClick(() => { + if (this.onPick) { + this.onPick() + } + }) } } diff --git a/entry/src/main/ets/components/runtime/RuntimeToolbar.ets b/entry/src/main/ets/components/runtime/RuntimeToolbar.ets index d6f75db..471b972 100644 --- a/entry/src/main/ets/components/runtime/RuntimeToolbar.ets +++ b/entry/src/main/ets/components/runtime/RuntimeToolbar.ets @@ -1,10 +1,26 @@ @Component export struct RuntimeToolbar { + onBack?: () => void + onRestart?: () => void + onExit?: () => void + build() { Row({ space: 12 }) { - Button('返回') - Button('重启') - Button('退出') + Button('返回').onClick(() => { + if (this.onBack) { + this.onBack() + } + }) + Button('重启').onClick(() => { + if (this.onRestart) { + this.onRestart() + } + }) + Button('退出').onClick(() => { + if (this.onExit) { + this.onExit() + } + }) } .padding(16) } diff --git a/entry/src/main/ets/pages/AppListPage.ets b/entry/src/main/ets/pages/AppListPage.ets index 4f94a26..7db8ebd 100644 --- a/entry/src/main/ets/pages/AppListPage.ets +++ b/entry/src/main/ets/pages/AppListPage.ets @@ -15,6 +15,10 @@ struct AppListPage { this.store.loadApps() } + private openImportPage(): void { + console.info('TODO: open ImportPage') + } + build() { Column() { PageHeader({ title: '应用列表' }) @@ -25,7 +29,7 @@ struct AppListPage { LoadingBlock({ text: '正在加载应用列表' }) } else if (this.store.items.length === 0) { EmptyState({ text: '暂无已导入应用' }) - ImportEntryButton() + ImportEntryButton({ onTap: () => this.openImportPage() }) } else { AppListView({ items: this.store.items }) } diff --git a/entry/src/main/ets/pages/ImportPage.ets b/entry/src/main/ets/pages/ImportPage.ets index f386f8b..d64987b 100644 --- a/entry/src/main/ets/pages/ImportPage.ets +++ b/entry/src/main/ets/pages/ImportPage.ets @@ -10,13 +10,18 @@ import { ImportResultPanel } from '../components/import/ImportResultPanel' export struct ImportPage { private store: ImportStore = new ImportStore() + private async onPickFile(): Promise { + await this.store.pickFile() + await this.store.analyzeSelectedFile() + } + build() { Column() { PageHeader({ title: '导入应用' }) if (this.store.error) { StatusBanner({ text: this.store.error.message }) } - ImportSourceSelector() + ImportSourceSelector({ onPick: () => this.onPickFile() }) if (this.store.previewInfo) { PackagePreviewCard({ name: this.store.previewInfo.name }) } diff --git a/entry/src/main/ets/pages/RunPage.ets b/entry/src/main/ets/pages/RunPage.ets index 925ca0e..c36a586 100644 --- a/entry/src/main/ets/pages/RunPage.ets +++ b/entry/src/main/ets/pages/RunPage.ets @@ -10,13 +10,29 @@ import { RuntimeStatusOverlay } from '../components/runtime/RuntimeStatusOverlay export struct RunPage { private store: RuntimeSessionStore = new RuntimeSessionStore() + private onBack(): void { + console.info('TODO: back to AppListPage') + } + + private async onRestart(): Promise { + await this.store.restartSession() + } + + private async onExit(): Promise { + await this.store.stopSession() + } + build() { Column() { PageHeader({ title: '运行页' }) if (this.store.error) { StatusBanner({ text: this.store.error.message }) } - RuntimeToolbar() + RuntimeToolbar({ + onBack: () => this.onBack(), + onRestart: () => this.onRestart(), + onExit: () => this.onExit() + }) RuntimeContainer() if (this.store.phase !== 'running') { RuntimeStatusOverlay({ text: `当前状态:${this.store.phase}` })