!3313 StartRecentAbility向ArkTS语言迁移

Merge pull request !3313 from xinking129/startRecentAbility0828
This commit is contained in:
openharmony_ci 2023-09-01 08:48:51 +00:00 committed by Gitee
commit bd2b10e3de
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 8 additions and 7 deletions

View File

@ -13,6 +13,8 @@
* limitations under the License.
*/
import base from '@ohos.base';
import common from '@ohos.app.ability.common';
import systemDateTime from '@ohos.systemDateTime';
import Logger from '../logger/Logger';
@ -22,7 +24,7 @@ struct Index {
@State message: string = 'EntryAbility';
@State date: string = '--:--:--';
@State time: string = '--:--:--';
private context;
private context: common.UIAbilityContext;
build() {
Row() {
@ -50,7 +52,7 @@ struct Index {
abilityName: "EntryAbility",
}).then(() => {
Logger.debug("startAbility successful");
}).catch((err) => {
}).catch((err: base.BusinessError<void>) => {
Logger.debug("startAbility failed");
});
})
@ -69,7 +71,7 @@ struct Index {
abilityName: "SecondAbility",
}).then(() => {
Logger.debug("EntryAbility startAbility successful.");
}).catch((err) => {
}).catch((err: base.BusinessError<void>) => {
Logger.debug("EntryAbility startAbility dailed.");
});
})
@ -81,11 +83,11 @@ struct Index {
}
aboutToAppear() {
this.context = getContext(this) as any;
systemDateTime.getDate().then((date) => {
this.context = getContext(this) as common.UIAbilityContext;
systemDateTime.getDate().then((date: Date) => {
let dateStr = JSON.stringify(date);
this.date = dateStr.substr(1, dateStr.indexOf('T') - 1);
this.time = dateStr.substr(dateStr.indexOf('T') + 1, dateStr.length - (dateStr.indexOf('T') + 1) -2);
this.time = dateStr.substr(dateStr.indexOf('T') + 1, dateStr.length - (dateStr.indexOf('T') + 1) - 2);
});
}
}

View File

@ -43,7 +43,6 @@ export default class SecondAbility extends UIAbility {
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
globalThis.terminal();
}
onForeground() {