Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
zhangbo1_wd
2024-04-17 18:33:40 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d0debc187e67cb2e49a4b21d1ad8a2518c21d75e
d0debc18
1 parent
45216d57
解决图文详情web页面,偶现crash问题【Init error, The Webviewcontroller must be associated with a Web component】
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
7 deletions
sight_harmony/commons/wdWebComponent/src/main/ets/pages/WdWebLocalComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/ImageAndTextWebComponent.ets
sight_harmony/commons/wdWebComponent/src/main/ets/pages/WdWebLocalComponent.ets
View file @
d0debc1
...
...
@@ -12,6 +12,8 @@ const TAG = 'WdWebLocalComponent';
@Component
export struct WdWebLocalComponent {
webviewControl: BridgeWebViewControl = new BridgeWebViewControl()
onWebPrepared: () => void = () => {
}
@Prop backVisibility: boolean = false
@Prop webResource: Resource = {} as Resource
@State webHeight: string | number = '100%'
...
...
@@ -106,6 +108,7 @@ export struct WdWebLocalComponent {
}
onPageEnd: (url?: string) => void = () => {
Logger.debug(TAG, 'onPageEnd');
this.onWebPrepared()
}
onLoadIntercept: (url?: string) => boolean = () => {
Logger.debug(TAG, 'onLoadIntercept return false');
...
...
sight_harmony/features/wdComponent/src/main/ets/components/ImageAndTextWebComponent.ets
View file @
d0debc1
...
...
@@ -17,6 +17,9 @@ export struct ImageAndTextWebComponent {
@State reload: number = 0;
@Prop @Watch('onDetailDataUpdated') contentDetailData: ContentDetailDTO [] = [] as ContentDetailDTO []
webviewControl: BridgeWebViewControl = new BridgeWebViewControl()
private h5ReceiveAppData: H5ReceiveDetailBean = { dataSource: '2' } as H5ReceiveDetailBean
private webPrepared = false;
private dataPrepared = false;
onDetailDataUpdated() {
if (this.action) {
...
...
@@ -50,7 +53,6 @@ export struct ImageAndTextWebComponent {
}
let h5ReceiveAppData: H5ReceiveDetailBean = { dataSource: '2' } as H5ReceiveDetailBean
// TODO 对接user信息、登录情况
let h5ReceiveDataExtraBean: H5ReceiveDataExtraBean = { creatorId: '', isLogin: '0' } as H5ReceiveDataExtraBean
let h5ReceiveDataJsonBean: H5ReceiveDataJsonBean = {
...
...
@@ -67,12 +69,10 @@ export struct ImageAndTextWebComponent {
response.code = 200
response.success = true
h5ReceiveDataJsonBean.responseMap = response
h5ReceiveAppData.dataJson = h5ReceiveDataJsonBean
h5ReceiveAppData.dataExt = h5ReceiveDataExtraBean
// TODO 暂延时1s,考虑业务流程再优化
setTimeout(() => {
this.sendContentData2H5(h5ReceiveAppData);
}, 2000)
this.h5ReceiveAppData.dataJson = h5ReceiveDataJsonBean
this.h5ReceiveAppData.dataExt = h5ReceiveDataExtraBean
this.dataPrepared = true
this.trySendData2H5()
}
...
...
@@ -84,10 +84,24 @@ export struct ImageAndTextWebComponent {
webviewControl: this.webviewControl,
webResource: $rawfile('apph5/index.html'),
backVisibility: false,
onWebPrepared: this.onWebPrepared.bind(this)
})
}
}
private trySendData2H5() {
if (!this.webPrepared || !this.dataPrepared) {
return
}
// 数据、web组件,都准备好了,开始塞详情数据
this.sendContentData2H5(this.h5ReceiveAppData)
}
private onWebPrepared() {
this.webPrepared = true
this.trySendData2H5()
}
private sendContentData2H5(h5ReceiveAppData: H5ReceiveDetailBean) {
Logger.debug('ImageAndTextWebComponent', 'jsCall_receiveAppData');
this.webviewControl.callHandle(NativeCallH5Type.jsCall_receiveAppData,
...
...
Please
register
or
login
to post a comment