chenquansheng

fix |> 添加返回到稿件详情页刷新页面逻辑

... ... @@ -49,5 +49,10 @@ export enum EmitterEventId {
// 全屏
FULL_SCREEN = 14,
// app页面显示
APP_PAGE_SHOW = 102,
// app页面隐藏
APP_PAGE_HIDDEN = 103,
}
... ...
export interface eventParams {
event: string;
}
export const enum NativeCallH5Event {
NativeCallH5EventPageWillAppear = '1',
NativeCallH5EventPageWillDisAppear = '2',
NativeCallH5EventAppWillEnterForeground = '3',
NativeCallH5EventAppEnterBackground = '4',
NativeCallH5EventAppPlayingAudio = '5',
NativeCallH5EventUpdateBrowseCount = '6',
NativeCallH5EventStartLoadingOnReuse = '7',
NativeCallH5EventNightModel = '9',
NativeCallH5EventFontSizesChange = '10',
NativeCallH5EventFollowEvent = '11',
NativeCallH5EventLikeEvent = '12'
}
/**
* native调用h5,事件id枚举
* app主动调用h5方法
*/
export const enum NativeCallH5Type {
jsCall_receiveAppData = 'jsCall_receiveAppData',
jsCall_appNotifyEvent = 'jsCall_appNotifyEvent',
// TODO 业务自行新增类型,自行调用,例:
// TODO this.webviewControl.callHandle(NativeCallH5Type.jsCall_receiveAppData,xxxx)
... ...
... ... @@ -4,8 +4,9 @@ import { Logger, WindowModel } from 'wdKit/Index';
import { performJSCallNative } from './JsBridgeBiz';
import { H5CallNativeType } from './H5CallNativeType';
import { Message } from 'wdJsBridge/src/main/ets/bean/Message';
import { DateTimeUtils } from 'wdKit'
import { DateTimeUtils,EmitterUtils,EmitterEventId } from 'wdKit'
import { window } from '@kit.ArkUI';
import { NativeCallH5Type,NativeCallH5Event,eventParams } from './NativeCallH5Type';
const TAG = 'WdWebLocalComponent';
... ... @@ -183,6 +184,7 @@ export struct WdWebLocalComponent {
private defaultPerformJSCallNative: (data: Message, f: Callback) => void = (data: Message, f: Callback) => {
performJSCallNative(data, f)
}
onPageBegin: (url?: string) => void = () => {
Logger.debug(TAG, 'onPageBegin');
this.registerHandlers();
... ... @@ -228,6 +230,17 @@ export struct WdWebLocalComponent {
}
}
aboutToAppear(): void {
EmitterUtils.receiveEvent(EmitterEventId.APP_PAGE_SHOW, () => {
Logger.info(TAG, 'APP_PAGE_SHOW');
let params = {'event':NativeCallH5Event.NativeCallH5EventPageWillAppear} as eventParams;
let jsonString = JSON.stringify(params);
this.webviewControl.callHandle(NativeCallH5Type.jsCall_appNotifyEvent, jsonString, (data: string) => {
Logger.debug(TAG, "from js data = " + data);
})
})
}
@Builder
videoComp(){
Video({
... ...
import { Action } from 'wdBean';
import { ImageAndTextPageComponent } from 'wdComponent'
import { Logger } from 'wdKit'
import { Logger,EmitterUtils,EmitterEventId } from 'wdKit'
import router from '@ohos.router';
import { TrackConstants } from 'wdTracking/Index';
... ... @@ -47,6 +47,7 @@ struct ImageAndTextDetailPage {
onPageShow() {
this.pageShow = Math.random()
EmitterUtils.sendEmptyEvent(EmitterEventId.APP_PAGE_SHOW)
Logger.info(TAG, 'onPageShow');
}
... ...