中国优质的IT技术网站
专业IT技术创作平台
IT职业在线教育平台
分布式存储数据的方法
微信扫码分享
// EntryAbility.ets export default class EntryAbility extends UIAbility { onContinue(wantParam: Record<string, Object | undefined>): AbilityConstant.OnContinueResult { // The data to be migrated is stored in wantParam. wantParam.appendix = JSON.stringify(AppStorage.get<Array<AppendixBean>>('appendix')); try { let sessionId: string = distributedDataObject.genSessionId(); if (this.localObject) { this.localObject.setSessionId(sessionId); this.localObject['recipient'] = AppStorage.get('recipient'); this.localObject['sender'] = AppStorage.get('sender'); this.localObject['subject'] = AppStorage.get('subject'); this.localObject['emailContent'] = AppStorage.get('emailContent'); this.targetDeviceId = wantParam.targetDevice as string; this.localObject.save(wantParam.targetDevice as string).then(() => { Logger.info('onContinue localObject save success'); }).catch((err: BusinessError) => { Logger.error(`Failed to save. Code:${err.code},message:${err.message}`); }); } wantParam.distributedSessionId = sessionId; } catch (error) { Logger.error('EntryAbility', 'distributedDataObject failed', `code ${(error as BusinessError).code}`); } return AbilityConstant.OnContinueResult.AGREE; } }