Skip to content
This repository was archived by the owner on Nov 27, 2025. It is now read-only.

Commit 838ff57

Browse files
authored
fix: 修复预创建web内容留存问题 (#87)
1 parent 48d6e37 commit 838ff57

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

harmony/rn_webview/src/main/ets/Common.ets

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,15 @@ export class myNodeController extends NodeController {
105105
aboutToAppear() {
106106
this.isMounted = true
107107
this.getController()?.onActive()
108-
Logger.debug("ljc aboutToAppear")
108+
Logger.debug(" aboutToAppear")
109109
}
110110

111111
// 当controller对应的NodeContainer在Disappear的时候进行回调
112112
aboutToDisappear() {
113-
this.isMounted = false
114-
this.getController()?.onInactive()
115-
Logger.debug("ljc aboutToDisappear")
113+
this.release()
114+
// this.isMounted = false
115+
// this.getController()?.onInactive()
116+
Logger.debug(" aboutToDisappear")
116117
}
117118

118119
setMount(isMounted: boolean) {
@@ -127,7 +128,9 @@ export class myNodeController extends NodeController {
127128
return controllerMap.get(this.id);
128129
}
129130

130-
release(): void {
131+
private release(): void {
132+
this.getController()?.loadData('','text/html', 'UTF-8')
133+
this.getController()?.clearHistory()
131134
this.isMounted = false
132135
this.getController()?.onInactive()
133136
}

harmony/rn_webview/src/main/ets/WebView.ets

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,9 @@ export struct WebView {
367367
} catch (error) {
368368
Logger.error(TAG, `[RNOH]Errorcode: ${error.code}, Message: ${error.message}`);
369369
}
370-
if (this.webNodeId) {
371-
getNWeb(this.webNodeId)?.release()
372-
}
370+
// if (this.webNodeId) {
371+
// getNWeb(this.webNodeId)?.release()
372+
// }
373373
}
374374

375375
transCacheMode(cacheMode: number): CacheMode {

0 commit comments

Comments
 (0)