feat: add mock adapter data for ArkTS shell demo flow
This commit is contained in:
1 parent
7fb4e6117a
commit
04cb1178dd
6 files changed
+100
-11
No files matched your search
@@ -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 启动入口
|
||||||
@@ -8,6 +8,19 @@ export interface NativeInstalledAppDTO {
|
|||||||
|
|
||||||
export class NativeAppAdapter {
|
export class NativeAppAdapter {
|
||||||
async listInstalledApps(): Promise<NativeInstalledAppDTO[]> {
|
async listInstalledApps(): Promise<NativeInstalledAppDTO[]> {
|
||||||
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
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,14 +8,19 @@ export interface NativePackagePreviewDTO {
|
|||||||
|
|
||||||
export class NativeImportAdapter {
|
export class NativeImportAdapter {
|
||||||
async pickFile(): Promise<string | null> {
|
async pickFile(): Promise<string | null> {
|
||||||
return null
|
return 'file://mock/demo.mrp'
|
||||||
}
|
}
|
||||||
|
|
||||||
async inspectPackage(_fileUri: string): Promise<NativePackagePreviewDTO> {
|
async inspectPackage(_fileUri: string): Promise<NativePackagePreviewDTO> {
|
||||||
return { name: '', valid: false }
|
return {
|
||||||
|
name: 'Imported Demo App',
|
||||||
|
version: '1.0.0',
|
||||||
|
size: 204800,
|
||||||
|
valid: true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async importPackage(_fileUri: string): Promise<{ appId: string }> {
|
async importPackage(_fileUri: string): Promise<{ appId: string }> {
|
||||||
return { appId: '' }
|
return { appId: 'demo.imported.001' }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,21 @@
|
|||||||
export class NativeRuntimeAdapter {
|
export class NativeRuntimeAdapter {
|
||||||
async startSession(_appId: string): Promise<void> {}
|
async startSession(_appId: string): Promise<void> {
|
||||||
async restartSession(_appId: string): Promise<void> {}
|
return
|
||||||
async stopSession(): Promise<void> {}
|
}
|
||||||
async notifyPageShow(): Promise<void> {}
|
|
||||||
async notifyPageHide(): Promise<void> {}
|
async restartSession(_appId: string): Promise<void> {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
async stopSession(): Promise<void> {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
async notifyPageShow(): Promise<void> {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
async notifyPageHide(): Promise<void> {
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -3,13 +3,26 @@ import type { AppItemVM } from '../../models/AppItemVM'
|
|||||||
@Component
|
@Component
|
||||||
export struct AppListView {
|
export struct AppListView {
|
||||||
@Prop items: AppItemVM[] = []
|
@Prop items: AppItemVM[] = []
|
||||||
|
onItemTap?: (appId: string) => void
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
List() {
|
List() {
|
||||||
ForEach(this.items, (item: AppItemVM) => {
|
ForEach(this.items, (item: AppItemVM) => {
|
||||||
ListItem() {
|
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)
|
}, (item: AppItemVM) => item.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { AppListView } from '../components/appList/AppListView'
|
|||||||
@Component
|
@Component
|
||||||
struct AppListPage {
|
struct AppListPage {
|
||||||
@State refreshTick: number = 0
|
@State refreshTick: number = 0
|
||||||
|
@State selectedAppId: string = ''
|
||||||
private store: AppCatalogStore = new AppCatalogStore()
|
private store: AppCatalogStore = new AppCatalogStore()
|
||||||
private unsubscribe?: () => void
|
private unsubscribe?: () => void
|
||||||
|
|
||||||
@@ -33,10 +34,18 @@ struct AppListPage {
|
|||||||
console.info('TODO: open ImportPage')
|
console.info('TODO: open ImportPage')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private openRunPage(appId: string): void {
|
||||||
|
this.selectedAppId = appId
|
||||||
|
console.info(`TODO: open RunPage for ${appId}`)
|
||||||
|
}
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
Column() {
|
Column() {
|
||||||
Text(`${this.refreshTick}`).fontSize(1).opacity(0)
|
Text(`${this.refreshTick}`).fontSize(1).opacity(0)
|
||||||
PageHeader({ title: '应用列表' })
|
PageHeader({ title: '应用列表' })
|
||||||
|
if (this.selectedAppId) {
|
||||||
|
StatusBanner({ text: `已选择应用:${this.selectedAppId}` })
|
||||||
|
}
|
||||||
if (this.store.error) {
|
if (this.store.error) {
|
||||||
StatusBanner({ text: this.store.error.message })
|
StatusBanner({ text: this.store.error.message })
|
||||||
}
|
}
|
||||||
@@ -46,7 +55,10 @@ struct AppListPage {
|
|||||||
EmptyState({ text: '暂无已导入应用' })
|
EmptyState({ text: '暂无已导入应用' })
|
||||||
ImportEntryButton({ onTap: () => this.openImportPage() })
|
ImportEntryButton({ onTap: () => this.openImportPage() })
|
||||||
} else {
|
} else {
|
||||||
AppListView({ items: this.store.items })
|
AppListView({
|
||||||
|
items: this.store.items,
|
||||||
|
onItemTap: (appId: string) => this.openRunPage(appId)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.width('100%')
|
.width('100%')
|
||||||
|
|||||||
Reference in new issue
Block a user