From 3bea511eb7b99f1107898cc84dfea805236faddd Mon Sep 17 00:00:00 2001 From: hzt Date: Mon, 9 Jun 2025 17:15:24 +0800 Subject: [PATCH] =?UTF-8?q?feat=20:=20=E4=BF=AE=E6=94=B9=20NetworkReconnec?= =?UTF-8?q?tion=20=E4=BB=93=E5=BA=93=E5=BA=9F=E5=BC=83api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entry/src/main/ets/pages/HTTPReconnection.ets | 2 +- .../entry/src/main/ets/pages/RCPReconnection.ets | 2 +- .../entry/src/main/ets/pages/SocketReconnection.ets | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/NetworkReconnection/entry/src/main/ets/pages/HTTPReconnection.ets b/NetworkReconnection/entry/src/main/ets/pages/HTTPReconnection.ets index 79a8d8e..7dfcd94 100644 --- a/NetworkReconnection/entry/src/main/ets/pages/HTTPReconnection.ets +++ b/NetworkReconnection/entry/src/main/ets/pages/HTTPReconnection.ets @@ -27,7 +27,7 @@ export struct HTTPReconnection { @State process: number = 0; @State isDownload: boolean = false; private httpRequest: http.HttpRequest = http.createHttp(); - private context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + private context: common.UIAbilityContext = this.getUIContext().getHostContext() as common.UIAbilityContext; aboutToDisappear(): void { this.httpRequest.destroy(); diff --git a/NetworkReconnection/entry/src/main/ets/pages/RCPReconnection.ets b/NetworkReconnection/entry/src/main/ets/pages/RCPReconnection.ets index cfa194f..d53c9c7 100644 --- a/NetworkReconnection/entry/src/main/ets/pages/RCPReconnection.ets +++ b/NetworkReconnection/entry/src/main/ets/pages/RCPReconnection.ets @@ -28,7 +28,7 @@ export struct RCPReconnection { @State process: number = 0; @State isDownload: boolean = false; private session = this.createRCPSession(); - private context = getContext(this) as common.UIAbilityContext; + private context = this.getUIContext().getHostContext() as common.UIAbilityContext; aboutToDisappear(): void { this.session.close(); diff --git a/NetworkReconnection/entry/src/main/ets/pages/SocketReconnection.ets b/NetworkReconnection/entry/src/main/ets/pages/SocketReconnection.ets index 566dd7c..330d93e 100644 --- a/NetworkReconnection/entry/src/main/ets/pages/SocketReconnection.ets +++ b/NetworkReconnection/entry/src/main/ets/pages/SocketReconnection.ets @@ -33,7 +33,7 @@ export struct SocketReconnection { // [Start storage_on_foreground] @StorageProp('onForeground') @Watch('onForegroundChange') onForeground: boolean = true; // [StartExclude storage_on_foreground] - private context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + private context: common.UIAbilityContext = this.getUIContext().getHostContext() as common.UIAbilityContext; private tcp?: socket.TCPSocket; private receivedDataBuf: buffer.Buffer = buffer.alloc(15 * 1024 * 1024); private receivedDataLen: number = 0; -- Gitee