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
yuzhilin
2024-04-19 17:39:13 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
702bf033964cb09e284c3b91222e71adcf379e3e
702bf033
1 parent
3d09ab88
屏蔽活动、音频
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
54 additions
and
28 deletions
sight_harmony/commons/wdWebComponent/src/main/ets/pages/JsBridgeBiz.ets
sight_harmony/commons/wdWebComponent/src/main/ets/pages/WdWebComponent.ets
sight_harmony/commons/wdWebComponent/src/main/ets/pages/WdWebLocalComponent.ets
sight_harmony/features/wdBean/src/main/ets/bean/component/CompDTO.ets
sight_harmony/features/wdComponent/src/main/ets/components/CompParser.ets
sight_harmony/features/wdComponent/src/main/ets/components/SpacialTopicPageComponent.ets
sight_harmony/features/wdComponent/src/main/ets/utils/ProcessUtils.ets
sight_harmony/products/phone/src/main/ets/pages/web/DefaultWebPage.ets
sight_harmony/commons/wdWebComponent/src/main/ets/pages/JsBridgeBiz.ets
View file @
702bf03
import { Callback
, BridgeWebViewControl
} from 'wdJsBridge';
import { Callback } from 'wdJsBridge';
import { Message } from 'wdJsBridge/src/main/ets/bean/Message';
import { Logger
, StringUtils,
} from 'wdKit';
import { Logger } from 'wdKit';
import { H5CallNativeType } from './H5CallNativeType';
import { ContentDTO } from 'wdBean';
//TODO 这里引用了 features模块,是否考虑将跳转抽到公共模块
...
...
@@ -27,7 +27,10 @@ export function performJSCallNative(data: Message, call: Callback) {
case H5CallNativeType.jsCall_callAppService:
break;
case H5CallNativeType.jsCall_receiveH5Data:
if(data?.data?.dataSource === 5){
handleH5Data(JSON.parse(data?.data?.dataJson || '{}'))
}
break;
case 'changeNativeMessage':
call("this is change Web Message")
...
...
@@ -59,6 +62,7 @@ function getAppPublicInfo(): string {
}
function handleH5Data(content:ContentDTO) {
Logger.debug(TAG, 'handleH5Data' + ', content: ' + JSON.stringify(content))
ProcessUtils.processPage(content)
}
...
...
sight_harmony/commons/wdWebComponent/src/main/ets/pages/WdWebComponent.ets
View file @
702bf03
import router from '@ohos.router';
import { BridgeUtil, BridgeWebViewControl, Callback } from 'wdJsBridge';
import { Bridge
Handler, Bridge
Util, BridgeWebViewControl, Callback } from 'wdJsBridge';
import { Logger } from 'wdKit/Index';
import { setDefaultNativeWebSettings } from './WebComponentUtil';
import { Action } from 'wdBean';
import { performJSCallNative } from './JsBridgeBiz';
import { H5CallNativeType } from './H5CallNativeType';
import { Message } from 'wdJsBridge/src/main/ets/bean/Message';
...
...
@@ -10,9 +12,9 @@ const TAG = 'WdWebLocalComponent';
@Component
export struct WdWebComponent {
webviewControl: BridgeWebViewControl = new BridgeWebViewControl()
onWebPrepared: () => void = () => {}
@Prop backVisibility: boolean = false
@Prop webUrl: string = ''
@Prop @Watch('onReloadStateChanged') reload: number = 0
@Link isPageEnd: boolean
build() {
...
...
@@ -34,9 +36,10 @@ export struct WdWebComponent {
.domStorageAccess(true)
.databaseAccess(true)
.javaScriptAccess(true)
.zoomAccess(false)
.horizontalScrollBarAccess(false)
.verticalScrollBarAccess(false)
.imageAccess(true)
.mixedMode(MixedMode.All)
.onlineImageAccess(true)
.enableNativeEmbedMode(true)
.onPageBegin((event) => {
this.onPageBegin(event?.url);
})
...
...
@@ -66,14 +69,13 @@ export struct WdWebComponent {
// 注册h5调用js相关
for (let i = 0; i < H5CallNativeType.JsCallTypeList.length; i++) {
let handleName = H5CallNativeType.JsCallTypeList[i];
console.log('handleName:', handleName)
let handle = (data: Message, f: Callback) => {
Logger.debug('registerHandlers handlerName: ' + JSON.stringify(data))
this.defaultPerformJSCallNative(data, f)
};
this.webviewControl.registerHandler(handleName, { handle: handle });
}
}
/**
* 默认【CallNative】逻辑处理
*/
...
...
@@ -83,22 +85,18 @@ export struct WdWebComponent {
onPageBegin: (url?: string) => void = () => {
Logger.debug(TAG, 'onPageBegin');
this.registerHandlers();
// setTimeout(() => {
BridgeUtil.webViewLoadLocalJs(getContext(this), this.webviewControl)
// }, 100)
}
onPageEnd: (url?: string) => void = () => {
this.isPageEnd = true
Logger.debug(TAG, 'onPageEnd');
this.onWebPrepared()
this.isPageEnd = true
}
onLoadIntercept: (url?: string) => boolean = () => {
Logger.debug(TAG, 'onLoadIntercept return false');
return false
}
onReloadStateChanged() {
Logger.info(TAG, `onReloadStateChanged:::refresh, this.reload: ${this.reload}`);
if (this.reload > 0) {
this.webviewControl.refresh()
}
}
}
...
...
sight_harmony/commons/wdWebComponent/src/main/ets/pages/WdWebLocalComponent.ets
View file @
702bf03
...
...
@@ -12,8 +12,7 @@ const TAG = 'WdWebLocalComponent';
@Component
export struct WdWebLocalComponent {
webviewControl: BridgeWebViewControl = new BridgeWebViewControl()
onWebPrepared: () => void = () => {
}
onWebPrepared: () => void = () => {}
@Prop backVisibility: boolean = false
@Prop webResource: Resource = {} as Resource
@State webHeight: string | number = '100%'
...
...
@@ -73,6 +72,7 @@ export struct WdWebLocalComponent {
for (let i = 0; i < H5CallNativeType.JsCallTypeList.length; i++) {
let handleName = H5CallNativeType.JsCallTypeList[i];
let handle = (data: Message, f: Callback) => {
Logger.debug('registerHandlers handlerName: ' + JSON.stringify(data.data))
this.setCurrentPageOperate(data)
this.defaultPerformJSCallNative(data, f)
};
...
...
sight_harmony/features/wdBean/src/main/ets/bean/component/CompDTO.ets
View file @
702bf03
...
...
@@ -19,7 +19,7 @@ export interface CompDTO {
name: string;
objectId: string; // 跳转页面id?
objectTitle: string; // comp标题
objectType?: string; // 跳转类型,枚举:
//
objectType?: string; // 跳转类型,枚举:
operDataList: ContentDTO[]; // 运营数据列表【正常运营配置的强运营数据,部分推荐场景的配置(自动源兜底数据)】
// pageId?: any;
posterSize: string;
...
...
sight_harmony/features/wdComponent/src/main/ets/components/CompParser.ets
View file @
702bf03
...
...
@@ -38,7 +38,7 @@ export struct CompParser {
@Builder
componentBuilder(compDTO: CompDTO, compIndex: number) {
if (compDTO.o
bjectType !== '3' && compDTO
.objectType !== '13') { //暂时屏蔽活动和音频详情入口
if (compDTO.o
perDataList[0]?.objectType !== '3' && compDTO.operDataList[0]?
.objectType !== '13') { //暂时屏蔽活动和音频详情入口
if (compDTO.compStyle === CompStyle.Label_03) {
LabelComponent({ compDTO: compDTO })
} else if (compDTO.compStyle === CompStyle.Zh_Carousel_Layout_01) {
...
...
sight_harmony/features/wdComponent/src/main/ets/components/SpacialTopicPageComponent.ets
View file @
702bf03
import { Action, ContentDetailDTO, } from 'wdBean';
import DetailViewModel from '../viewmodel/DetailViewModel';
import { Action, H5ReceiveDetailBean } from 'wdBean';
import { WdWebComponent } from 'wdWebComponent';
import router from '@ohos.router';
import { CommonConstants } from 'wdConstant'
import { BridgeWebViewControl } from 'wdJsBridge/Index';
import { detailedSkeleton } from './skeleton/detailSkeleton'
import { NativeCallH5Type } from 'wdWebComponent/src/main/ets/pages/NativeCallH5Type';
const TAG = 'SpacialTopicPageComponent'
@Component
...
...
@@ -15,6 +14,28 @@ export struct SpacialTopicPageComponent {
action: Action = {} as Action
@State webUrl: string = '';
@State isPageEnd: boolean = false
private h5ReceiveAppData: H5ReceiveDetailBean = { dataSource: '2' } as H5ReceiveDetailBean
private webPrepared = false;
private dataPrepared = false;
private trySendData2H5() {
if (!this.webPrepared || !this.dataPrepared) {
return
}
// 数据、web组件,都准备好了,开始塞详情数据
this.sendContentData2H5(this.h5ReceiveAppData)
}
private onWebPrepared() {
this.webPrepared = true
this.trySendData2H5()
}
private sendContentData2H5(h5ReceiveAppData: H5ReceiveDetailBean) {
this.webviewControl.callHandle(NativeCallH5Type.jsCall_receiveAppData,
JSON.stringify(h5ReceiveAppData), (data: string) => {
})
}
build() {
Column() {
...
...
@@ -27,7 +48,8 @@ export struct SpacialTopicPageComponent {
webviewControl: this.webviewControl,
webUrl: this.webUrl,
backVisibility: false,
isPageEnd:$isPageEnd
onWebPrepared: this.onWebPrepared.bind(this),
isPageEnd: $isPageEnd
})
}
.padding({ bottom: 56 })
...
...
@@ -72,7 +94,6 @@ export struct SpacialTopicPageComponent {
.justifyContent(FlexAlign.SpaceBetween)
.backgroundColor(Color.White)
}
}.width(CommonConstants.FULL_WIDTH).height(CommonConstants.FULL_HEIGHT)
.backgroundColor(Color.White)
...
...
@@ -83,8 +104,10 @@ export struct SpacialTopicPageComponent {
if (action) {
this.webUrl = action.params?.url || ''
}
this.trySendData2H5()
}
aboutToDisappear() {
}
}
\ No newline at end of file
...
...
sight_harmony/features/wdComponent/src/main/ets/utils/ProcessUtils.ets
View file @
702bf03
...
...
@@ -25,6 +25,7 @@ export class ProcessUtils {
return;
}
let type = content.objectType;
console.log(TAG,'objectType',`${JSON.stringify(content)}`);
switch (type) {
case ContentConstants.TYPE_NONE:
Logger.debug(TAG, "processPage, do nothing");
...
...
@@ -59,7 +60,7 @@ export class ProcessUtils {
break;
//动态详情页(动态视频)
case ContentConstants.TYPE_FIFTEEN:
ProcessUtils.goto
DynamicDetailPage
(content);
ProcessUtils.goto
Web
(content);
break;
default:
break;
...
...
sight_harmony/products/phone/src/main/ets/pages/web/DefaultWebPage.ets
View file @
702bf03
...
...
@@ -32,7 +32,7 @@ struct DefaultWebPage {
WdWebComponent({
webUrl: this.url,
backVisibility: false,
reload: this.reload,
//
reload: this.reload,
isPageEnd:$isPageEnd
})
}
...
...
Please
register
or
login
to post a comment