diff --git a/docs/product/ARKTS_MOCK_FLOW_PROGRESS_V0.md b/docs/product/ARKTS_MOCK_FLOW_PROGRESS_V0.md new file mode 100644 index 0000000..944bc23 --- /dev/null +++ b/docs/product/ARKTS_MOCK_FLOW_PROGRESS_V0.md @@ -0,0 +1,32 @@ +# ArkTS Mock 数据闭环进展 v0 + +项目:MRP 模拟器鸿蒙化 +角色:RD Frontend + +## 本轮完成 + +### 1. Adapter 已补 mock 数据 +- `NativeAppAdapter.listInstalledApps()` 返回 2 个示例应用 +- `NativeImportAdapter.pickFile()` 返回 mock 文件 URI +- `NativeImportAdapter.inspectPackage()` 返回 mock 预览信息 +- `NativeImportAdapter.importPackage()` 返回 mock appId +- `NativeRuntimeAdapter` 保持空成功返回 + +### 2. AppListView 已支持点击回调 +新增: +- `onItemTap(appId)` + +### 3. AppListPage 已接列表点击占位 +新增: +- `selectedAppId` +- 点击列表项后记录 appId,并显示 Banner 提示 + +## 当前结论 +- 页面展示已不再完全依赖真实 native 接口 +- 列表页已有最小可演示数据流 +- 下一步可继续补路由占位与 Import -> List 刷新占位 + +## 下一步 +1. 补最小路由占位文档 +2. 让导入成功后触发列表刷新占位 +3. 让运行页支持 mock 启动入口 diff --git a/entry/src/main/ets/adapters/NativeAppAdapter.ts b/entry/src/main/ets/adapters/NativeAppAdapter.ts index f59cb3b..4c3dd84 100644 --- a/entry/src/main/ets/adapters/NativeAppAdapter.ts +++ b/entry/src/main/ets/adapters/NativeAppAdapter.ts @@ -8,6 +8,19 @@ export interface NativeInstalledAppDTO { export class NativeAppAdapter { async listInstalledApps(): Promise { - return [] + return [ + { + appId: 'demo.app.001', + name: 'Demo MRP App', + version: '1.0.0', + runnable: true + }, + { + appId: 'demo.app.002', + name: 'Broken Sample', + version: '0.9.1', + runnable: false + } + ] } } diff --git a/entry/src/main/ets/adapters/NativeImportAdapter.ts b/entry/src/main/ets/adapters/NativeImportAdapter.ts index d5bc5d9..cd2379f 100644 --- a/entry/src/main/ets/adapters/NativeImportAdapter.ts +++ b/entry/src/main/ets/adapters/NativeImportAdapter.ts @@ -8,14 +8,19 @@ export interface NativePackagePreviewDTO { export class NativeImportAdapter { async pickFile(): Promise { - return null + return 'file://mock/demo.mrp' } async inspectPackage(_fileUri: string): Promise { - return { name: '', valid: false } + return { + name: 'Imported Demo App', + version: '1.0.0', + size: 204800, + valid: true + } } async importPackage(_fileUri: string): Promise<{ appId: string }> { - return { appId: '' } + return { appId: 'demo.imported.001' } } } diff --git a/entry/src/main/ets/adapters/NativeRuntimeAdapter.ts b/entry/src/main/ets/adapters/NativeRuntimeAdapter.ts index 3ea1799..1ae3e91 100644 --- a/entry/src/main/ets/adapters/NativeRuntimeAdapter.ts +++ b/entry/src/main/ets/adapters/NativeRuntimeAdapter.ts @@ -1,7 +1,21 @@ export class NativeRuntimeAdapter { - async startSession(_appId: string): Promise {} - async restartSession(_appId: string): Promise {} - async stopSession(): Promise {} - async notifyPageShow(): Promise {} - async notifyPageHide(): Promise {} + async startSession(_appId: string): Promise { + return + } + + async restartSession(_appId: string): Promise { + return + } + + async stopSession(): Promise { + return + } + + async notifyPageShow(): Promise { + return + } + + async notifyPageHide(): Promise { + return + } } diff --git a/entry/src/main/ets/components/appList/AppListView.ets b/entry/src/main/ets/components/appList/AppListView.ets index ea318a8..d1e8e78 100644 --- a/entry/src/main/ets/components/appList/AppListView.ets +++ b/entry/src/main/ets/components/appList/AppListView.ets @@ -3,13 +3,26 @@ import type { AppItemVM } from '../../models/AppItemVM' @Component export struct AppListView { @Prop items: AppItemVM[] = [] + onItemTap?: (appId: string) => void build() { List() { ForEach(this.items, (item: AppItemVM) => { ListItem() { - Text(item.name) + Column() { + Text(item.name).fontSize(18) + Text(item.version || '').fontSize(12) + Text(item.status).fontSize(12) + } + .width('100%') + .padding(16) + .alignItems(HorizontalAlign.Start) } + .onClick(() => { + if (this.onItemTap) { + this.onItemTap(item.id) + } + }) }, (item: AppItemVM) => item.id) } } diff --git a/entry/src/main/ets/pages/AppListPage.ets b/entry/src/main/ets/pages/AppListPage.ets index 66415a9..48d4090 100644 --- a/entry/src/main/ets/pages/AppListPage.ets +++ b/entry/src/main/ets/pages/AppListPage.ets @@ -10,6 +10,7 @@ import { AppListView } from '../components/appList/AppListView' @Component struct AppListPage { @State refreshTick: number = 0 + @State selectedAppId: string = '' private store: AppCatalogStore = new AppCatalogStore() private unsubscribe?: () => void @@ -33,10 +34,18 @@ struct AppListPage { console.info('TODO: open ImportPage') } + private openRunPage(appId: string): void { + this.selectedAppId = appId + console.info(`TODO: open RunPage for ${appId}`) + } + build() { Column() { Text(`${this.refreshTick}`).fontSize(1).opacity(0) PageHeader({ title: '应用列表' }) + if (this.selectedAppId) { + StatusBanner({ text: `已选择应用:${this.selectedAppId}` }) + } if (this.store.error) { StatusBanner({ text: this.store.error.message }) } @@ -46,7 +55,10 @@ struct AppListPage { EmptyState({ text: '暂无已导入应用' }) ImportEntryButton({ onTap: () => this.openImportPage() }) } else { - AppListView({ items: this.store.items }) + AppListView({ + items: this.store.items, + onItemTap: (appId: string) => this.openRunPage(appId) + }) } } .width('100%')