Skip to content
This repository was archived by the owner on Nov 27, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions harmony/rn_webview/src/main/ets/RNCWebView.ets
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ export struct RNCWebView {

aboutToAppear() {
try {
this.eventEmitter = new RNC.RNCWebView.EventEmitter(this.ctx.rnInstance, this.tag)
this.initVariable()
this.url = this.source.uri as string;
webview.WebviewController.setWebDebuggingAccess(this.descriptorWrapper.props.webviewDebuggingEnabled)
Expand All @@ -109,7 +108,6 @@ export struct RNCWebView {
}
})
}
this.webViewBaseOperate = BaseOperate.getInstance(this.eventEmitter, this.controller)
} catch (error) {
Logger.error(TAG, `[RNOH]Errorcode: ${error.code}, Message: ${error.message}`);
}
Expand Down Expand Up @@ -360,6 +358,13 @@ export struct RNCWebView {
this.webViewBaseOperate?.ignoreSilentHardwareSwitchMethods(ignoreSilentHardwareSwitch)
}

controllerAttachedInit(): void {
this.controllerAttached = true;
this.eventEmitter = new RNC.RNCWebView.EventEmitter(this.ctx.rnInstance, this.tag)
this.webViewBaseOperate = BaseOperate.getInstance(this.eventEmitter, this.controller)
this.ignoreSilentHardwareSwitchMethods(this.descriptorWrapper.props.ignoreSilentHardwareSwitch)
}

build() {
Stack() {
Web({ src: "", controller: this.controller, renderMode: this.renderMode })
Expand Down Expand Up @@ -433,8 +438,7 @@ export struct RNCWebView {
}
})
.onControllerAttached(() => {
this.ignoreSilentHardwareSwitchMethods(this.descriptorWrapper.props.ignoreSilentHardwareSwitch)
this.controllerAttached = true;
this.controllerAttachedInit()
Logger.debug(TAG, "[RNOH] onControllerAttached")
let baseUrl = this.source.baseUrl
let uri = this.source.uri
Expand All @@ -458,7 +462,6 @@ export struct RNCWebView {
if (!this.hasRegisterJavaScriptProxy) {
this.registerPostMessage()
}
this.ignoreSilentHardwareSwitchMethods(this.descriptorWrapper.props.ignoreSilentHardwareSwitch)
})
.onAlert((event) => this.onJavascriptAlert(event))
.onConfirm((event) => this.onJavascriptConfirm(event))
Expand Down
2 changes: 0 additions & 2 deletions harmony/rn_webview/src/main/ets/WebViewBaseOperate.ets
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,6 @@ export class BaseOperate {
}

ignoreSilentHardwareSwitchMethods(ignoreSilentHardwareSwitch: boolean) {
Logger.info(TAG,
`ignoreSilentHardwareSwitchignoreSilentHardwareSwitchignoreSilentHardwareSwitch==${JSON.stringify(!ignoreSilentHardwareSwitch)}`)
this.controller.setAudioMuted(!ignoreSilentHardwareSwitch)
}
}