feat: wire ArkTS page actions to store placeholders

This commit is contained in:
OpenClaw committed 2026-03-09 14:42:32 +08:00
1 parent 879e1526f1
commit 0b20b5dd43
7 files changed
+87 -6

No files matched your search

@@ -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 结果
@@ -1,6 +1,13 @@
@Component
export struct ImportEntryButton {
onTap?: () => void
build() {
Button('导入应用')
.onClick(() => {
if (this.onTap) {
this.onTap()
}
})
}
}
@@ -1,6 +1,13 @@
@Component
export struct ImportSourceSelector {
onPick?: () => void
build() {
Button('选择本地文件')
.onClick(() => {
if (this.onPick) {
this.onPick()
}
})
}
}
@@ -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)
}
+5 -1
View File
@@ -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 })
}
+6 -1
View File
@@ -10,13 +10,18 @@ import { ImportResultPanel } from '../components/import/ImportResultPanel'
export struct ImportPage {
private store: ImportStore = new ImportStore()
private async onPickFile(): Promise<void> {
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 })
}
+17 -1
View File
@@ -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<void> {
await this.store.restartSession()
}
private async onExit(): Promise<void> {
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}` })