中国优质的IT技术网站
专业IT技术创作平台
IT职业在线教育平台
分布式恢复数据的方法
微信扫码分享
// EntryAbility.ets export default class EntryAbility extends UIAbility { async restoringData(want: Want, launchParam: AbilityConstant.LaunchParam): Promise<void> { this.checkPermissions(); // Recovering migrated data from want. if (launchParam.launchReason === AbilityConstant.LaunchReason.CONTINUATION) { // get user data from want params. AppStorage.setOrCreate<string>('isContinuation', CommonConstants.CAN_CONTINUATION); AppStorage.setOrCreate<Array<AppendixBean>>('appendix', JSON.parse(want.parameters?.appendix as string) as Array<AppendixBean>); let sessionId : string = want.parameters?.distributedSessionId as string; if (!this.localObject) { let mailInfo: MailInfo = new MailInfo(undefined, undefined, undefined, undefined); this.localObject = distributedDataObject.create(this.context, mailInfo); this.localObject.on('change', this.changeCall); } if (sessionId && this.localObject) { await this.localObject.setSessionId(sessionId); AppStorage.setOrCreate('recipient', this.localObject['recipient']); AppStorage.setOrCreate('sender', this.localObject['sender']); AppStorage.setOrCreate('subject', this.localObject['subject']); AppStorage.setOrCreate('emailContent', this.localObject['emailContent']); } this.context.restoreWindowStage(new LocalStorage()); } } }