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-24 17:24:51 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
3ec9e42cda6c347be9d516d1357a3558fa08064c
3ec9e42c
1 parent
cfa20dd6
H5 调用 app 内链接入
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
243 additions
and
113 deletions
sight_harmony/commons/wdJsBridge/src/main/ets/bean/Message.ets
sight_harmony/commons/wdRouter/src/main/ets/utils/ProcessUtils.ets
sight_harmony/commons/wdWebComponent/src/main/ets/pages/H5OperateType.ets
sight_harmony/commons/wdWebComponent/src/main/ets/pages/JsBridgeBiz.ets
sight_harmony/features/wdComponent/src/main/ets/components/ImageAndTextPageComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/page/TopNavigationComponent.ets
sight_harmony/products/phone/oh-package.json5
sight_harmony/products/phone/src/main/ets/pages/web/DefaultWebPage.ets
sight_harmony/commons/wdJsBridge/src/main/ets/bean/Message.ets
View file @
3ec9e42
...
...
@@ -16,6 +16,7 @@ interface dataObject {
operateType?: string
webViewHeight?: string
dataJson?: string
appInnerLink?: string
}
/**
* 消息Message
...
...
sight_harmony/commons/wdRouter/src/main/ets/utils/ProcessUtils.ets
View file @
3ec9e42
...
...
@@ -138,7 +138,7 @@ export class ProcessUtils {
* 动态详情页(动态视频/动态图片)
* @param content
* */
p
rivate
static gotoDynamicDetailPage(content: ContentDTO) {
p
ublic
static gotoDynamicDetailPage(content: ContentDTO) {
let taskAction: Action = {
type: 'JUMP_DETAIL_PAGE',
params: {
...
...
@@ -172,7 +172,7 @@ export class ProcessUtils {
Logger.debug(TAG, `gotoMultiPictureListPage`);
}
p
rivate
static gotoSpecialTopic(content: ContentDTO) {
p
ublic
static gotoSpecialTopic(content: ContentDTO) {
let taskAction: Action = {
type: 'JUMP_INNER_NEW_PAGE',
params: {
...
...
@@ -183,7 +183,7 @@ export class ProcessUtils {
WDRouterRule.jumpWithAction(taskAction)
}
p
rivate
static gotoDefaultWeb(content: ContentDTO) {
p
ublic
static gotoDefaultWeb(content: ContentDTO) {
let taskAction: Action = {
type: 'JUMP_H5_BY_WEB_VIEW',
params: {
...
...
@@ -212,7 +212,7 @@ export class ProcessUtils {
Logger.debug(TAG, `commentGotoWeb, ${content.newsId}`);
}
p
rivate
static gotoWeb(content: ContentDTO) {
p
ublic
static gotoWeb(content: ContentDTO) {
let taskAction: Action = {
type: 'JUMP_INNER_NEW_PAGE',
params: {
...
...
@@ -231,7 +231,7 @@ export class ProcessUtils {
Logger.debug(TAG, `gotoWeb, ${content.objectId}`);
}
p
rivate
static gotoVod(content: ContentDTO) {
p
ublic
static gotoVod(content: ContentDTO) {
let taskAction: Action = {
type: 'JUMP_DETAIL_PAGE',
params: {
...
...
@@ -247,7 +247,7 @@ export class ProcessUtils {
Logger.debug(TAG, `gotoVod, ${content.objectId}`);
}
p
rivate
static async gotoLive(content: ContentDTO) {
p
ublic
static async gotoLive(content: ContentDTO) {
let taskAction: Action = {
type: 'JUMP_DETAIL_PAGE',
params: {
...
...
@@ -263,7 +263,7 @@ export class ProcessUtils {
Logger.debug(TAG, `gotoLive, ${content.objectId}`);
}
p
rivate
static gotoAudio(content: ContentDTO) {
p
ublic
static gotoAudio(content: ContentDTO) {
let taskAction: Action = {
type: 'JUMP_DETAIL_PAGE',
params: {
...
...
@@ -283,7 +283,7 @@ export class ProcessUtils {
* 金刚位聚合页
* @param content
* */
p
rivate
static gotoThemeListPage(content: ContentDTO) {
p
ublic
static gotoThemeListPage(content: ContentDTO) {
let taskAction: Action = {
type: 'JUMP_DETAIL_PAGE',
params: {
...
...
@@ -303,7 +303,7 @@ export class ProcessUtils {
* 图片预览页
* @param content
* */
p
rivate
static gotoAtlasDetailPage(content: ContentDTO) {
p
ublic
static gotoAtlasDetailPage(content: ContentDTO) {
let taskAction: Action = {
type: 'JUMP_DETAIL_PAGE',
params: {
...
...
@@ -351,5 +351,43 @@ export class ProcessUtils {
WDRouterRule.jumpWithAction(taskAction)
}
/**
* 打开早晚报
*/
public static gotoMorningEveningPaper() {
let taskAction: Action = {
type: 'JUMP_INNER_NEW_PAGE',
params: {
pageID: 'MorningEveningPaper'
} as Params,
};
WDRouterRule.jumpWithAction(taskAction)
}
/**
* 打开电子报
*/
public static gotoENewsPaper() {
let taskAction: Action = {
type: 'JUMP_INNER_NEW_PAGE',
params: {
pageID: 'E_NEWSPAPER'
} as Params,
};
WDRouterRule.jumpWithAction(taskAction)
}
/**
* 打开播报
*/
public static gotoBroadcastPage(pageId: number) {
let taskAction: Action = {
type: 'JUMP_INNER_NEW_PAGE',
params: {
pageID: 'BroadcastPage',
id: pageId
} as Params,
};
WDRouterRule.jumpWithAction(taskAction)
}
}
...
...
sight_harmony/commons/wdWebComponent/src/main/ets/pages/H5OperateType.ets
0 → 100644
View file @
3ec9e42
export class H5OperateType {
/* jsCall_currentPageOperate#operateType
1、关闭页面
2、页面reload,
3、返回上一级历史,
4、允许蜂窝网络播放视频
5、邮件订阅关闭事件
6、H5进入沉浸式播放 (android)
7、H5退出沉浸式播放(andriod)
8、WebView高度更新
9、App播放视频
10、H5开始播放音频 (处理音视频互斥问题)
12、关闭 App原生默认顶部导航,并通顶显示Webview (专题页使用)
13、显示 App原生默认顶部导航,支持返回按钮和标题显示(专题页使用,默认不用设置)
14、关闭 底部评论交互BAR (专题页使用,默认不用设置)
15、显示 底部评论交互BAR(专题页使用)
16、显示 顶导分享按钮(专题页使用,针对默认顶导情况)
17、关闭 顶导分享按钮(专题页使用,针对默认顶导情况)
18、设置页面标题 (专题页使用,针对默认顶导情况)
19、设置页面状态栏颜色(专题页使用,针对默认顶导情况)
20、设置页面底部蒙层效果显示(专题页使用,针对默认顶导情况)
21、设置页面底部蒙层效果 隐藏(专题页使用,针对默认顶导情况)
22、页面加载失败后重试操作
23、开启H5自己的返回操作(默认关闭,当开启后 App返回/物理按键返回 都需要调用H5的返回方法,参见:jsCall_appNotifyEvent)
24、号主关注操作 状态更新
30、关闭当前页面左滑事件
31、打开当前页面左滑事件
32、开始弹全局弹框事件(原生代码确保Webview底部到底)
33、结束全局弹框事件(原生代码确保Webview正常恢复)
40、抽奖 阅读、评论、点赞、关注等任务--跳首页 (默认)
41、抽奖 签到任务–-跳积分中心签到
42、抽奖 意见反馈–跳意见反馈页面
43、抽奖 关注号主任务–跳关注列表页
44、抽奖 创作者认证 页面,H5 直接跳人民号申请页?
45、打开APP直接使用goBack(安卓使用,使用场景:h5页面跳转新页面,但url没有变化,不能返回上一级页面)
46、关闭APP直接使用goBack(安卓使用)
*/
// 1、关闭页面
static readonly TYPE_ONE: string = "1";
}
\ No newline at end of file
...
...
sight_harmony/commons/wdWebComponent/src/main/ets/pages/JsBridgeBiz.ets
View file @
3ec9e42
...
...
@@ -2,11 +2,22 @@ import { Callback } from 'wdJsBridge';
import { Message } from 'wdJsBridge/src/main/ets/bean/Message';
import { Logger } from 'wdKit';
import { H5CallNativeType } from './H5CallNativeType';
import { ContentDTO } from 'wdBean';
import { ProcessUtils } from 'wdRouter/src/main/ets/utils/ProcessUtils';
import { H5OperateType } from './H5OperateType';
import { ContentConstants } from 'wdConstant';
import { ProcessUtils } from 'wdRouter';
import router from '@ohos.router';
import Url from '@ohos.url'
import { ContentDTO } from 'wdBean/Index';
const TAG = 'JsBridgeBiz'
class AppInfo {
plat: string = ''
system: string = ''
networkStatus: number = 1
// TODO 完善
}
/**
* h5调用native代码
* @param data
...
...
@@ -17,6 +28,7 @@ export function performJSCallNative(data: Message, call: Callback) {
switch (data.handlerName) {
case H5CallNativeType.jsCall_currentPageOperate:
handleJsCallCurrentPageOperate(data)
break;
case H5CallNativeType.jsCall_getAppPublicInfo:
// h5获取app配置信息
...
...
@@ -33,27 +45,25 @@ export function performJSCallNative(data: Message, call: Callback) {
case H5CallNativeType.jsCall_appInnerLinkMethod:
handleJsCallAppInnerLinkMethod(data)
break;
case 'changeNativeMessage':
call("this is change Web Message")
break;
default:
call("this is def value")
break;
}
}
class AppInfo {
plat: string = ''
system: string = ''
networkStatus: number = 1
// TODO 完善
function handleJsCallCurrentPageOperate(data: Message) {
switch (data?.data?.operateType) {
case H5OperateType.TYPE_ONE:
router.back()
break;
default:
break;
}
}
/**
* 获取App公共信息
*/
function getAppPublicInfo(): string {
let info = new AppInfo()
info.plat = 'Phone'
// 直接用Android,后续适配再新增鸿蒙
...
...
@@ -73,7 +83,6 @@ function handleJsCallReceiveH5Data(data: Message) {
}
break;
default:
break;
}
}
...
...
@@ -83,5 +92,61 @@ function handleJsCallCallAppService(data: Message) {
}
function handleJsCallAppInnerLinkMethod(data: Message) {
}
let urlObject = Url.URL.parseURL(data?.data?.appInnerLink);
let urlParams = new Url.URLParams(urlObject.search);
console.log('urlObject:', `${JSON.stringify(urlParams)}`)
let content: ContentDTO = {
objectId: urlParams.get('contentId') || '',
relId: urlParams.get('relId') || '',
relType: urlParams.get('relType') || '',
pageId:urlParams.get('pageId') || '',
objectType: ''
} as ContentDTO
if (urlParams.get('skipType') === '1') {
switch (urlParams.get('type')) {
case 'video':
content.objectType = ContentConstants.TYPE_VOD
ProcessUtils.processPage(content)
break;
case 'live':
content.objectType = ContentConstants.TYPE_LIVE
ProcessUtils.processPage(content)
break;
case 'article':
content.objectType = ContentConstants.TYPE_TELETEXT
ProcessUtils.processPage(content)
break;
case 'picture':
content.objectType = ContentConstants.TYPE_NINE
ProcessUtils.processPage(content)
break;
case 'audio':
content.objectType = ContentConstants.TYPE_AUDIO
ProcessUtils.processPage(content)
break;
case 'h5':
content.objectType = ContentConstants.TYPE_LINK
ProcessUtils.processPage(content)
break;
case 'topic':
if(urlParams.get('subType') === 'h5'){
content.objectType = ContentConstants.TYPE_SPECIAL_TOPIC
ProcessUtils.processPage(content)
}
if(urlParams.get('subType') === 'moring_evening_news'){
ProcessUtils.gotoMorningEveningPaper()
}
if(urlParams.get('subType') === 'electronic_newspapers'){
ProcessUtils.gotoENewsPaper()
}
break;
case 'dynamic':
content.objectType = ContentConstants.TYPE_FOURTEEN
ProcessUtils.processPage(content)
break;
default:
break;
}
}
}
...
...
sight_harmony/features/wdComponent/src/main/ets/components/ImageAndTextPageComponent.ets
View file @
3ec9e42
...
...
@@ -20,9 +20,11 @@ import { WDRouterPage, WDRouterRule } from 'wdRouter/Index';
import { MultiPictureDetailViewModel } from '../viewmodel/MultiPictureDetailViewModel';
import { PageRepository } from '../repository/PageRepository';
import { detailedSkeleton } from './skeleton/detailSkeleton';
const PATTERN_DATE_CN_RN: string = 'yyyy年MM月dd日 HH:mm';
const TAG = 'ImageAndTextPageComponent'
@Component
export struct ImageAndTextPageComponent {
scroller: Scroller = new Scroller();
...
...
@@ -33,39 +35,35 @@ export struct ImageAndTextPageComponent {
@State interactData: InteractDataDTO = {} as InteractDataDTO
@State isPageEnd: boolean = false
@State publishTime: string = ''
build() {
Column() {
if (!this.isPageEnd) {
detailedSkeleton()
} else {
// 发布时间
Row() {
Image(this.contentDetailData[0]?.rmhInfo ? $r('app.media.logo_rmh') : $r('app.media.logo_rmrb'))
.width(80)
.height(28)
Text(this.publishTime)
.fontColor($r('app.color.color_B0B0B0'))
.fontSize($r('app.float.font_size_13'))
.height('100%')
.align(Alignment.End)
}
.width(CommonConstants.FULL_WIDTH)
.height(32)
.padding({ left: 15, right: 15, })
.justifyContent(FlexAlign.SpaceBetween)
.backgroundColor(Color.White)
Row() {
Image($r('app.media.line'))
.width('100%')
.height(6)
.objectFit(ImageFit.Cover)
.margin({ top: 10 })
}
.padding({ left: 15, right: 15 })
.backgroundColor(Color.White)
// 发布时间
Row() {
Image(this.contentDetailData[0]?.rmhInfo ? $r('app.media.logo_rmh') : $r('app.media.logo_rmrb'))
.width(80)
.height(28)
Text(this.publishTime)
.fontColor($r('app.color.color_B0B0B0'))
.fontSize($r('app.float.font_size_13'))
.height('100%')
.align(Alignment.End)
}
.width(CommonConstants.FULL_WIDTH)
.height(32)
.padding({ left: 15, right: 15, })
.justifyContent(FlexAlign.SpaceBetween)
.backgroundColor(Color.White)
Row() {
Image($r('app.media.line'))
.width('100%')
.height(6)
.objectFit(ImageFit.Cover)
.margin({ top: 10 })
}
.padding({ left: 15, right: 15 })
.backgroundColor(Color.White)
Stack({ alignContent: Alignment.Bottom }) {
Scroll(this.scroller) {
...
...
@@ -88,6 +86,10 @@ export struct ImageAndTextPageComponent {
.padding({ bottom: 76 })
.scrollBar(BarState.Off)
if (!this.isPageEnd) {
detailedSkeleton()
}
//底部交互区
Row() {
Image($r('app.media.icon_arrow_left'))
...
...
@@ -126,6 +128,7 @@ export struct ImageAndTextPageComponent {
.justifyContent(FlexAlign.SpaceBetween)
.backgroundColor(Color.White)
}
}
.width(CommonConstants.FULL_WIDTH)
.height(CommonConstants.FULL_HEIGHT)
...
...
@@ -152,7 +155,7 @@ export struct ImageAndTextPageComponent {
if (detailBeans && detailBeans.length > 0) {
this.contentDetailData = detailBeans;
let dateTime = DateTimeUtils.parseDate(this.contentDetailData[0]?.publishTime, DateTimeUtils.PATTERN_DATE_TIME_HYPHEN);
this.publishTime = DateTimeUtils.formatDate(dateTime,PATTERN_DATE_CN_RN)
this.publishTime = DateTimeUtils.formatDate(dateTime,
PATTERN_DATE_CN_RN)
if (this.contentDetailData[0]?.recommendShow === 1) {
this.getRecommend()
}
...
...
sight_harmony/features/wdComponent/src/main/ets/components/page/TopNavigationComponent.ets
View file @
3ec9e42
import { Action, CompDTO, Params, TopNavDTO } from 'wdBean';
import { LazyDataSource, Logger } from 'wdKit';
import {
WDRouterRule
} from 'wdRouter';
import {
ProcessUtils
} from 'wdRouter';
import { PageComponent } from './PageComponent';
import { ChannelSubscriptionLayout } from './ChannelSubscriptionLayout';
import { FirstTabTopSearchComponent } from '../search/FirstTabTopSearchComponent';
...
...
@@ -135,16 +135,6 @@ export struct TopNavigationComponent {
return item.name === '版面'
}
jumpToENewPaper() {
let taskAction: Action = {
type: 'JUMP_INNER_NEW_PAGE',
params: {
pageID: 'E_NEWSPAPER'
} as Params,
};
WDRouterRule.jumpWithAction(taskAction)
}
build() {
Column() {
// 顶部搜索、日报logo、早晚报
...
...
@@ -156,7 +146,7 @@ export struct TopNavigationComponent {
.width(72)
.height(29)
.onClick(() => {
this.jumpToENew
Paper()
ProcessUtils.gotoENews
Paper()
})
Stack({ alignContent: Alignment.Center }) {
Image($r('app.media.background_read_paper_home'))
...
...
@@ -177,13 +167,7 @@ export struct TopNavigationComponent {
.height(30)
.width(124)
.onClick(() => {
let taskAction: Action = {
type: 'JUMP_INNER_NEW_PAGE',
params: {
pageID: 'MorningEveningPaper'
} as Params,
};
WDRouterRule.jumpWithAction(taskAction)
ProcessUtils.gotoMorningEveningPaper()
})
}.width('100%')
.justifyContent(FlexAlign.SpaceBetween)
...
...
@@ -236,18 +220,11 @@ export struct TopNavigationComponent {
}
if (this.isBroadcast(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index])) {
// 跳转到播报页面
let taskAction: Action = {
type: 'JUMP_INNER_NEW_PAGE',
params: {
pageID: 'BroadcastPage',
id: this.myChannelList[index].pageId
} as Params,
};
WDRouterRule.jumpWithAction(taskAction)
ProcessUtils.gotoBroadcastPage(this.myChannelList[index].pageId)
this.tabsController.changeIndex(this.currentTopNavSelectedIndex)
}
if (this.isLayout(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index])) {
this.jumpToENew
Paper()
ProcessUtils.gotoENews
Paper()
this.tabsController.changeIndex(this.currentTopNavSelectedIndex)
}
})
...
...
sight_harmony/products/phone/oh-package.json5
View file @
3ec9e42
...
...
@@ -15,6 +15,7 @@
"wdDetailPlayShortVideo"
:
"file:../../features/wdDetailPlayShortVideo"
,
"wdRouter"
:
"file:../../commons/wdRouter"
,
"wdNetwork"
:
"file:../../commons/wdNetwork"
,
"wdHwAbility"
:
"file:../../features/wdHwAbility"
"wdHwAbility"
:
"file:../../features/wdHwAbility"
,
"wdJsBridge"
:
"file:../../commons/wdJsBridge"
}
}
...
...
sight_harmony/products/phone/src/main/ets/pages/web/DefaultWebPage.ets
View file @
3ec9e42
import router from '@ohos.router';
import { Action } from 'wdBean';
import { Logger } from 'wdKit';
import { WdWebComponent } from 'wdWebComponent';
const TAG = 'DefaultWebPage';
import router from '@ohos.router';
import { CommonConstants } from 'wdConstant'
import { BridgeWebViewControl } from 'wdJsBridge';
import { detailedSkeleton } from 'wdComponent/src/main/ets/components/skeleton/detailSkeleton'
const TAG = 'DefaultWebPage'
@Entry
@Component
struct DefaultWebPage {
private url?: string;
@State reload: number = 0;
@State isPageEnd : boolean = false
aboutToAppear() {
let action: Action = router.getParams() as Action
if (action) {
this.url = action.params?.url
}
}
onPageShow() {
Logger.info(TAG, `DefaultWebPage# onPageShow:::refresh`);
this.reload = ++this.reload
}
onPageHide() {
this.reload = 0
}
webviewControl: BridgeWebViewControl = new BridgeWebViewControl()
scroller: Scroller = new Scroller();
action: Action = {} as Action
@State webUrl: string = '';
@State isPageEnd: boolean = false
build() {
Column() {
WdWebComponent({
webUrl: this.url,
backVisibility: false,
// reload: this.reload,
isPageEnd:$isPageEnd
})
if (!this.isPageEnd) {
detailedSkeleton()
}
Stack({ alignContent: Alignment.Bottom }) {
Column() {
WdWebComponent({
webviewControl: this.webviewControl,
webUrl: this.webUrl,
backVisibility: false,
isPageEnd: $isPageEnd
})
}
.padding({ bottom: 56 })
.width(CommonConstants.FULL_WIDTH)
.height(CommonConstants.FULL_HEIGHT)
}
}.width(CommonConstants.FULL_WIDTH).height(CommonConstants.FULL_HEIGHT)
}
aboutToAppear() {
let action: Action = router.getParams() as Action
if (action) {
this.webUrl = action.params?.url || ''
}
}
}
}
\ No newline at end of file
...
...
Please
register
or
login
to post a comment