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
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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 })
|
||||
}
|
||||
|
||||
@@ -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 })
|
||||
}
|
||||
|
||||
@@ -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}` })
|
||||
|
||||
Reference in new issue
Block a user