修复jscrash-recent-backview

Signed-off-by: gengzhengxing <gengzhengxing1@h-partners.com>
This commit is contained in:
gengzhengxing 2023-10-12 14:22:40 +08:00
parent 76b13cf57b
commit 1e51eb533f
3 changed files with 26 additions and 19 deletions

View File

@ -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;

View File

@ -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 = <RecentModeFeatureConfig> 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<void> {
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) {

View File

@ -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();
}
})
}