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
陈剑华
2024-04-19 17:54:05 +0800
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
c363d612aefde0aea6bcd57dd96fd11978714eaa
c363d612
2 parents
81fd2b3a
b357d228
Merge remote-tracking branch 'origin/main'
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
70 additions
and
41 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/SpacialTopicPageComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/compview/ZhGridLayout02.ets
sight_harmony/features/wdComponent/src/main/ets/components/peopleShipHomePage/PeopleShipHomeArticleListComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/reusable/CustomPullToRefresh.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 @
c363d61
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 @
c363d61
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 @
c363d61
...
...
@@ -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 @
c363d61
...
...
@@ -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/SpacialTopicPageComponent.ets
View file @
c363d61
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/components/compview/ZhGridLayout02.ets
View file @
c363d61
import { CompDTO, ContentDTO } from 'wdBean';
import { CommonConstants } from 'wdConstant/Index';
import {
CollectionUtils, DateTimeUtils, Logger, StringUtils, ToastUtils
} from 'wdKit/Index';
import {
Logger
} from 'wdKit/Index';
import PageViewModel from '../../viewmodel/PageViewModel';
const TAG = 'Zh_Grid_Layout-02';
...
...
@@ -31,8 +31,6 @@ export struct ZhGridLayout02 {
build() {
Column() {
Scroll() {
Column() {
Row() {
...
...
@@ -46,10 +44,12 @@ export struct ZhGridLayout02 {
.fontWeight(600)
}
.justifyContent(FlexAlign.Start)
.margin({ top: 8, bottom: 8 })
.width(CommonConstants.FULL_WIDTH)
GridRow({
gutter: { x: 12, y: 22 },
columns: { sm: listSize, md: 2 },
breakpoints: { value: ['320vp', '520vp', '840vp'] }
}) {
...
...
@@ -60,7 +60,6 @@ export struct ZhGridLayout02 {
})
}
}
}
.width("100%")
.height("100%")
...
...
@@ -82,12 +81,9 @@ export struct ZhGridLayout02 {
.width(CommonConstants.FULL_WIDTH)
// .width("100%")
.height("100%")
.padding({ left: 16, right: 16 })
// .layoutWeight(1)
.padding({
top: 14,
left: 16,
right: 16
})
}
...
...
@@ -100,9 +96,9 @@ export struct ZhGridLayout02 {
buildItemCard(item: ContentDTO) {
Column() {
Image(item.fullColumnImgUrls[0].url)
.width(
170
)
.width(
'100%'
)
.height(95)
.
margin(16
)
.
borderRadius(4
)
Text(item.newsTitle)
.fontSize(13)
.maxLines(2)
...
...
sight_harmony/features/wdComponent/src/main/ets/components/peopleShipHomePage/PeopleShipHomeArticleListComponent.ets
View file @
c363d61
...
...
@@ -68,6 +68,7 @@ export struct PeopleShipHomeArticleListComponent {
}
if(!this.isLoading && this.hasMore){
//加载分页数据
this.currentPage++;
this.getPeopleShipPageArticleList(resolve)
}else {
if(resolve) {
...
...
@@ -132,7 +133,7 @@ export struct PeopleShipHomeArticleListComponent {
}
onChange() {
if (this.currentIndex == this.currentTopSelectedIndex) {
if (this.currentIndex == this.currentTopSelectedIndex
&& this.arr.length == 0
) {
this.currentPage = 1
this.getPeopleShipPageArticleList()
}
...
...
@@ -163,7 +164,6 @@ export struct PeopleShipHomeArticleListComponent {
if (listData && listData.list && listData.list.length > 0) {
this.viewType = 3;
if (listData.list.length === 20) {
this.currentPage++;
this.hasMore = true;
} else {
this.hasMore = false;
...
...
@@ -211,6 +211,9 @@ export struct PeopleShipHomeArticleListComponent {
private articleListDTOChangeContentDTO(listData: ArticleListData, listCom: InteractDataDTO[]) {
this.isLoading = false
if (listData.list.length) {
if (this.currentPage == 1) {
this.arr = []
}
for (const element of listData.list) {
let contentDTO = {} as ContentDTO
contentDTO.appStyle = this.changeCommon(element.appStyle)
...
...
sight_harmony/features/wdComponent/src/main/ets/components/reusable/CustomPullToRefresh.ets
View file @
c363d61
...
...
@@ -10,7 +10,7 @@ export struct CustomPullToRefresh {
onLoadMore: (resolve?: (value: string | PromiseLike<string>) => void) => void = () => {
}
///是否存在上拉更多
@Prop hasMore: boolean = true
@Prop
@Watch('hasMoreChange')
hasMore: boolean = true
refreshConfigurator: PullToRefreshConfigurator = new PullToRefreshConfigurator().setHasLoadMore(this.hasMore);
build() {
Column(){
...
...
@@ -36,4 +36,8 @@ export struct CustomPullToRefresh {
})
}
}
hasMoreChange() {
this.refreshConfigurator.setHasLoadMore(this.hasMore)
}
}
\ No newline at end of file
...
...
sight_harmony/features/wdComponent/src/main/ets/utils/ProcessUtils.ets
View file @
c363d61
...
...
@@ -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 @
c363d61
...
...
@@ -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