diff --git a/common/src/main/ets/default/manager/AmsMissionManager.ts b/common/src/main/ets/default/manager/AmsMissionManager.ts index da641ad8..ab3c0c70 100644 --- a/common/src/main/ets/default/manager/AmsMissionManager.ts +++ b/common/src/main/ets/default/manager/AmsMissionManager.ts @@ -83,6 +83,7 @@ class AmsMissionManager { recentMissionInfo.abilityName = recentItem.want.abilityName; recentMissionInfo.moduleName = recentItem.want.parameters?.moduleName ? String(recentItem.want.parameters?.moduleName) : ''; recentMissionInfo.lockedState = recentItem.lockedState; + recentMissionInfo.snapShotTime = recentItem.timestamp; const appInfo = await launcherAbilityManager.getAppInfoByBundleName(recentMissionInfo.bundleName, recentMissionInfo.abilityName); if (appInfo == undefined) { continue; diff --git a/feature/recents/src/main/ets/default/viewmodel/RecentMissionsViewModel.ets b/feature/recents/src/main/ets/default/viewmodel/RecentMissionsViewModel.ts similarity index 96% rename from feature/recents/src/main/ets/default/viewmodel/RecentMissionsViewModel.ets rename to feature/recents/src/main/ets/default/viewmodel/RecentMissionsViewModel.ts index 9fe56a12..b67256ce 100644 --- a/feature/recents/src/main/ets/default/viewmodel/RecentMissionsViewModel.ets +++ b/feature/recents/src/main/ets/default/viewmodel/RecentMissionsViewModel.ts @@ -31,6 +31,7 @@ export class RecentMissionsViewModel { private mRecentModeFeatureConfig: RecentModeFeatureConfig; private mRecentMissionsLimit: number; private mRecentMissionsList: RecentMissionInfo[] = []; + private mRecentMissionsRowType: string = 'single'; private constructor() { Log.showInfo(TAG, 'constructor start'); @@ -39,6 +40,7 @@ export class RecentMissionsViewModel { if (config instanceof RecentModeFeatureConfig) { this.mRecentModeFeatureConfig = config; this.mRecentMissionsLimit = this.mRecentModeFeatureConfig.getRecentMissionsLimit(); + this.mRecentMissionsRowType = this.mRecentModeFeatureConfig.getRecentMissionsRowType(); } } @@ -68,7 +70,7 @@ export class RecentMissionsViewModel { * @return {string} row type */ getRecentMissionsRowType(): string { - return this.mRecentModeFeatureConfig.getRecentMissionsRowType(); + return this.mRecentMissionsRowType; } /** @@ -77,10 +79,6 @@ export class RecentMissionsViewModel { async getRecentMissionsList(): Promise { Log.showDebug(TAG, 'getRecentMissionsList start'); this.mRecentMissionsList = await amsMissionManager.getRecentMissionsList(); - const snapShotTime = new Date().toString(); - for (let item of this.mRecentMissionsList) { - item.snapShotTime = snapShotTime; - } if (globalThis.recentMode && windowManager.isSplitWindowMode(globalThis.recentMode)) { this.mRecentMissionsList.forEach((item, index) => { if (item.missionId == globalThis.splitMissionId) { diff --git a/product/phone/src/main/ets/pages/RecentView.ets b/product/phone/src/main/ets/pages/RecentView.ets index 92c39420..a3d1441e 100644 --- a/product/phone/src/main/ets/pages/RecentView.ets +++ b/product/phone/src/main/ets/pages/RecentView.ets @@ -31,44 +31,52 @@ struct RecentView { @StorageLink('recentMissionsList') recentMissionsList: RecentMissionInfo[] = []; @State isClickSubComponent: boolean = false; private mRecentMissionsStage: RecentMissionsStage = new RecentMissionsStage(); - @State mRecentMissionsViewModel: RecentMissionsViewModel = undefined; + private mRecentMissionsViewModel?: RecentMissionsViewModel; + @State mRecentMissionsRowType: string = ''; + @State recentLoadedCompleted: boolean = false; onPageShow(): void { Log.showInfo(TAG, 'onPageShow'); this.isClickSubComponent = false; this.mRecentMissionsStage.onCreate(); this.mRecentMissionsViewModel = RecentMissionsViewModel.getInstance(); + this.mRecentMissionsRowType = this.mRecentMissionsViewModel.getRecentMissionsRowType(); this.mRecentMissionsViewModel.getRecentMissionsList(); AppStorage.setOrCreate('recentIdx', 0); + this.recentLoadedCompleted = true; } onPageHide(): void { Log.showInfo(TAG, `onPageHide`); + this.recentLoadedCompleted = false; this.isClickSubComponent = false; this.mRecentMissionsStage.onDestroy(); - Log.showInfo(TAG, `onPageHide end`); } onBackPress(): boolean { Log.showInfo(TAG, 'RecentMission EntryView onBackPress'); windowManager.hideWindow(windowManager.RECENT_WINDOW_NAME); - Log.showInfo(TAG, 'RecentMission EntryView onBackPress end'); return true; } build() { Column() { - if (!Array.isArray(this.recentMissionsList) || this.recentMissionsList.length == 0 || !this.mRecentMissionsViewModel) { - Text($r('app.string.No_running_apps_recently')) - .fontColor(RecentsStyleConstants.DEFAULT_FONT_COLOR) - .fontSize(RecentsStyleConstants.DEFAULT_FONT_SIZE); - } else { - if (this.mRecentMissionsViewModel.getRecentMissionsRowType() === 'single') { - RecentMissionsSingleLayout({ recentMissionsSingleList: $recentMissionsList, - isClickSubComponent: $isClickSubComponent}); + if (this.recentMissionsList && this.mRecentMissionsViewModel && this.mRecentMissionsRowType) { + if (this.recentMissionsList.length) { + if (this.mRecentMissionsRowType === 'single') { + RecentMissionsSingleLayout({ recentMissionsSingleList: $recentMissionsList, + isClickSubComponent: $isClickSubComponent}); + } + if (this.mRecentMissionsRowType === 'double') { + RecentMissionsDoubleLayout({ recentMissionsDoubleList: $recentMissionsList, + isClickSubComponent: $isClickSubComponent}); + } } else { - RecentMissionsDoubleLayout({ recentMissionsDoubleList: $recentMissionsList, - isClickSubComponent: $isClickSubComponent}); + if (this.recentLoadedCompleted) { + Text($r('app.string.No_running_apps_recently')) + .fontColor(RecentsStyleConstants.DEFAULT_FONT_COLOR) + .fontSize(RecentsStyleConstants.DEFAULT_FONT_SIZE) + } } } if (this.traceBuildEnd()) { } @@ -81,7 +89,7 @@ struct RecentView { .onClick(() => { if (!this.isClickSubComponent) { Log.showInfo(TAG, 'click recent missions area'); - this.mRecentMissionsViewModel.backView(); + this.mRecentMissionsViewModel?.backView && this.mRecentMissionsViewModel.backView(); } }) }