feat: add ArkTS shell route placeholder flow
This commit is contained in:
1 parent
04cb1178dd
commit
eaf07f1902
5 files changed
+152
-6
No files matched your search
@@ -6,9 +6,11 @@ import { StatusBanner } from '../components/common/StatusBanner'
|
||||
import { ImportEntryButton } from '../components/appList/ImportEntryButton'
|
||||
import { AppListView } from '../components/appList/AppListView'
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct AppListPage {
|
||||
export struct AppListPage {
|
||||
onNavigateImport?: () => void
|
||||
onNavigateRun?: (appId: string) => void
|
||||
|
||||
@State refreshTick: number = 0
|
||||
@State selectedAppId: string = ''
|
||||
private store: AppCatalogStore = new AppCatalogStore()
|
||||
@@ -31,11 +33,19 @@ struct AppListPage {
|
||||
}
|
||||
|
||||
private openImportPage(): void {
|
||||
if (this.onNavigateImport) {
|
||||
this.onNavigateImport()
|
||||
return
|
||||
}
|
||||
console.info('TODO: open ImportPage')
|
||||
}
|
||||
|
||||
private openRunPage(appId: string): void {
|
||||
this.selectedAppId = appId
|
||||
if (this.onNavigateRun) {
|
||||
this.onNavigateRun(appId)
|
||||
return
|
||||
}
|
||||
console.info(`TODO: open RunPage for ${appId}`)
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,9 @@ import { ImportResultPanel } from '../components/import/ImportResultPanel'
|
||||
|
||||
@Component
|
||||
export struct ImportPage {
|
||||
onBack?: () => void
|
||||
onImportSuccess?: () => void
|
||||
|
||||
@State refreshTick: number = 0
|
||||
private store: ImportStore = new ImportStore()
|
||||
private unsubscribe?: () => void
|
||||
@@ -34,12 +37,20 @@ export struct ImportPage {
|
||||
|
||||
private async onImport(): Promise<void> {
|
||||
await this.store.startImport()
|
||||
if (this.store.phase === 'success' && this.onImportSuccess) {
|
||||
this.onImportSuccess()
|
||||
}
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Text(`${this.refreshTick}`).fontSize(1).opacity(0)
|
||||
PageHeader({ title: '导入应用' })
|
||||
if (this.onBack) {
|
||||
Button('返回列表').onClick(() => {
|
||||
this.onBack && this.onBack()
|
||||
}).margin({ bottom: 8, left: 16, right: 16 })
|
||||
}
|
||||
if (this.store.error) {
|
||||
StatusBanner({ text: this.store.error.message })
|
||||
}
|
||||
@@ -48,13 +59,13 @@ export struct ImportPage {
|
||||
PackagePreviewCard({ name: this.store.previewInfo.name })
|
||||
Button('开始导入').onClick(() => {
|
||||
this.onImport()
|
||||
})
|
||||
}).margin(16)
|
||||
}
|
||||
if (this.store.phase === 'importing') {
|
||||
ImportProgressPanel({ text: '导入中' })
|
||||
}
|
||||
if (this.store.phase === 'success') {
|
||||
ImportResultPanel({ text: '导入成功' })
|
||||
ImportResultPanel({ text: '导入成功,正在返回列表' })
|
||||
}
|
||||
if (this.store.phase === 'failed') {
|
||||
ImportResultPanel({ text: '导入失败' })
|
||||
|
||||
@@ -8,6 +8,9 @@ import { RuntimeStatusOverlay } from '../components/runtime/RuntimeStatusOverlay
|
||||
|
||||
@Component
|
||||
export struct RunPage {
|
||||
appId?: string
|
||||
onBack?: () => void
|
||||
|
||||
@State refreshTick: number = 0
|
||||
private store: RuntimeSessionStore = new RuntimeSessionStore()
|
||||
private unsubscribe?: () => void
|
||||
@@ -18,6 +21,9 @@ export struct RunPage {
|
||||
this.refreshTick += 1
|
||||
})
|
||||
}
|
||||
if (this.appId) {
|
||||
this.store.startSession(this.appId)
|
||||
}
|
||||
}
|
||||
|
||||
aboutToDisappear(): void {
|
||||
@@ -27,7 +33,11 @@ export struct RunPage {
|
||||
}
|
||||
}
|
||||
|
||||
private onBack(): void {
|
||||
private onBackClick(): void {
|
||||
if (this.onBack) {
|
||||
this.onBack()
|
||||
return
|
||||
}
|
||||
console.info('TODO: back to AppListPage')
|
||||
}
|
||||
|
||||
@@ -37,17 +47,23 @@ export struct RunPage {
|
||||
|
||||
private async onExit(): Promise<void> {
|
||||
await this.store.stopSession()
|
||||
if (this.onBack) {
|
||||
this.onBack()
|
||||
}
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Text(`${this.refreshTick}`).fontSize(1).opacity(0)
|
||||
PageHeader({ title: '运行页' })
|
||||
if (this.appId) {
|
||||
StatusBanner({ text: `当前应用:${this.appId}` })
|
||||
}
|
||||
if (this.store.error) {
|
||||
StatusBanner({ text: this.store.error.message })
|
||||
}
|
||||
RuntimeToolbar({
|
||||
onBack: () => this.onBack(),
|
||||
onBack: () => this.onBackClick(),
|
||||
onRestart: () => this.onRestart(),
|
||||
onExit: () => this.onExit()
|
||||
})
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
import { AppListPage } from './AppListPage'
|
||||
import { ImportPage } from './ImportPage'
|
||||
import { RunPage } from './RunPage'
|
||||
|
||||
export type ShellRoute = 'appList' | 'import' | 'run'
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct ShellRootPage {
|
||||
@State currentRoute: ShellRoute = 'appList'
|
||||
@State currentAppId: string = ''
|
||||
@State catalogRefreshTick: number = 0
|
||||
|
||||
private goToImport(): void {
|
||||
this.currentRoute = 'import'
|
||||
}
|
||||
|
||||
private goToRun(appId: string): void {
|
||||
this.currentAppId = appId
|
||||
this.currentRoute = 'run'
|
||||
}
|
||||
|
||||
private backToList(): void {
|
||||
this.currentRoute = 'appList'
|
||||
}
|
||||
|
||||
private backToListAfterImport(): void {
|
||||
this.catalogRefreshTick += 1
|
||||
this.currentRoute = 'appList'
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Text(`${this.catalogRefreshTick}`).fontSize(1).opacity(0)
|
||||
if (this.currentRoute === 'appList') {
|
||||
AppListPage({
|
||||
onNavigateImport: () => this.goToImport(),
|
||||
onNavigateRun: (appId: string) => this.goToRun(appId)
|
||||
})
|
||||
}
|
||||
if (this.currentRoute === 'import') {
|
||||
ImportPage({
|
||||
onBack: () => this.backToList(),
|
||||
onImportSuccess: () => this.backToListAfterImport()
|
||||
})
|
||||
}
|
||||
if (this.currentRoute === 'run') {
|
||||
RunPage({
|
||||
appId: this.currentAppId,
|
||||
onBack: () => this.backToList()
|
||||
})
|
||||
}
|
||||
}
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user