liyubing

Merge remote-tracking branch 'origin/main'

import { Action } from './Action';
interface dataObject {
// dataSource:
// 1、图文详情数据
// 2、英文端跳转推荐内容数据
// 3、显示图片预览
// 4、专题pageinfo数据
// 5、专题comp运营位点击跳转(传给App记录浏览历史)
// 6、图文详情引用内容跳转
// 7、专题分享海报图上的数据列表(H5可选第一页前5条运营位数据)
// 8、活动投稿 文章跳转
// 9、活动投稿 视频跳转
// 10、活动投稿 动态跳转
// 11、活动投稿 图集跳转
dataSource: number
operateType?: string
webViewHeight?: string
... ...
... ... @@ -22,6 +22,11 @@ export class Logger {
private static domain: number = 0xFF00;
private static prefix: string = 'SightApp';
private static format: string = `%{public}s, %{public}s`;
private static format_ext: string = `%{public}s`;
/**
* 暂时没找到限制大小相关文档,尝试4000是不行的,3500可以。可以后续优化
*/
private static CHUNK_SIZE: number = 3500;
static isDebug: boolean = true;
/**
... ... @@ -36,46 +41,113 @@ export class Logger {
}
static debug(...args: string[]) {
if(!Logger.isDebug){
if (!Logger.isDebug) {
return
}
hilog.debug(Logger.domain, Logger.prefix, Logger.format, args);
Logger.logContent(LogLevel.DEBUG, ...args)
}
static info(...args: string[]) {
if(!Logger.isDebug){
if (!Logger.isDebug) {
return
}
hilog.info(Logger.domain, Logger.prefix, Logger.format, args);
Logger.logContent(LogLevel.INFO, ...args)
}
static warn(...args: string[]) {
if(!Logger.isDebug){
if (!Logger.isDebug) {
return
}
hilog.warn(Logger.domain, Logger.prefix, Logger.format, args);
Logger.logContent(LogLevel.WARN, ...args)
}
static error(...args: string[]) {
if(!Logger.isDebug){
if (!Logger.isDebug) {
return
}
hilog.error(Logger.domain, Logger.prefix, Logger.format, args);
Logger.logContent(LogLevel.ERROR, ...args)
}
static fatal(...args: string[]) {
if(!Logger.isDebug){
if (!Logger.isDebug) {
return
}
hilog.fatal(Logger.domain, Logger.prefix, Logger.format, args);
Logger.logContent(LogLevel.FATAL, ...args)
}
static isLoggable(level: LogLevel) {
if(!Logger.isDebug){
if (!Logger.isDebug) {
return
}
// 判断是否打印 TODO
hilog.isLoggable(Logger.domain, Logger.prefix, level);
}
static logContent(level: LogLevel, ...args: string[]) {
let msg = Logger.getMsg(...args)
let length = msg.length
if (length < Logger.CHUNK_SIZE) {
// 不超限,保持原来的打印
Logger.print(level, ...args)
} else {
// 超限,分段打印
for (let i = 0; i < length; i += Logger.CHUNK_SIZE) {
let count = Math.min(length - i, Logger.CHUNK_SIZE);
Logger.printExt(level, msg.substring(i, i + count));
}
}
}
static print(level: LogLevel, ...msg: string[]) {
switch (level) {
case LogLevel.DEBUG:
hilog.debug(Logger.domain, Logger.prefix, Logger.format, msg);
break
case LogLevel.INFO:
hilog.info(Logger.domain, Logger.prefix, Logger.format, msg);
break
case LogLevel.WARN:
hilog.warn(Logger.domain, Logger.prefix, Logger.format, msg);
break
case LogLevel.ERROR:
hilog.error(Logger.domain, Logger.prefix, Logger.format, msg);
break
case LogLevel.FATAL:
hilog.fatal(Logger.domain, Logger.prefix, Logger.format, msg);
break
}
}
static printExt(level: LogLevel, msg: string) {
switch (level) {
case LogLevel.DEBUG:
hilog.debug(Logger.domain, Logger.prefix, Logger.format_ext, msg);
break
case LogLevel.INFO:
hilog.info(Logger.domain, Logger.prefix, Logger.format_ext, msg);
break
case LogLevel.WARN:
hilog.warn(Logger.domain, Logger.prefix, Logger.format_ext, msg);
break
case LogLevel.ERROR:
hilog.error(Logger.domain, Logger.prefix, Logger.format_ext, msg);
break
case LogLevel.FATAL:
hilog.fatal(Logger.domain, Logger.prefix, Logger.format_ext, msg);
break
}
}
static getMsg(...args: string[]): string {
if (args == null || args.length <= 0) {
return '';
}
let msg = ''
args.forEach((v) => {
msg = msg.concat(', ').concat(v)
})
return msg.substring(2, msg.length);
}
}
export default new Logger('SightApp', 0xFF00)
\ No newline at end of file
... ...
... ... @@ -12,8 +12,17 @@ export interface ResponseDTO<T = string> {
// 响应结果
data?: T;
/**
* @deprecated
*/
totalCount?: number;
meta?: MetaDTO;
// 请求响应时间戳(unix格式)
timestamp?: number;
}
export interface MetaDTO {
md5: string;
}
\ No newline at end of file
... ...
... ... @@ -38,6 +38,7 @@ instance.interceptors.request.use(
}
// 公共请求参数
// config.params.key = key
Logger.debug('HttpRequest', 'request: ' + config.url)
return config;
},
(error: AxiosError) => {
... ... @@ -85,9 +86,9 @@ instance.interceptors.response.use(// 响应拦截器response类型就是Axios.r
// return Promise.reject(new Error(message))
// }
// const data: ResponseBean<any> = response.data
Logger.debug('HttpRequest', 'response ======start======= ')
Logger.debug('HttpRequest', 'response ==============start=================')
Logger.debug('HttpRequest', 'response: ' + JSON.stringify(response.data))
Logger.debug('HttpRequest', 'response ======end======= ')
Logger.debug('HttpRequest', 'response ==============end=================')
// 改造返回的数据,即将AxiosResponse的data返回,服务端返回的数据
return response.data;
} else {
... ... @@ -102,7 +103,7 @@ instance.interceptors.response.use(// 响应拦截器response类型就是Axios.r
// console.log(error.request)
// console.log(error.response)
// 这里用来处理http常见错误,进行全局提示
if(error!=null && error.response!=null ){
if (error != null && error.response != null) {
let message = buildErrorMsg(error.response.status);
// 错误消息可以使用全局弹框展示出来
console.log(`httpStatus:${error.response?.status}-${message},请检查网络或联系管理员!`)
... ...
... ... @@ -14,6 +14,7 @@ const TAG = 'JsBridgeBiz'
*/
export function performJSCallNative(data: Message, call: Callback) {
Logger.debug(TAG, 'performJSCallNative handlerName: ' + data.handlerName + ', data: ' + JSON.stringify(data.data))
switch (data.handlerName) {
case H5CallNativeType.jsCall_currentPageOperate:
break;
... ... @@ -24,12 +25,13 @@ export function performJSCallNative(data: Message, call: Callback) {
case H5CallNativeType.jsCall_getArticleDetailBussinessData:
break;
case H5CallNativeType.jsCall_callAppService:
handleJsCallCallAppService(data)
break;
case H5CallNativeType.jsCall_receiveH5Data:
if(data?.data?.dataSource === 5){
handleH5Data(JSON.parse(data?.data?.dataJson || '{}'))
}
handleJsCallReceiveH5Data(data)
break;
case H5CallNativeType.jsCall_appInnerLinkMethod:
handleJsCallAppInnerLinkMethod(data)
break;
case 'changeNativeMessage':
call("this is change Web Message")
... ... @@ -51,17 +53,35 @@ class AppInfo {
* 获取App公共信息
*/
function getAppPublicInfo(): string {
let info = new AppInfo()
info.plat = 'Phone'
// 直接用Android,后续适配再新增鸿蒙
info.system = 'Android'
info.networkStatus = 1
let result = JSON.stringify(info)
Logger.debug(TAG, 'getAppPublicInfo: ' + JSON.stringify(info))
return result;
}
function handleH5Data(content:ContentDTO) {
Logger.debug(TAG, 'handleH5Data' + ', content: ' + JSON.stringify(content))
ProcessUtils.processPage(content)
function handleJsCallReceiveH5Data(data: Message) {
switch (data?.data?.dataSource) {
case 5:
if (data?.data?.dataSource === 5) {
ProcessUtils.processPage(JSON.parse(data?.data?.dataJson || '{}'))
}
break;
default:
break;
}
}
function handleJsCallCallAppService(data: Message) {
}
function handleJsCallAppInnerLinkMethod(data: Message) {
}
... ...
... ... @@ -67,11 +67,10 @@ export struct BottomNavigationComponent {
TopNavigationComponent({
groupId: navItem.id,
topNavList: navItem.topNavChannelList.filter(item => item.channelId != 2073),
_currentNavIndex: this.currentNavIndex,
_currentNavIndex: $currentNavIndex,
currentBottomNavName: navItem.name,
changeBarBackgroundColor: (color: Color) => {
this.barBackgroundColor = color
}
barBackgroundColor: $barBackgroundColor
})
}
... ... @@ -92,7 +91,8 @@ export struct BottomNavigationComponent {
// this.onBottomNavigationIndexChange()
})
.backgroundColor(this.barBackgroundColor)
.padding({ bottom: this.bottomRectHeight + 'px', top: this.topRectHeight + 'px' }) // 此处margin具体数值在实际中应与导航条区域高度保持一致
// .padding({ bottom: this.bottomRectHeight + 'px', top: this.topRectHeight + 'px' }) // 此处margin具体数值在实际中应与导航条区域高度保持一致
}
... ...
... ... @@ -125,14 +125,15 @@ export struct PageComponent {
this.pageModel.groupId = this.pageId;
this.pageModel.channelId = this.channelId;
this.pageModel.currentPage = 1;
let pageInfo = await PageViewModel.getPageInfo(this.pageModel.pageId);
if (pageInfo == null) {
this.pageModel.viewType = ViewType.EMPTY;
return;
}
this.pageModel.pageInfo = pageInfo;
this.pageModel.loadStrategy = 1
PageHelper.parseGroup(this.pageModel)
PageHelper.getInitData(this.pageModel)
// let pageInfo = await PageViewModel.getPageInfo(this.pageModel.pageId);
// if (pageInfo == null) {
// this.pageModel.viewType = ViewType.EMPTY;
// return;
// }
// this.pageModel.pageInfo = pageInfo;
// this.pageModel.loadStrategy = 1
// PageHelper.parseGroup(this.pageModel)
}
}
... ...
... ... @@ -24,17 +24,15 @@ export struct TopNavigationComponent {
private groupId: number = 0
private currentBottomNavName: string = ''
private tabsController: TabsController = new TabsController()
private changeBarBackgroundColor: (color: Color) => void = () => {
}
@Consume isLayoutFullScreen: boolean
@Consume bottomRectHeight: number
@Consume topRectHeight: number
@State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0
@State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0
@State barBackgroundColor: Color = Color.Transparent
@Prop @Watch('indexChange') _currentNavIndex?: number;
@Link barBackgroundColor: Color
@Link _currentNavIndex?: number;
// 顶导当前选中/焦点下标
@State @Watch('indexChange') currentTopNavSelectedIndex: number = 0;
@State currentTopNavSelectedIndex: number = 0;
// 顶导数据
@State @Watch('onTopNavigationDataUpdated') topNavList: TopNavDTO[] = []
@State compList: LazyDataSource<CompDTO> = new LazyDataSource();
... ... @@ -151,29 +149,6 @@ export struct TopNavigationComponent {
WDRouterRule.jumpWithAction(taskAction)
}
indexChange() {
// 判断视频频道待处理
if (this._currentNavIndex === 2 && this.currentTopNavSelectedIndex == 0) {
this.barBackgroundColor = Color.Black
this.changeBarBackgroundColor && this.changeBarBackgroundColor(this.barBackgroundColor)
// WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#ffffff', })
// WindowModel.shared.setWindowLayoutFullScreen(true)
// this.isLayoutFullScreen = true
// this.bottomRectHeight = this.bottomSafeHeight
// this.topRectHeight = this.topSafeHeight
} else {
this.barBackgroundColor = Color.Transparent
this.changeBarBackgroundColor && this.changeBarBackgroundColor(this.barBackgroundColor)
// WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#000000', })
// WindowModel.shared.setWindowLayoutFullScreen(false)
// this.isLayoutFullScreen = false
// this.bottomRectHeight = 0
// this.topRectHeight = 0
}
}
build() {
Column() {
// 顶部搜索、日报logo、早晚报
... ... @@ -230,11 +205,12 @@ export struct TopNavigationComponent {
TabContent() {
if (this.currentBottomNavName === '视频' && navItem.name === '视频') {
VideoChannelDetail({
bottomNavIndex: this._currentNavIndex,
topNavIndex: this.currentTopNavSelectedIndex,
bottomNavIndex: $_currentNavIndex,
topNavIndex: $currentTopNavSelectedIndex,
groupId: this.groupId + '',
pageId: navItem.pageId + '',
channelId: navItem.channelId + '',
barBackgroundColor: $barBackgroundColor
})
} else
if (!this.isBroadcast(navItem) && !this.isLayout(navItem)) {
... ...
... ... @@ -14,9 +14,9 @@
<meta name="apple-mobile-web-app-capable" content="yes" />
<!-- 设置苹果工具栏颜色 -->
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<script src="./js/plugin/vconsole.min.js"></script>
<!-- <script src="./js/plugin/vconsole.min.js"></script>-->
<script>
new VConsole()
//new VConsole()
var hasDetails = false
function getTime() {
... ...
... ... @@ -137,26 +137,22 @@ export struct DetailVideoListPage {
Column() {
Swiper(this.swiperController) {
ForEach(this.data, (item: ContentDetailDTO, index: number) => {
Column() {
DetailPlayShortVideoPage({
switchVideoStatus: $switchVideoStatus,
contentDetailData: item,
currentIndex: this.currentIndex,
index: index,
interactData: this.interactDataList[index]
})
}.width('100%')
.height('100%')
DetailPlayShortVideoPage({
switchVideoStatus: $switchVideoStatus,
contentDetailData: item,
currentIndex: this.currentIndex,
index: index,
interactData: this.interactDataList[index]
})
}, (item: ContentDetailDTO) => item.newsId + '')
}
.clip(false)
.cachedCount(-1)
.indicator(false)
.vertical(true)
.loop(false)
.width('100%')
.height('100%')
.cachedCount(3)
.displayCount(1, true)
.onChange((index: number) => {
this.currentIndex = index
console.info('onChange==', index.toString())
... ...
import { Logger } from 'wdKit';
const TAG = 'PictureLoading';
@Component
export struct PictureLoading {
private imagePath: string = ''
//alt app.media.picture_loading 设计稿尺寸
@State imageWidth: string | number = 167
@State ratio: number = 167 / 60
async aboutToAppear() {
Logger.info(TAG, 'pictures preview')
}
build() {
Row() {
Image(this.imagePath)
.alt($r('app.media.picture_loading'))
.width(this.imageWidth)
.aspectRatio(this.ratio)
.objectFit(ImageFit.Fill)
.interpolation(ImageInterpolation.High)
.onComplete((event) => {
if (event) {
this.imageWidth = '100%'
this.ratio = event.width / event.height
}
})
}
.height('100%')
.width('100%')
.backgroundColor(Color.Black)
.justifyContent(FlexAlign.Center)
}
}
\ No newline at end of file
... ...
... ... @@ -14,6 +14,7 @@ import {
} from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest';
import { Logger, WindowModel } from 'wdKit/Index';
import { BusinessError } from '@kit.BasicServicesKit';
import { PictureLoading } from './PictureLoading';
interface loadMoreData {
pageNum: number;
... ... @@ -39,6 +40,7 @@ export struct VideoChannelDetail {
// private recommend?: string = '' // 0.非推荐,1.推荐;
@Link @Watch('navIndexChange') bottomNavIndex: number
@Link @Watch('navIndexChange') topNavIndex: number
@Link barBackgroundColor: Color
private swiperController: SwiperController = new SwiperController()
@Provide showComment: boolean = false
@State data: ContentDetailDTO[] = []
... ... @@ -46,26 +48,29 @@ export struct VideoChannelDetail {
@State interactDataList: InteractDataDTO[] = []
@State totalCount: number = 0
@State switchVideoStatus: boolean = false
@State isMouted: boolean = false
/**
* 监听视频频道激活或失活
*/
navIndexChange() {
if (timer) clearTimeout(timer)
timer = setTimeout(() => {
if (this.bottomNavIndex === 2 && this.topNavIndex === 0) {
// 如果视频在暂停则播放视频
this.switchVideoStatus = true
WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#ffffff', statusBarColor: '#000000' })
} else {
// 如果视频在播放则暂停视频
this.switchVideoStatus = false
WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#000000', statusBarColor: '#ffffff' })
// WindowModel.shared.setWindowLayoutFullScreen(false)
}
timer = -1
}, 100)
// if (timer) clearTimeout(timer)
console.log('navIndexChange', this.bottomNavIndex, this.topNavIndex)
// timer = setTimeout(() => {
if (this.bottomNavIndex === 2 && this.topNavIndex === 0) {
// 如果视频在暂停则播放视频
this.switchVideoStatus = true
this.barBackgroundColor = Color.Black
this.openFullScreen()
} else {
// 如果视频在播放则暂停视频
this.switchVideoStatus = false
this.barBackgroundColor = Color.Transparent
this.closeFullScreen()
}
// timer = -1
// }, 100)
}
... ... @@ -82,22 +87,27 @@ export struct VideoChannelDetail {
Logger.info(TAG, 'aboutToDisappear');
}
// onPageShow(): void {
// this.openFullScreen()
// Logger.info(TAG, 'onPageShow');
// }
//
// onPageHide(): void {
// this.closeFullScreen()
// Logger.info(TAG, 'onPageHide');
// }
onPageShow(): void {
this.openFullScreen()
Logger.info(TAG, 'onPageShow');
}
onPageHide(): void {
this.closeFullScreen()
Logger.info(TAG, 'onPageHide');
}
/**
* 开启沉浸式
* TODO:颜色待根据业务接口修改
*/
openFullScreen() {
WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#ffffff', })
WindowModel.shared.setWindowSystemBarProperties({
statusBarContentColor: '#ffffff',
statusBarColor: '#000000',
// navigationBarColor: '#000000',
// navigationBarContentColor: '#ffffff'
})
// WindowModel.shared.setWindowLayoutFullScreen(true)
// WindowModel.shared.setWindowSystemBarEnable([])
}
... ... @@ -107,7 +117,13 @@ export struct VideoChannelDetail {
* TODO:颜色待根据业务接口修改
*/
closeFullScreen() {
WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#000000', })
WindowModel.shared.setWindowSystemBarProperties({
statusBarContentColor: '#000000',
statusBarColor: '#ffffff',
// navigationBarColor: '#0x66000000',
// navigationBarContentColor: '#0xE5FFFFFF'
})
// WindowModel.shared.setWindowLayoutFullScreen(false)
// WindowModel.shared.setWindowSystemBarEnable(['status', 'navigation'])
}
... ... @@ -162,6 +178,9 @@ export struct VideoChannelDetail {
this.batchContentDetail(list1)
this.getContentInteract(list2)
setTimeout(() => {
this.isMouted = true
}, 500)
})
}
... ... @@ -192,6 +211,7 @@ export struct VideoChannelDetail {
build() {
Column() {
PictureLoading().visibility(this.isMouted ? Visibility.None : Visibility.Visible)
Swiper(this.swiperController) {
ForEach(this.data, (item: ContentDetailDTO, index: number) => {
Column() {
... ... @@ -206,6 +226,7 @@ export struct VideoChannelDetail {
.height('100%')
}, (item: ContentDetailDTO) => item.newsId + '')
}
.visibility(this.isMouted ? Visibility.Visible : Visibility.None)
.cachedCount(-1)
.indicator(false)
.vertical(true)
... ... @@ -226,6 +247,9 @@ export struct VideoChannelDetail {
}
})
}.width('100%').height('100%')
}
.width('100%')
.height('100%')
.backgroundColor('#000000')
}
}
\ No newline at end of file
... ...