Signed-off-by: ma-shaoyin <mashaoyin1@huawei.com>

Changes to be committed:
This commit is contained in:
ma-shaoyin 2023-06-07 11:45:18 +08:00
parent 758868864a
commit 2ff38cc22c

View File

@ -78,19 +78,19 @@ export default class ServiceExtAbility extends ServiceExtensionAbility {
}
});
});
globalThis.releaseContext = ((): void => {
if (globalThis.context !== null) {
globalThis.extensionWin.destroy();
globalThis.context.terminateSelf();
globalThis.context = null;
}
});
}
onDestroy(): void {
console.log(TAG + 'ServiceExtAbility destroyed');
this.releaseContext();
}
private async releaseContext(): Promise<void> {
if (globalThis.context !== null) {
await globalThis.extensionWin.destroy();
await globalThis.context.terminateSelf();
globalThis.context = null;
}
globalThis.releaseContext();
}
private async createWindow(name: string, windowType: number, rect): Promise<void> {
@ -111,7 +111,7 @@ export default class ServiceExtAbility extends ServiceExtensionAbility {
win.on('windowEvent', (data) => {
console.log(TAG + 'windowEvent:' + JSON.stringify(data));
if (data === window.WindowEventType.WINDOW_INACTIVE) {
this.releaseContext();
globalThis.releaseContext();
}
});
await win.moveTo(rect.left, rect.top);