feat: wire ArkTS page actions to store placeholders
This commit is contained in:
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
|
@Component
|
||||||
export struct ImportEntryButton {
|
export struct ImportEntryButton {
|
||||||
|
onTap?: () => void
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
Button('导入应用')
|
Button('导入应用')
|
||||||
|
.onClick(() => {
|
||||||
|
if (this.onTap) {
|
||||||
|
this.onTap()
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,13 @@
|
|||||||
@Component
|
@Component
|
||||||
export struct ImportSourceSelector {
|
export struct ImportSourceSelector {
|
||||||
|
onPick?: () => void
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
Button('选择本地文件')
|
Button('选择本地文件')
|
||||||
|
.onClick(() => {
|
||||||
|
if (this.onPick) {
|
||||||
|
this.onPick()
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,26 @@
|
|||||||
@Component
|
@Component
|
||||||
export struct RuntimeToolbar {
|
export struct RuntimeToolbar {
|
||||||
|
onBack?: () => void
|
||||||
|
onRestart?: () => void
|
||||||
|
onExit?: () => void
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
Row({ space: 12 }) {
|
Row({ space: 12 }) {
|
||||||
Button('返回')
|
Button('返回').onClick(() => {
|
||||||
Button('重启')
|
if (this.onBack) {
|
||||||
Button('退出')
|
this.onBack()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
Button('重启').onClick(() => {
|
||||||
|
if (this.onRestart) {
|
||||||
|
this.onRestart()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
Button('退出').onClick(() => {
|
||||||
|
if (this.onExit) {
|
||||||
|
this.onExit()
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
.padding(16)
|
.padding(16)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ struct AppListPage {
|
|||||||
this.store.loadApps()
|
this.store.loadApps()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private openImportPage(): void {
|
||||||
|
console.info('TODO: open ImportPage')
|
||||||
|
}
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
Column() {
|
Column() {
|
||||||
PageHeader({ title: '应用列表' })
|
PageHeader({ title: '应用列表' })
|
||||||
@@ -25,7 +29,7 @@ struct AppListPage {
|
|||||||
LoadingBlock({ text: '正在加载应用列表' })
|
LoadingBlock({ text: '正在加载应用列表' })
|
||||||
} else if (this.store.items.length === 0) {
|
} else if (this.store.items.length === 0) {
|
||||||
EmptyState({ text: '暂无已导入应用' })
|
EmptyState({ text: '暂无已导入应用' })
|
||||||
ImportEntryButton()
|
ImportEntryButton({ onTap: () => this.openImportPage() })
|
||||||
} else {
|
} else {
|
||||||
AppListView({ items: this.store.items })
|
AppListView({ items: this.store.items })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,13 +10,18 @@ import { ImportResultPanel } from '../components/import/ImportResultPanel'
|
|||||||
export struct ImportPage {
|
export struct ImportPage {
|
||||||
private store: ImportStore = new ImportStore()
|
private store: ImportStore = new ImportStore()
|
||||||
|
|
||||||
|
private async onPickFile(): Promise<void> {
|
||||||
|
await this.store.pickFile()
|
||||||
|
await this.store.analyzeSelectedFile()
|
||||||
|
}
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
Column() {
|
Column() {
|
||||||
PageHeader({ title: '导入应用' })
|
PageHeader({ title: '导入应用' })
|
||||||
if (this.store.error) {
|
if (this.store.error) {
|
||||||
StatusBanner({ text: this.store.error.message })
|
StatusBanner({ text: this.store.error.message })
|
||||||
}
|
}
|
||||||
ImportSourceSelector()
|
ImportSourceSelector({ onPick: () => this.onPickFile() })
|
||||||
if (this.store.previewInfo) {
|
if (this.store.previewInfo) {
|
||||||
PackagePreviewCard({ name: this.store.previewInfo.name })
|
PackagePreviewCard({ name: this.store.previewInfo.name })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,13 +10,29 @@ import { RuntimeStatusOverlay } from '../components/runtime/RuntimeStatusOverlay
|
|||||||
export struct RunPage {
|
export struct RunPage {
|
||||||
private store: RuntimeSessionStore = new RuntimeSessionStore()
|
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() {
|
build() {
|
||||||
Column() {
|
Column() {
|
||||||
PageHeader({ title: '运行页' })
|
PageHeader({ title: '运行页' })
|
||||||
if (this.store.error) {
|
if (this.store.error) {
|
||||||
StatusBanner({ text: this.store.error.message })
|
StatusBanner({ text: this.store.error.message })
|
||||||
}
|
}
|
||||||
RuntimeToolbar()
|
RuntimeToolbar({
|
||||||
|
onBack: () => this.onBack(),
|
||||||
|
onRestart: () => this.onRestart(),
|
||||||
|
onExit: () => this.onExit()
|
||||||
|
})
|
||||||
RuntimeContainer()
|
RuntimeContainer()
|
||||||
if (this.store.phase !== 'running') {
|
if (this.store.phase !== 'running') {
|
||||||
RuntimeStatusOverlay({ text: `当前状态:${this.store.phase}` })
|
RuntimeStatusOverlay({ text: `当前状态:${this.store.phase}` })
|
||||||
|
|||||||
Reference in new issue
Block a user