feat: add runtime startup mock flow and import reset
This commit is contained in:
1 parent
36671fd8c1
commit
0a23c3813d
4 files changed
+53
-5
No files matched your search
@@ -0,0 +1,27 @@
|
|||||||
|
# RunPage mock 启动过渡与 ImportPage 重置进展 v0
|
||||||
|
|
||||||
|
项目:MRP 模拟器鸿蒙化
|
||||||
|
角色:RD Frontend
|
||||||
|
|
||||||
|
## 本轮完成
|
||||||
|
|
||||||
|
### 1. Runtime mock 启动过渡已补齐
|
||||||
|
- `NativeRuntimeAdapter.startSession()` 增加 600ms mock 延迟
|
||||||
|
- `NativeRuntimeAdapter.restartSession()` 增加 400ms mock 延迟
|
||||||
|
- `RuntimeSessionStore` 在 start/restart 时显式进入 `starting`
|
||||||
|
- 运行页现在可观察到 `starting -> running` 状态过渡
|
||||||
|
|
||||||
|
### 2. ImportPage 返回/成功后重置已补齐
|
||||||
|
- 新增 `onBackClick()`
|
||||||
|
- 返回列表前调用 `store.reset()`
|
||||||
|
- 导入成功后先 `store.reset()` 再回调 `onImportSuccess()`
|
||||||
|
- `aboutToDisappear()` 兜底重置导入态
|
||||||
|
|
||||||
|
## 当前结论
|
||||||
|
- 运行页已具备最小 mock 启动状态演示能力
|
||||||
|
- 导入页不会把旧预览/旧错误带回下一轮导入
|
||||||
|
|
||||||
|
## 下一步
|
||||||
|
1. 让 RunPage 在不可 restart 时禁用重启按钮
|
||||||
|
2. 给 AppList 增加“导入成功后新应用高亮”占位
|
||||||
|
3. 补一份 POC 演示路径说明
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
|
const sleep = (ms: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, ms))
|
||||||
|
|
||||||
export class NativeRuntimeAdapter {
|
export class NativeRuntimeAdapter {
|
||||||
async startSession(_appId: string): Promise<void> {
|
async startSession(_appId: string): Promise<void> {
|
||||||
return
|
await sleep(600)
|
||||||
}
|
}
|
||||||
|
|
||||||
async restartSession(_appId: string): Promise<void> {
|
async restartSession(_appId: string): Promise<void> {
|
||||||
return
|
await sleep(400)
|
||||||
}
|
}
|
||||||
|
|
||||||
async stopSession(): Promise<void> {
|
async stopSession(): Promise<void> {
|
||||||
|
|||||||
@@ -28,6 +28,14 @@ export struct ImportPage {
|
|||||||
this.unsubscribe()
|
this.unsubscribe()
|
||||||
this.unsubscribe = undefined
|
this.unsubscribe = undefined
|
||||||
}
|
}
|
||||||
|
this.store.reset()
|
||||||
|
}
|
||||||
|
|
||||||
|
private onBackClick(): void {
|
||||||
|
this.store.reset()
|
||||||
|
if (this.onBack) {
|
||||||
|
this.onBack()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async onPickFile(): Promise<void> {
|
private async onPickFile(): Promise<void> {
|
||||||
@@ -37,8 +45,11 @@ export struct ImportPage {
|
|||||||
|
|
||||||
private async onImport(): Promise<void> {
|
private async onImport(): Promise<void> {
|
||||||
await this.store.startImport()
|
await this.store.startImport()
|
||||||
if (this.store.phase === 'success' && this.onImportSuccess) {
|
if (this.store.phase === 'success') {
|
||||||
this.onImportSuccess()
|
this.store.reset()
|
||||||
|
if (this.onImportSuccess) {
|
||||||
|
this.onImportSuccess()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,7 +59,7 @@ export struct ImportPage {
|
|||||||
PageHeader({ title: '导入应用' })
|
PageHeader({ title: '导入应用' })
|
||||||
if (this.onBack) {
|
if (this.onBack) {
|
||||||
Button('返回列表').onClick(() => {
|
Button('返回列表').onClick(() => {
|
||||||
this.onBack && this.onBack()
|
this.onBackClick()
|
||||||
}).margin({ bottom: 8, left: 16, right: 16 })
|
}).margin({ bottom: 8, left: 16, right: 16 })
|
||||||
}
|
}
|
||||||
if (this.store.error) {
|
if (this.store.error) {
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ export class RuntimeSessionStore extends StoreObserver {
|
|||||||
this.currentAppId = appId
|
this.currentAppId = appId
|
||||||
this.phase = 'starting'
|
this.phase = 'starting'
|
||||||
this.error = null
|
this.error = null
|
||||||
|
this.canRestart = false
|
||||||
|
this.canExit = false
|
||||||
this.notify()
|
this.notify()
|
||||||
try {
|
try {
|
||||||
await this.service.start(appId)
|
await this.service.start(appId)
|
||||||
@@ -35,9 +37,15 @@ export class RuntimeSessionStore extends StoreObserver {
|
|||||||
if (!this.currentAppId) {
|
if (!this.currentAppId) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
this.phase = 'starting'
|
||||||
|
this.error = null
|
||||||
|
this.canRestart = false
|
||||||
|
this.notify()
|
||||||
try {
|
try {
|
||||||
await this.service.restart(this.currentAppId)
|
await this.service.restart(this.currentAppId)
|
||||||
this.phase = 'running'
|
this.phase = 'running'
|
||||||
|
this.canRestart = true
|
||||||
|
this.canExit = true
|
||||||
} catch (_error) {
|
} catch (_error) {
|
||||||
this.phase = 'error'
|
this.phase = 'error'
|
||||||
this.error = { message: '重启失败', retryable: true }
|
this.error = { message: '重启失败', retryable: true }
|
||||||
|
|||||||
Reference in new issue
Block a user