feat: refresh app list after mock import flow
This commit is contained in:
1 parent
bbf4123844
commit
36671fd8c1
4 files changed
+53
-2
No files matched your search
@@ -0,0 +1,34 @@
|
||||
# ArkTS 导入成功后的列表刷新进展 v0
|
||||
|
||||
项目:MRP 模拟器鸿蒙化
|
||||
角色:RD Frontend
|
||||
|
||||
## 本轮完成
|
||||
|
||||
### 1. AppListPage 已支持 refreshToken
|
||||
新增:
|
||||
- `@Prop refreshToken`
|
||||
- `ensureRefreshByToken()`
|
||||
- 当 ShellRootPage 变更 refreshToken 时,触发 `store.refreshApps()`
|
||||
|
||||
### 2. ShellRootPage 已接导入成功后的刷新意图
|
||||
当前逻辑:
|
||||
- Import 成功 -> `backToListAfterImport()`
|
||||
- `catalogRefreshTick += 1`
|
||||
- 切回 `appList`
|
||||
- `AppListPage` 接收新 token 并刷新列表
|
||||
|
||||
### 3. AppListView 已禁用不可运行应用点击
|
||||
当前逻辑:
|
||||
- `status === 'ready'` 才允许触发 `onItemTap`
|
||||
- 不可运行应用降透明度显示
|
||||
|
||||
## 当前结论
|
||||
- 导入成功后的列表刷新占位链路已补齐
|
||||
- 列表页已具备最小可交互约束
|
||||
- 仍为 POC 占位实现,后续可替换为正式路由与状态框架
|
||||
|
||||
## 下一步
|
||||
1. 给 RunPage 增加 mock 启动中 -> 运行中状态过渡
|
||||
2. 给 ImportPage 增加返回后重置本地状态
|
||||
3. 补 ArkTS 页面流演示说明图
|
||||
@@ -12,13 +12,17 @@ export struct AppListView {
|
||||
Column() {
|
||||
Text(item.name).fontSize(18)
|
||||
Text(item.version || '').fontSize(12)
|
||||
Text(item.status).fontSize(12)
|
||||
Text(item.status === 'ready' ? '可运行' : '不可运行').fontSize(12)
|
||||
}
|
||||
.width('100%')
|
||||
.padding(16)
|
||||
.opacity(item.status === 'ready' ? 1 : 0.5)
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
}
|
||||
.onClick(() => {
|
||||
if (item.status !== 'ready') {
|
||||
return
|
||||
}
|
||||
if (this.onItemTap) {
|
||||
this.onItemTap(item.id)
|
||||
}
|
||||
|
||||
@@ -8,11 +8,13 @@ import { AppListView } from '../components/appList/AppListView'
|
||||
|
||||
@Component
|
||||
export struct AppListPage {
|
||||
@Prop refreshToken: number = 0
|
||||
onNavigateImport?: () => void
|
||||
onNavigateRun?: (appId: string) => void
|
||||
|
||||
@State refreshTick: number = 0
|
||||
@State selectedAppId: string = ''
|
||||
private lastHandledRefreshToken: number = -1
|
||||
private store: AppCatalogStore = new AppCatalogStore()
|
||||
private unsubscribe?: () => void
|
||||
|
||||
@@ -32,6 +34,14 @@ export struct AppListPage {
|
||||
}
|
||||
}
|
||||
|
||||
private ensureRefreshByToken(): void {
|
||||
if (this.refreshToken === this.lastHandledRefreshToken) {
|
||||
return
|
||||
}
|
||||
this.lastHandledRefreshToken = this.refreshToken
|
||||
this.store.refreshApps()
|
||||
}
|
||||
|
||||
private openImportPage(): void {
|
||||
if (this.onNavigateImport) {
|
||||
this.onNavigateImport()
|
||||
@@ -50,8 +60,10 @@ export struct AppListPage {
|
||||
}
|
||||
|
||||
build() {
|
||||
this.ensureRefreshByToken()
|
||||
|
||||
Column() {
|
||||
Text(`${this.refreshTick}`).fontSize(1).opacity(0)
|
||||
Text(`${this.refreshTick}-${this.refreshToken}`).fontSize(1).opacity(0)
|
||||
PageHeader({ title: '应用列表' })
|
||||
if (this.selectedAppId) {
|
||||
StatusBanner({ text: `已选择应用:${this.selectedAppId}` })
|
||||
|
||||
@@ -34,6 +34,7 @@ struct ShellRootPage {
|
||||
Text(`${this.catalogRefreshTick}`).fontSize(1).opacity(0)
|
||||
if (this.currentRoute === 'appList') {
|
||||
AppListPage({
|
||||
refreshToken: this.catalogRefreshTick,
|
||||
onNavigateImport: () => this.goToImport(),
|
||||
onNavigateRun: (appId: string) => this.goToRun(appId)
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user