From d7ffd228b7410c3b260c42446a1bfcb8b75319b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E5=8B=A4=E6=B0=91?= Date: Mon, 27 Oct 2025 17:15:26 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix(webview):=E4=BF=AE=E5=A4=8D=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E5=85=B3=E9=97=AD=E6=97=B6=E6=9C=AA=E6=AD=A3=E7=A1=AE?= =?UTF-8?q?=E7=A7=BB=E9=99=A4=E6=B6=88=E6=81=AF=E7=9B=91=E5=90=AC=E5=99=A8?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在页面关闭时移除对 HTML 的消息监听器 - 确保 UUID 相关的监听器被正确清理 - 防止因未清理监听器导致的内存泄漏问题 --- src/main/ets/pages/XWebview.ets | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/ets/pages/XWebview.ets b/src/main/ets/pages/XWebview.ets index 1b2a010..95707a5 100644 --- a/src/main/ets/pages/XWebview.ets +++ b/src/main/ets/pages/XWebview.ets @@ -64,6 +64,7 @@ export struct XWebview { if (this.closeTag !== undefined) { SZYXLocalStorageHelper.storage.setOrCreate(SZYXLocalStorageKeys.XWebViewCLose, this.closeTag) } + XWebManager.removeOnMessageToWeb(this._uuidToHtml) XWebManager.removeOnMessage(this._uuid) XWebManager.removeOnMessageToHtml(this._uuidToHtml) if (this._uuidToHtml) { From bf6d4287c05debae40a6040815bbe610c2266d3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E5=8B=A4=E6=B0=91?= Date: Mon, 27 Oct 2025 17:23:11 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix(webview):=20=E6=9B=B4=E6=96=B0=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E6=A8=A1=E5=BC=8F=E4=B8=BA=E5=9C=A8=E7=BA=BF=E7=BC=93?= =?UTF-8?q?=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将缓存模式从 None 更改为 Online - 确保网页内容可以正常缓存和加载- 提升页面加载性能和用户体验 --- src/main/ets/pages/XWebview.ets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/ets/pages/XWebview.ets b/src/main/ets/pages/XWebview.ets index 95707a5..2397d00 100644 --- a/src/main/ets/pages/XWebview.ets +++ b/src/main/ets/pages/XWebview.ets @@ -156,7 +156,7 @@ export struct XWebview { .mixedMode(MixedMode.All)//允许加载HTTP和HTTPS混合内容 .zoomAccess(this.zoomAccess ?? false)//不支持手势进行缩放 .mediaPlayGestureAccess(false)//有声视频播放不需要用户手动点击 - .cacheMode(CacheMode.None)//设置缓存模式 + .cacheMode(CacheMode.Online)//设置缓存模式 .onConfirm((event) => { // 自定义Confirm弹窗 if (event) { console.log("event.url:" + event.url)