wangliang_wd

Merge branch 'main' of http://192.168.1.42/developOne/harmonyPool into main

* 'main' of http://192.168.1.42/developOne/harmonyPool:
  版面-电子报版面按住图片出现阴影绘制区域优化
  fix: 1)无网络,点击预告直播间和正在直播直播间,预期提示“网络出小差了,请检查网络后重试”,实际进入黑色页面
  feat: 1)人民号--关注频道,稿件线,和删除冗余调用冗余接口
  ref |> 统一优化跳转详情页detailPageType
  ref |> 早晚报桌面组件跳转App页面处理
  ref |> 早晚报桌面组件图片显示相关逻辑
  feat: 1)人民号--关注频道ui
Showing 24 changed files with 534 additions and 137 deletions
@@ -67,4 +67,8 @@ export { TingyunAPM } from './src/main/ets/tingyunAPM/TingyunAPM' @@ -67,4 +67,8 @@ export { TingyunAPM } from './src/main/ets/tingyunAPM/TingyunAPM'
67 export { FastClickUtil } from './src/main/ets/utils/FastClickUtil'; 67 export { FastClickUtil } from './src/main/ets/utils/FastClickUtil';
68 68
69 // export { PublicPopupDialogView } from "./src/main/ets/pubComps/dialog/PublicPopupDialogView" 69 // export { PublicPopupDialogView } from "./src/main/ets/pubComps/dialog/PublicPopupDialogView"
70 -export { PublicDialogManager, CloseAction } from "./src/main/ets/pubComps/dialog/PublicDialogManager"  
  70 +export { PublicDialogManager, CloseAction } from "./src/main/ets/pubComps/dialog/PublicDialogManager"
  71 +
  72 +export { CrptoUtils } from "./src/main/ets/utils/CrptoUtils"
  73 +
  74 +export { FileUtils } from "./src/main/ets/utils/FileUtils"
  1 +import cryptoFramework from '@ohos.security.cryptoFramework';
  2 +import buffer from '@ohos.buffer';
  3 +
  4 +export class CrptoUtils {
  5 +
  6 + static md5(message: string) : Promise<string> {
  7 + return CrptoUtils.mdFunc(message, 'MD5')
  8 + }
  9 +
  10 + static mdFunc(message: string, algoName: string = 'MD5'): Promise<string> {
  11 + return new Promise<string>(async (reslove, fail) => {
  12 +
  13 + try {
  14 + let md = cryptoFramework.createMd(algoName);
  15 + // 数据量较少时,可以只做一次update,将数据全部传入,接口未对入参长度做限制
  16 + await md.update({ data: new Uint8Array(buffer.from(message, 'utf-8').buffer) });
  17 + let mdResult = await md.digest();
  18 + // console.info('Md result:' + mdResult.data);
  19 +
  20 + // const string = mdResult.data.map((charCode, index, array) => {
  21 + // return String.fromCharCode(charCode)
  22 + // }).join("")
  23 +
  24 + let string = "";
  25 + for (let i = 0; i < mdResult.data.length; i++) {
  26 + string += mdResult.data[i].toString(16).padStart(2, "0")
  27 + }
  28 +
  29 + // const string = mdResult.data.join('')
  30 +
  31 + reslove(string)
  32 + } catch (e) {
  33 + fail(e)
  34 + }
  35 + })
  36 + }
  37 +}
  38 +
  39 +
  40 +
  41 +
  1 +
  2 +import fs from '@ohos.file.fs';
  3 +import { BusinessError } from '@kit.BasicServicesKit';
  4 +
  5 +export class FileUtils {
  6 +
  7 + // 文件是否存在,忽略错误
  8 + static fileExsit(path: string) : Promise<boolean> {
  9 + return new Promise((reslove, fail) => {
  10 + fs.stat(path).then(() => {
  11 + reslove(true)
  12 + }).catch((error: BusinessError) => {
  13 + if (error.code = 13900002) {
  14 + reslove(false)
  15 + } else {
  16 + reslove(true)
  17 + }
  18 + })
  19 + });
  20 + }
  21 +
  22 + static makeDirIfNotExsit(path: string) : Promise<void> {
  23 + return new Promise((reslove, fail) => {
  24 + fs.stat(path).then(() => {
  25 + reslove()
  26 + }).catch((error: BusinessError) => {
  27 + if (error.code = 13900002) {
  28 + fs.mkdirSync(path)
  29 + }
  30 + reslove()
  31 + })
  32 + })
  33 + }
  34 +}
@@ -49,9 +49,9 @@ export function registerRouter() { @@ -49,9 +49,9 @@ export function registerRouter() {
49 // }) 49 // })
50 50
51 Action2Page.register("JUMP_DETAIL_PAGE", (action: Action) => { 51 Action2Page.register("JUMP_DETAIL_PAGE", (action: Action) => {
52 - if (action.params?.detailPageType == 2 || action.params?.detailPageType == 6) { 52 + if (action.params?.detailPageType == 2) {
53 return WDRouterPage.detailPlayLiveCommon 53 return WDRouterPage.detailPlayLiveCommon
54 - } else if (action.params?.detailPageType == 7 || action.params?.detailPageType == 8) { 54 + } else if (action.params?.detailPageType == 1) {
55 return WDRouterPage.detailVideoListPage 55 return WDRouterPage.detailVideoListPage
56 } else if (action.params?.detailPageType == 9) { 56 } else if (action.params?.detailPageType == 9) {
57 //图集详情页 57 //图集详情页
@@ -59,16 +59,19 @@ export function registerRouter() { @@ -59,16 +59,19 @@ export function registerRouter() {
59 } else if (action.params?.detailPageType == 14 || action.params?.detailPageType == 15) { 59 } else if (action.params?.detailPageType == 14 || action.params?.detailPageType == 15) {
60 //动态详情页 60 //动态详情页
61 return WDRouterPage.dynamicDetailPage 61 return WDRouterPage.dynamicDetailPage
62 - } else if (action.params?.detailPageType == 17) {  
63 - return WDRouterPage.multiPictureDetailPage  
64 } else if (action.params?.detailPageType == 13) { 62 } else if (action.params?.detailPageType == 13) {
65 return WDRouterPage.audioDetail 63 return WDRouterPage.audioDetail
66 - } else if (action.params?.detailPageType == 18) { 64 + } else if (action.params?.detailPageType == 30) {
  65 + return WDRouterPage.themeListPage
  66 + } else if (action.params?.detailPageType == 8) {
  67 + return WDRouterPage.imageTextDetailPage
  68 + }
  69 +
  70 + //TODO: 以下两个最好改为pageID方式,以上都是有具体内容类型 对应详情页面
  71 + else if (action.params?.detailPageType == 18) {
67 return WDRouterPage.multiPictureListPage 72 return WDRouterPage.multiPictureListPage
68 } else if (action.params?.detailPageType == 19) { 73 } else if (action.params?.detailPageType == 19) {
69 return WDRouterPage.videoPlayPage 74 return WDRouterPage.videoPlayPage
70 - }else if (action.params?.detailPageType == 30) {  
71 - return WDRouterPage.themeListPage  
72 } 75 }
73 return WDRouterPage.detailPlayVodPage 76 return WDRouterPage.detailPlayVodPage
74 }) 77 })
@@ -3,6 +3,7 @@ import App from '@system.app' @@ -3,6 +3,7 @@ import App from '@system.app'
3 import { Action, Params } from 'wdBean/Index' 3 import { Action, Params } from 'wdBean/Index'
4 import { ExtraDTO } from 'wdBean/src/main/ets/bean/component/extra/ExtraDTO' 4 import { ExtraDTO } from 'wdBean/src/main/ets/bean/component/extra/ExtraDTO'
5 import { Logger } from 'wdKit/Index' 5 import { Logger } from 'wdKit/Index'
  6 +import { ContentType } from '../common/ContentType'
6 import { WDRouterRule } from '../router/WDRouterRule' 7 import { WDRouterRule } from '../router/WDRouterRule'
7 import { ProcessUtils } from './ProcessUtils' 8 import { ProcessUtils } from './ProcessUtils'
8 9
@@ -111,13 +112,13 @@ export class AppInnerLink { @@ -111,13 +112,13 @@ export class AppInnerLink {
111 } 112 }
112 private static contentTypeWithType(type?: string) : number | undefined { 113 private static contentTypeWithType(type?: string) : number | undefined {
113 switch (type) { 114 switch (type) {
114 - case "video": return 1  
115 - case "dynamic": return 14  
116 - case "live": return 2  
117 - case "audio": return 13  
118 - case "picture": return 9  
119 - case "article": return 8  
120 - case "ask": return 16 115 + case "video": return ContentType.Video
  116 + case "dynamic": return ContentType.DynamicImageText
  117 + case "live": return ContentType.Live
  118 + case "audio": return ContentType.Audio
  119 + case "picture": return ContentType.Pictures
  120 + case "article": return ContentType.ImageText
  121 + case "ask": return ContentType.Ask
121 } 122 }
122 return 123 return
123 } 124 }
1 import { Action, ContentDTO, Params, PhotoListBean, commentInfo } from 'wdBean'; 1 import { Action, ContentDTO, Params, PhotoListBean, commentInfo } from 'wdBean';
2 import { ExtraDTO } from 'wdBean/src/main/ets/bean/component/extra/ExtraDTO'; 2 import { ExtraDTO } from 'wdBean/src/main/ets/bean/component/extra/ExtraDTO';
3 -import { Logger, SPHelper } from 'wdKit'; 3 +import { Logger, NetworkUtil, SPHelper, ToastUtils } from 'wdKit';
4 import { StringUtils } from 'wdKit/src/main/ets/utils/StringUtils'; 4 import { StringUtils } from 'wdKit/src/main/ets/utils/StringUtils';
5 import { WDRouterRule, WDRouterPage } from '../../../../Index'; 5 import { WDRouterRule, WDRouterPage } from '../../../../Index';
6 import { ContentConstants, SpConstants } from 'wdConstant'; 6 import { ContentConstants, SpConstants } from 'wdConstant';
@@ -84,6 +84,13 @@ export class ProcessUtils { @@ -84,6 +84,13 @@ export class ProcessUtils {
84 Logger.error(TAG, "processPage, objectType is empty"); 84 Logger.error(TAG, "processPage, objectType is empty");
85 return; 85 return;
86 } 86 }
  87 + // 网络出小差了,请检查网络后重试
  88 + let netStatus = NetworkUtil.isNetConnected()
  89 + if(!netStatus){
  90 + ToastUtils.shortToast('网络出小差了,请检查网络后重试')
  91 + return
  92 + }
  93 +
87 let type = content.objectType; 94 let type = content.objectType;
88 if (typeof type == "number") { 95 if (typeof type == "number") {
89 type = `${type}` 96 type = `${type}`
@@ -304,7 +311,7 @@ export class ProcessUtils { @@ -304,7 +311,7 @@ export class ProcessUtils {
304 let taskAction: Action = { 311 let taskAction: Action = {
305 type: 'JUMP_DETAIL_PAGE', 312 type: 'JUMP_DETAIL_PAGE',
306 params: { 313 params: {
307 - detailPageType: 7, 314 + detailPageType: 1,
308 contentID: content?.objectId, 315 contentID: content?.objectId,
309 extra: { 316 extra: {
310 relType: content?.relType, 317 relType: content?.relType,
@@ -382,7 +389,7 @@ export class ProcessUtils { @@ -382,7 +389,7 @@ export class ProcessUtils {
382 let taskAction: Action = { 389 let taskAction: Action = {
383 type: 'JUMP_DETAIL_PAGE', 390 type: 'JUMP_DETAIL_PAGE',
384 params: { 391 params: {
385 - detailPageType: 17, 392 + detailPageType: 9,
386 contentID: content?.objectId, 393 contentID: content?.objectId,
387 extra: { 394 extra: {
388 relType: content?.relType, 395 relType: content?.relType,
@@ -10,16 +10,13 @@ export interface Params { @@ -10,16 +10,13 @@ export interface Params {
10 // 详情页类型 10 // 详情页类型
11 // 1.点播详情页 11 // 1.点播详情页
12 // 2.直播详情页 12 // 2.直播详情页
13 - // 3.图文详情页  
14 - // 4.全民播详情页  
15 - // 5.欢喜详情页  
16 - // 6.挂件详情页  
17 - // 7.沉浸式竖屏详情页  
18 - // 8.专辑竖屏详情页  
19 - // 13.音频详情页  
20 - // 17.多图(图集)详情页  
21 - // 18.大图列表页  
22 - // 19.单个视频播放页 13 + // 8.图文详情页
  14 + // 9.多图(图集)详情页
  15 + // 14和15 动态详情页
  16 + // 13 音频详情页
  17 + // 30 金刚位
  18 + // 18.大图列表页 - 图片预览 ------ 需要变更待定
  19 + // 19.单个视频播放页 - 视频播放 ----- 需要变更待定
23 detailPageType?: number; // 详情页类型 20 detailPageType?: number; // 详情页类型
24 liveStyle?: number; // 直播类型:0横屏,1竖屏 21 liveStyle?: number; // 直播类型:0横屏,1竖屏
25 creatorId?: string; //号主id 22 creatorId?: string; //号主id
@@ -25,6 +25,7 @@ import { TrackConstants, TrackingPageBrowse } from 'wdTracking/Index'; @@ -25,6 +25,7 @@ import { TrackConstants, TrackingPageBrowse } from 'wdTracking/Index';
25 */ 25 */
26 @Component 26 @Component
27 export struct CardParser { 27 export struct CardParser {
  28 +
28 @State pageId: string = ''; 29 @State pageId: string = '';
29 @State pageName: string = ''; 30 @State pageName: string = '';
30 @State contentDTO: ContentDTO = new ContentDTO(); 31 @State contentDTO: ContentDTO = new ContentDTO();
@@ -45,8 +45,6 @@ export struct CompParser { @@ -45,8 +45,6 @@ export struct CompParser {
45 45
46 aboutToAppear(): void { 46 aboutToAppear(): void {
47 47
48 -  
49 -  
50 console.log('CompParser', JSON.stringify(this.compDTO)) 48 console.log('CompParser', JSON.stringify(this.compDTO))
51 this.pageName = this.pageModel.pageInfo.name 49 this.pageName = this.pageModel.pageInfo.name
52 // 轮播图屏蔽音频类型稿件 50 // 轮播图屏蔽音频类型稿件
@@ -13,6 +13,10 @@ export struct ENewspaperItemComponent { @@ -13,6 +13,10 @@ export struct ENewspaperItemComponent {
13 private startY: number = 0 13 private startY: number = 0
14 private itemBeanClicked: NewspaperPositionItemBean = {} as NewspaperPositionItemBean 14 private itemBeanClicked: NewspaperPositionItemBean = {} as NewspaperPositionItemBean
15 @State isShowSkeleton: boolean = true 15 @State isShowSkeleton: boolean = true
  16 + @State contentWidth: number = 0
  17 + @State contentHeight: number = 0
  18 + @Consume itemPicWidth: number
  19 + @Consume itemPicHeight: number
16 20
17 aboutToAppear(): void { 21 aboutToAppear(): void {
18 for (let index = 0; index < this.newspaperListItemBean.items.length; index++) { 22 for (let index = 0; index < this.newspaperListItemBean.items.length; index++) {
@@ -33,23 +37,28 @@ export struct ENewspaperItemComponent { @@ -33,23 +37,28 @@ export struct ENewspaperItemComponent {
33 newsSkeleton() 37 newsSkeleton()
34 .visibility(this.isShowSkeleton ? Visibility.Visible : Visibility.None) 38 .visibility(this.isShowSkeleton ? Visibility.Visible : Visibility.None)
35 Image(this.newspaperListItemBean.pagePic) 39 Image(this.newspaperListItemBean.pagePic)
36 - .width('100%')  
37 - .onComplete(() => { 40 + .width(px2vp(this.itemPicWidth))
  41 + .height(px2vp(this.itemPicHeight))
  42 + .onComplete((event) => {
  43 + if (event?.loadingStatus == 1) {
  44 + this.contentWidth = event?.contentWidth
  45 + this.contentHeight = event?.contentHeight
  46 + }
38 this.isShowSkeleton = false 47 this.isShowSkeleton = false
39 }) 48 })
40 - .objectFit(ImageFit.Contain) 49 + .objectFit(ImageFit.Fill)
41 .visibility(this.isShowSkeleton ? Visibility.None : Visibility.Visible) 50 .visibility(this.isShowSkeleton ? Visibility.None : Visibility.Visible)
  51 + if (this.contentWidth !== 0) {
  52 + Canvas(this.context)
  53 + .width(px2vp(this.contentWidth))
  54 + .height(px2vp(this.contentHeight))
  55 + .backgroundColor(Color.Transparent)
  56 + .onReady(() => {
42 57
43 - Canvas(this.context)  
44 - .width('100%')  
45 - .height('100%')  
46 - .backgroundColor(Color.Transparent)  
47 - .onReady(() => {  
48 -  
49 - }) 58 + })
  59 + }
50 } 60 }
51 .padding({ top:14, right: 10, bottom: 14, left: 10 }) 61 .padding({ top:14, right: 10, bottom: 14, left: 10 })
52 - .margin({ left: 10, right: 10 })  
53 .backgroundColor(Color.White) 62 .backgroundColor(Color.White)
54 .width('100%') 63 .width('100%')
55 .onTouch((event: TouchEvent) => { 64 .onTouch((event: TouchEvent) => {
@@ -59,6 +68,7 @@ export struct ENewspaperItemComponent { @@ -59,6 +68,7 @@ export struct ENewspaperItemComponent {
59 this.startX = x; 68 this.startX = x;
60 this.startY = y; 69 this.startY = y;
61 let points: number[][] = this.getArea(x, y, this.newspaperListItemBean.items); 70 let points: number[][] = this.getArea(x, y, this.newspaperListItemBean.items);
  71 + console.log("event.points", JSON.stringify(points))
62 if (points && points.length > 2) { 72 if (points && points.length > 2) {
63 let path = new Path2D(); 73 let path = new Path2D();
64 path.moveTo(px2vp(points[0][0]), px2vp(points[0][1])); 74 path.moveTo(px2vp(points[0][0]), px2vp(points[0][1]));
@@ -21,8 +21,10 @@ export struct ENewspaperPageComponent { @@ -21,8 +21,10 @@ export struct ENewspaperPageComponent {
21 private windowClass?: window.Window; 21 private windowClass?: window.Window;
22 private displayTool = display.getDefaultDisplaySync() 22 private displayTool = display.getDefaultDisplaySync()
23 private screenWidth: number = 0 23 private screenWidth: number = 0
24 - private picWidth: number = 0 24 + @State picWidth: number = 0
25 @State picHeight: number = 0 25 @State picHeight: number = 0
  26 + @Provide itemPicWidth: number = 0
  27 + @Provide itemPicHeight: number = 0
26 @State newspaperListBean: NewspaperListBean = {} as NewspaperListBean 28 @State newspaperListBean: NewspaperListBean = {} as NewspaperListBean
27 @Provide @Watch('onCurrentPageNumUpdated') currentPageNum: string = '01' 29 @Provide @Watch('onCurrentPageNumUpdated') currentPageNum: string = '01'
28 @State pageDialogShow: boolean = false 30 @State pageDialogShow: boolean = false
@@ -131,13 +133,19 @@ export struct ENewspaperPageComponent { @@ -131,13 +133,19 @@ export struct ENewspaperPageComponent {
131 this.screenWidth = this.windowClass?.getWindowProperties()?.windowRect.width 133 this.screenWidth = this.windowClass?.getWindowProperties()?.windowRect.width
132 console.log('ENewspaperPageComponent this.screenWidth', this.screenWidth) 134 console.log('ENewspaperPageComponent this.screenWidth', this.screenWidth)
133 // 2000折叠屏 TODO DeviceUtil 方法完善了换判断条件 135 // 2000折叠屏 TODO DeviceUtil 方法完善了换判断条件
134 - this.ratio = this.screenWidth > 2000 ? '60%' : '100%' 136 + this.ratio = this.screenWidth > 2000 ? '50%' : '100%'
135 //获取宽高尺寸 137 //获取宽高尺寸
136 - this.picWidth = this.screenWidth - vp2px(52) 138 + // Swiper .margin({ left: 10, right: 10 })
  139 + this.picWidth = this.screenWidth - vp2px(20)
137 let screenHeight = this.displayTool.height; 140 let screenHeight = this.displayTool.height;
138 // bottomSafeHeight 底导高度 topSafeHeight 顶导高度 44 顶部高度 60 底部高度 141 // bottomSafeHeight 底导高度 topSafeHeight 顶导高度 44 顶部高度 60 底部高度
139 - let height = screenHeight - this.bottomSafeHeight - this.topSafeHeight - vp2px(44) - vp2px(60) 142 + // newspaper_shadow 49 高度 e_newspaper_content 59 margin top
  143 + let height = screenHeight - this.bottomSafeHeight - this.topSafeHeight - vp2px(44) - vp2px(60) - vp2px(49) -vp2px(59)
140 this.picHeight = height 144 this.picHeight = height
  145 +
  146 + let ratio = this.ratio == '100%' ? 1 : 0.5
  147 + this.picWidth = this.picWidth * ratio
  148 + this.picHeight = this.picHeight
141 // 默认日期 149 // 默认日期
142 const date = new Date() 150 const date = new Date()
143 const month = date.getMonth() + 1 151 const month = date.getMonth() + 1
@@ -168,7 +176,10 @@ export struct ENewspaperPageComponent { @@ -168,7 +176,10 @@ export struct ENewspaperPageComponent {
168 this.windowClass?.on('windowSizeChange', () => { 176 this.windowClass?.on('windowSizeChange', () => {
169 this.screenWidth = this.windowClass?.getWindowProperties()?.windowRect.width || this.displayTool.width 177 this.screenWidth = this.windowClass?.getWindowProperties()?.windowRect.width || this.displayTool.width
170 // 2000折叠屏 TODO DeviceUtil 方法完善了换判断条件 178 // 2000折叠屏 TODO DeviceUtil 方法完善了换判断条件
171 - this.ratio = this.screenWidth > 2000 ? '60%' : '100%' 179 + this.ratio = this.screenWidth > 2000 ? '50%' : '100%'
  180 + let ratio = this.ratio == '100%' ? 1 : 0.5
  181 + this.picWidth = this.screenWidth - vp2px(20)
  182 + this.picWidth = this.picWidth * ratio
172 }); 183 });
173 } 184 }
174 185
@@ -248,7 +259,7 @@ export struct ENewspaperPageComponent { @@ -248,7 +259,7 @@ export struct ENewspaperPageComponent {
248 .id('news_skeleton_id') 259 .id('news_skeleton_id')
249 .width('100%') 260 .width('100%')
250 .height(px2vp(this.picHeight) + 32) 261 .height(px2vp(this.picHeight) + 32)
251 - .margin({ top: 35, left: 10, right: 10 }) 262 + .margin({ top: 59, left: 10, right: 10 })
252 } 263 }
253 264
254 if (this.newspaperListBean && this.newspaperListBean.list && this.newspaperListBean.list.length > 0) { 265 if (this.newspaperListBean && this.newspaperListBean.list && this.newspaperListBean.list.length > 0) {
@@ -259,16 +270,15 @@ export struct ENewspaperPageComponent { @@ -259,16 +270,15 @@ export struct ENewspaperPageComponent {
259 } 270 }
260 .itemSpace(10) 271 .itemSpace(10)
261 .index(this.swiperIndex) 272 .index(this.swiperIndex)
262 - .width(this.ratio)  
263 - // newspaper_shadow 44 高度 e_newspaper_content 35 margin top  
264 - .height(px2vp(this.picHeight) - 44 - 35) 273 + .width(px2vp(this.picWidth))
  274 + .height(px2vp(this.picHeight))
265 .vertical(true) 275 .vertical(true)
266 .autoPlay(false) 276 .autoPlay(false)
267 .cachedCount(1) 277 .cachedCount(1)
268 .indicator(false) 278 .indicator(false)
269 .loop(false) 279 .loop(false)
270 .displayCount(1) 280 .displayCount(1)
271 - .margin({ top: 35, left: 10, right: 10 }) 281 + .margin({ top: 59, left: 10, right: 10 })
272 .id('e_newspaper_content') 282 .id('e_newspaper_content')
273 .alignRules({ 283 .alignRules({
274 top: { anchor: "e_newspaper_top", align: VerticalAlign.Bottom }, 284 top: { anchor: "e_newspaper_top", align: VerticalAlign.Bottom },
@@ -298,6 +308,7 @@ export struct ENewspaperPageComponent { @@ -298,6 +308,7 @@ export struct ENewspaperPageComponent {
298 '滑动查看下一版') 308 '滑动查看下一版')
299 .fontColor(Color.White) 309 .fontColor(Color.White)
300 .fontSize($r('app.float.font_size_14')) 310 .fontSize($r('app.float.font_size_14'))
  311 + .lineHeight(20)
301 Image($r('app.media.icon_next_page')) 312 Image($r('app.media.icon_next_page'))
302 .width($r('app.float.vp_16')) 313 .width($r('app.float.vp_16'))
303 .height($r('app.float.vp_16')) 314 .height($r('app.float.vp_16'))
@@ -305,7 +316,7 @@ export struct ENewspaperPageComponent { @@ -305,7 +316,7 @@ export struct ENewspaperPageComponent {
305 Visibility.Visible) 316 Visibility.Visible)
306 } 317 }
307 .justifyContent(FlexAlign.Center) 318 .justifyContent(FlexAlign.Center)
308 - .margin({ top: $r('app.float.margin_16') }) 319 + .margin({ top: 17 })
309 .alignRules({ 320 .alignRules({
310 top: { anchor: "e_newspaper_shadow", align: VerticalAlign.Bottom }, 321 top: { anchor: "e_newspaper_shadow", align: VerticalAlign.Bottom },
311 middle: { anchor: "__container__", align: HorizontalAlign.Center } 322 middle: { anchor: "__container__", align: HorizontalAlign.Center }
@@ -434,10 +445,15 @@ export struct ENewspaperPageComponent { @@ -434,10 +445,15 @@ export struct ENewspaperPageComponent {
434 } 445 }
435 446
436 private async getNewspaperList() { 447 private async getNewspaperList() {
  448 + // ENewspaperItemComponent .padding({ top:14, right: 10, bottom: 14, left: 10 })
  449 + // 计算图片的内容宽高
  450 + let ratio = this.ratio == '100%' ? 1 : 0.6
  451 + this.itemPicWidth = this.picWidth * ratio - vp2px(20)
  452 + this.itemPicHeight = this.picHeight - vp2px(28)
437 try { 453 try {
438 if (NetworkUtil.isNetConnected()) { 454 if (NetworkUtil.isNetConnected()) {
439 let listBean = 455 let listBean =
440 - await NewspaperViewModel.getNewspaperList(this.calendarDate, this.picWidth + 'x' + this.picHeight) 456 + await NewspaperViewModel.getNewspaperList(this.calendarDate, this.itemPicWidth + 'x' + this.itemPicHeight)
441 this.newspaperListBean = listBean; 457 this.newspaperListBean = listBean;
442 } else { 458 } else {
443 this.showToastTip('网络出小差了,请检查网络后重试') 459 this.showToastTip('网络出小差了,请检查网络后重试')
@@ -116,7 +116,7 @@ export struct Card17Component { @@ -116,7 +116,7 @@ export struct Card17Component {
116 let taskAction: Action = { 116 let taskAction: Action = {
117 type: 'JUMP_DETAIL_PAGE', 117 type: 'JUMP_DETAIL_PAGE',
118 params: { 118 params: {
119 - detailPageType: 17, 119 + detailPageType: 9,
120 contentID: this.contentDTO.objectId, 120 contentID: this.contentDTO.objectId,
121 extra: { 121 extra: {
122 relType: this.contentDTO.relType, 122 relType: this.contentDTO.relType,
1 import { PeopleShipRecommendComponent } from './PeopleShipRecommendComponent'; 1 import { PeopleShipRecommendComponent } from './PeopleShipRecommendComponent';
2 import { PeopleShipMainViewModel } from '../../viewmodel/PeopleShipMainViewModel'; 2 import { PeopleShipMainViewModel } from '../../viewmodel/PeopleShipMainViewModel';
3 -import { HttpUtils } from 'wdNetwork/Index'; 3 +import { HttpUtils } from 'wdNetwork/Index';
4 import { Logger, DateTimeUtils, EmitterEventId, EmitterUtils } from 'wdKit'; 4 import { Logger, DateTimeUtils, EmitterEventId, EmitterUtils } from 'wdKit';
5 import { 5 import {
6 RmhRecommendDTO, 6 RmhRecommendDTO,
@@ -21,27 +21,27 @@ import { FollowListDetailItem } from '../../viewmodel/FollowListDetailItem'; @@ -21,27 +21,27 @@ import { FollowListDetailItem } from '../../viewmodel/FollowListDetailItem';
21 import { CustomPullToRefresh } from '../reusable/CustomPullToRefresh'; 21 import { CustomPullToRefresh } from '../reusable/CustomPullToRefresh';
22 import PageModel from '../../viewmodel/PageModel'; 22 import PageModel from '../../viewmodel/PageModel';
23 import PageAdModel from '../../viewmodel/PageAdvModel'; 23 import PageAdModel from '../../viewmodel/PageAdvModel';
24 -import PageHelper from '../../viewmodel/PageHelper';  
25 import { PeopleShipAttentionContentListTopComponent } from './PeopleShipAttentionContentListTopComponent' 24 import { PeopleShipAttentionContentListTopComponent } from './PeopleShipAttentionContentListTopComponent'
26 import { CardParser } from '../CardParser' 25 import { CardParser } from '../CardParser'
27 import { PeopleShipNoMoreData } from '../reusable/PeopleShipNoMoreData'; 26 import { PeopleShipNoMoreData } from '../reusable/PeopleShipNoMoreData';
  27 +import PageFollowHelper from '../../viewmodel/PageFollowHelper';
  28 +
28 const TAG = 'PeopleShipMainComponent'; 29 const TAG = 'PeopleShipMainComponent';
  30 +
29 /** 31 /**
30 * 人民号 --- 关注 32 * 人民号 --- 关注
31 */ 33 */
32 @Component 34 @Component
33 export struct PeopleShipMainComponent { 35 export struct PeopleShipMainComponent {
34 @State private pageModel: PageModel = new PageModel(); 36 @State private pageModel: PageModel = new PageModel();
35 - @State private pageAdvModel: PageAdModel = new PageAdModel();  
36 // 自动刷新通知 37 // 自动刷新通知
37 @Prop @Watch('onAutoRefresh') autoRefresh: number = 0 38 @Prop @Watch('onAutoRefresh') autoRefresh: number = 0
38 navIndex: number = 0; 39 navIndex: number = 0;
39 pageId: string = ""; 40 pageId: string = "";
40 channelId: string = ""; 41 channelId: string = "";
41 @Link @Watch('onChange') currentTopNavSelectedIndex: number 42 @Link @Watch('onChange') currentTopNavSelectedIndex: number
42 - private scroller: Scroller = new Scroller() 43 + // private scroller: Scroller = new Scroller()
43 private listScroller: Scroller = new Scroller() 44 private listScroller: Scroller = new Scroller()
44 -  
45 @State rmhList: RmhRecommendDTO[] = [] 45 @State rmhList: RmhRecommendDTO[] = []
46 @Provide rmhSelectedList: string[] = [] 46 @Provide rmhSelectedList: string[] = []
47 @State viewType: ViewType = ViewType.LOADING 47 @State viewType: ViewType = ViewType.LOADING
@@ -56,7 +56,6 @@ export struct PeopleShipMainComponent { @@ -56,7 +56,6 @@ export struct PeopleShipMainComponent {
56 @State private currentPage: number = 1 56 @State private currentPage: number = 1
57 @State private isLoading: boolean = false 57 @State private isLoading: boolean = false
58 @State private loadTime: string = '' 58 @State private loadTime: string = ''
59 -  
60 // 页面展示监听 59 // 页面展示监听
61 @Consume @Watch('onPageShowChange') pageShow: number 60 @Consume @Watch('onPageShowChange') pageShow: number
62 @State private pageAttentionChange: boolean = false 61 @State private pageAttentionChange: boolean = false
@@ -86,7 +85,7 @@ export struct PeopleShipMainComponent { @@ -86,7 +85,7 @@ export struct PeopleShipMainComponent {
86 if (this.followList.length == 0) { 85 if (this.followList.length == 0) {
87 CustomPullToRefresh({ 86 CustomPullToRefresh({
88 alldata: this.rmhList, 87 alldata: this.rmhList,
89 - scroller: this.scroller, 88 + scroller: this.listScroller,
90 hasMore: false, 89 hasMore: false,
91 customList: () => { 90 customList: () => {
92 this.ListLayout() 91 this.ListLayout()
@@ -96,7 +95,7 @@ export struct PeopleShipMainComponent { @@ -96,7 +95,7 @@ export struct PeopleShipMainComponent {
96 this.getData(resolve) 95 this.getData(resolve)
97 }, 96 },
98 }) 97 })
99 - }else { 98 + } else {
100 CustomPullToRefresh({ 99 CustomPullToRefresh({
101 alldata: this.attentionList, 100 alldata: this.attentionList,
102 scroller: this.listScroller, 101 scroller: this.listScroller,
@@ -108,19 +107,19 @@ export struct PeopleShipMainComponent { @@ -108,19 +107,19 @@ export struct PeopleShipMainComponent {
108 this.currentPage = 1 107 this.currentPage = 1
109 this.getData(resolve) 108 this.getData(resolve)
110 }, 109 },
111 - onLoadMore:(resolve)=> { 110 + onLoadMore: (resolve) => {
112 if (this.hasMore === false) { 111 if (this.hasMore === false) {
113 - if(resolve) { 112 + if (resolve) {
114 resolve('') 113 resolve('')
115 } 114 }
116 return 115 return
117 } 116 }
118 - if(!this.isLoading && this.hasMore){ 117 + if (!this.isLoading && this.hasMore) {
119 //加载分页数据 118 //加载分页数据
120 this.currentPage++; 119 this.currentPage++;
121 this.getAttentionContentListData(resolve) 120 this.getAttentionContentListData(resolve)
122 - }else {  
123 - if(resolve) { 121 + } else {
  122 + if (resolve) {
124 resolve('') 123 resolve('')
125 } 124 }
126 } 125 }
@@ -137,13 +136,16 @@ export struct PeopleShipMainComponent { @@ -137,13 +136,16 @@ export struct PeopleShipMainComponent {
137 136
138 @Builder 137 @Builder
139 ListLayout() { 138 ListLayout() {
140 - Scroll(this.scroller) {  
141 - // 推荐人民号  
142 - PeopleShipRecommendComponent({  
143 - rmhList: this.rmhList,  
144 - oneKeyFollow: this.oneKeyFollow,  
145 - changeButton: this.changeButton  
146 - }) 139 +
  140 + List({ scroller: this.listScroller }) {
  141 + // 头部关注列表
  142 + ListItem() {
  143 + PeopleShipRecommendComponent({
  144 + rmhList: this.rmhList,
  145 + oneKeyFollow: this.oneKeyFollow,
  146 + changeButton: this.changeButton
  147 + })
  148 + }
147 } 149 }
148 .edgeEffect(EdgeEffect.None) 150 .edgeEffect(EdgeEffect.None)
149 .scrollBar(BarState.Off) 151 .scrollBar(BarState.Off)
@@ -153,20 +155,25 @@ export struct PeopleShipMainComponent { @@ -153,20 +155,25 @@ export struct PeopleShipMainComponent {
153 155
154 @Builder 156 @Builder
155 ListAttentionLayout() { 157 ListAttentionLayout() {
156 - List({scroller: this.listScroller}){ 158 + List({ scroller: this.listScroller }) {
157 // 头部关注列表 159 // 头部关注列表
158 - ListItem(){ 160 + ListItem() {
159 PeopleShipAttentionContentListTopComponent({ 161 PeopleShipAttentionContentListTopComponent({
160 followList: this.followList 162 followList: this.followList
161 }) 163 })
162 } 164 }
  165 +
163 ForEach(this.attentionList, (item: ContentDTO) => { 166 ForEach(this.attentionList, (item: ContentDTO) => {
164 ListItem() { 167 ListItem() {
165 - CardParser({compDTO:new CompDTO, contentDTO: item }) 168 + Column(){
  169 + CardParser({ compDTO: new CompDTO, contentDTO: item })
  170 + Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
  171 + }.width('100%')
  172 +
166 }.width("100%") 173 }.width("100%")
167 .backgroundColor(Color.Transparent) 174 .backgroundColor(Color.Transparent)
168 175
169 - }, (item: ContentDTO, index: number) => item.objectId + index.toString()) 176 + }, (item: ContentDTO, index: number) => item.objectId + index.toString())
170 177
171 // 加载更多 178 // 加载更多
172 ListItem() { 179 ListItem() {
@@ -193,7 +200,8 @@ export struct PeopleShipMainComponent { @@ -193,7 +200,8 @@ export struct PeopleShipMainComponent {
193 } 200 }
194 201
195 onChange() { 202 onChange() {
196 - if (this.navIndex === this.currentTopNavSelectedIndex && (this.viewType == ViewType.LOADING || this.pageAttentionChange)) { 203 + if (this.navIndex === this.currentTopNavSelectedIndex &&
  204 + (this.viewType == ViewType.LOADING || this.pageAttentionChange)) {
197 this.getData(); 205 this.getData();
198 } 206 }
199 } 207 }
@@ -221,7 +229,6 @@ export struct PeopleShipMainComponent { @@ -221,7 +229,6 @@ export struct PeopleShipMainComponent {
221 this.getRmhRecommendInfo(resolve) 229 this.getRmhRecommendInfo(resolve)
222 } else { 230 } else {
223 this.followList = [] 231 this.followList = []
224 - // this.followList = followInfo.list  
225 this.followList.push(...followInfo.list) 232 this.followList.push(...followInfo.list)
226 this.attentionList = [] 233 this.attentionList = []
227 this.currentPage = 1 234 this.currentPage = 1
@@ -289,7 +296,7 @@ export struct PeopleShipMainComponent { @@ -289,7 +296,7 @@ export struct PeopleShipMainComponent {
289 } 296 }
290 //批量查询各类型内容动态数据接口 297 //批量查询各类型内容动态数据接口
291 this.checkContentInteractData(listData.list, resolve) 298 this.checkContentInteractData(listData.list, resolve)
292 - } else { 299 + } else {
293 this.hasMore = false; 300 this.hasMore = false;
294 this.resolveEnd(true, resolve) 301 this.resolveEnd(true, resolve)
295 } 302 }
@@ -319,7 +326,7 @@ export struct PeopleShipMainComponent { @@ -319,7 +326,7 @@ export struct PeopleShipMainComponent {
319 this.resolveEnd(true, resolve) 326 this.resolveEnd(true, resolve)
320 list.forEach((element: ContentDTO) => { 327 list.forEach((element: ContentDTO) => {
321 // 获取 interactData 数据 328 // 获取 interactData 数据
322 - if (listData && listData.length > 0) { 329 + if (listData && listData.length > 0) {
323 const objc = listData.find((interactModel: InteractDataDTO) => { 330 const objc = listData.find((interactModel: InteractDataDTO) => {
324 return element.objectId == interactModel.contentId 331 return element.objectId == interactModel.contentId
325 }) 332 })
@@ -343,7 +350,7 @@ export struct PeopleShipMainComponent { @@ -343,7 +350,7 @@ export struct PeopleShipMainComponent {
343 if (resolve) { 350 if (resolve) {
344 if (this.currentPage == 1 && isTop) { 351 if (this.currentPage == 1 && isTop) {
345 resolve('已更新至最新') 352 resolve('已更新至最新')
346 - }else { 353 + } else {
347 resolve('') 354 resolve('')
348 } 355 }
349 } 356 }
@@ -357,12 +364,13 @@ export struct PeopleShipMainComponent { @@ -357,12 +364,13 @@ export struct PeopleShipMainComponent {
357 364
358 // 说是首页必须要调用 365 // 说是首页必须要调用
359 async getInitData() { 366 async getInitData() {
360 - Logger.debug('PeopleShipMainComponent', `getData id: ${this.pageId} , ${this.channelId} , navIndex: ${this.currentTopNavSelectedIndex}`); 367 + Logger.debug('PeopleShipMainComponent',
  368 + `getData id: ${this.pageId} , ${this.channelId} , navIndex: ${this.currentTopNavSelectedIndex}`);
361 this.pageModel.pageId = this.pageId; 369 this.pageModel.pageId = this.pageId;
362 this.pageModel.groupId = this.pageId; 370 this.pageModel.groupId = this.pageId;
363 this.pageModel.channelId = this.channelId; 371 this.pageModel.channelId = this.channelId;
364 this.pageModel.currentPage = 1; 372 this.pageModel.currentPage = 1;
365 - PageHelper.getInitData(this.pageModel, this.pageAdvModel) 373 + PageFollowHelper.getInitData(this.pageModel)
366 } 374 }
367 375
368 // 点击一键关注 376 // 点击一键关注
@@ -388,7 +396,7 @@ export struct PeopleShipMainComponent { @@ -388,7 +396,7 @@ export struct PeopleShipMainComponent {
388 // 获取列表数据 396 // 获取列表数据
389 let objects = new AttentionBatchDTO() 397 let objects = new AttentionBatchDTO()
390 this.rmhList.forEach((element: RmhRecommendDTO) => { 398 this.rmhList.forEach((element: RmhRecommendDTO) => {
391 - if ( this.rmhSelectedList.indexOf(element.creatorId) != -1) { 399 + if (this.rmhSelectedList.indexOf(element.creatorId) != -1) {
392 const creator = new CreatorDTO(element.userType, element.userId, element.creatorId) 400 const creator = new CreatorDTO(element.userType, element.userId, element.creatorId)
393 objects.creators.push(creator) 401 objects.creators.push(creator)
394 } 402 }
@@ -413,7 +421,7 @@ export struct PeopleShipMainComponent { @@ -413,7 +421,7 @@ export struct PeopleShipMainComponent {
413 421
414 // 页面展示监听 422 // 页面展示监听
415 onPageShowChange() { 423 onPageShowChange() {
416 - if (this.navIndex === this.currentTopNavSelectedIndex && this.pageAttentionChange ) { 424 + if (this.navIndex === this.currentTopNavSelectedIndex && this.pageAttentionChange) {
417 this.getData() 425 this.getData()
418 } 426 }
419 } 427 }
@@ -56,7 +56,6 @@ export struct PeopleShipRecommendComponent { @@ -56,7 +56,6 @@ export struct PeopleShipRecommendComponent {
56 .width('100%') 56 .width('100%')
57 .alignSelf(ItemAlign.Start) 57 .alignSelf(ItemAlign.Start)
58 .margin({ 58 .margin({
59 - top: '-50vp',  
60 bottom: '10vp' 59 bottom: '10vp'
61 }) 60 })
62 61
@@ -294,11 +294,12 @@ export struct SearchResultContentComponent { @@ -294,11 +294,12 @@ export struct SearchResultContentComponent {
294 CardParser({compDTO:new CompDTO, contentDTO: item }) 294 CardParser({compDTO:new CompDTO, contentDTO: item })
295 } 295 }
296 if (index != this.data.totalCount() - 1) { 296 if (index != this.data.totalCount() - 1) {
297 - Divider()  
298 - .width('100%')  
299 - .height('1lpx')  
300 - .color($r('app.color.color_F5F5F5'))  
301 - .strokeWidth('1lpx') 297 + Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
  298 + // Divider()
  299 + // .width('100%')
  300 + // .height('1lpx')
  301 + // .color($r('app.color.color_F5F5F5'))
  302 + // .strokeWidth('1lpx')
302 } 303 }
303 } 304 }
304 } 305 }
  1 +import { CompDTO, ContentDTO, InteractDataDTO, LiveReviewDTO, LiveRoomDataBean, PageDTO, PageInfoDTO } from 'wdBean';
  2 +import { CompStyle, ViewType } from 'wdConstant/Index';
  3 +import { CollectionUtils, DateTimeUtils, LazyDataSource, Logger, NetworkUtil, StringUtils, ToastUtils } from 'wdKit';
  4 +import { closeRefresh } from '../utils/PullDownRefresh';
  5 +import PageModel from './PageModel';
  6 +import PageViewModel from './PageViewModel';
  7 +import { promptAction } from '@kit.ArkUI';
  8 +import { CompAdvBean } from 'wdBean/src/main/ets/bean/adv/AdvsRuleBean';
  9 +import PageAdModel from './PageAdvModel';
  10 +import { ArrayList } from '@kit.ArkTS';
  11 +import { WDViewDefaultType } from '../components/view/EmptyComponent';
  12 +import { CompAdvMatInfoBean } from 'wdBean/src/main/ets/bean/adv/CompAdvInfoBean';
  13 +import { BaseDTO } from 'wdBean/src/main/ets/bean/component/BaseDTO';
  14 +import { viewBlogInsightIntentShare, ActionMode } from '../utils/InsightIntentShare'
  15 +import { common } from '@kit.AbilityKit';
  16 +import { CacheData } from 'wdNetwork/Index';
  17 +import { closeLoadMore } from '../utils/PullUpLoadMore';
  18 +
  19 +const TAG = 'PageHelper';
  20 +
  21 +
  22 +/**
  23 + * 处理返回后的数据
  24 + */
  25 +export class PageFollowHelper {
  26 + private refreshUIEnd(pageModel: PageModel, isRefreshSuccess: boolean) {
  27 + if (pageModel.loadStrategy != 2) {
  28 + return
  29 + }
  30 + closeRefresh(pageModel, isRefreshSuccess)
  31 + }
  32 +
  33 +
  34 +
  35 + /**
  36 + * 进页面请求数据
  37 + */
  38 + async getInitData(pageModel: PageModel) {
  39 + pageModel.loadStrategy = 1
  40 + let netStatus = NetworkUtil.isNetConnected()
  41 + if (netStatus) {
  42 + this.getPageInfo(pageModel)
  43 + } else if (pageModel.compList.size() > 0) {
  44 + // 加载缓存数据了,不用无网络提示
  45 + } else {
  46 + pageModel.viewType = ViewType.EMPTY;
  47 + pageModel.emptyType = WDViewDefaultType.WDViewDefaultType_NoNetwork;
  48 + }
  49 + }
  50 +
  51 + getPageInfo(pageModel: PageModel) {
  52 + pageModel.currentPage = 1;
  53 + Logger.debug(TAG, 'getPageInfo')
  54 + PageViewModel.getPageInfo(pageModel.pageId).then(pageInfo => {
  55 + Logger.debug(TAG, 'getPageInfo back: ' + JSON.stringify(pageInfo))
  56 + if (pageInfo == null) {
  57 + pageModel.viewType = ViewType.EMPTY;
  58 + pageModel.emptyType = WDViewDefaultType.WDViewDefaultType_NoContent1;
  59 + return;
  60 + }
  61 + pageModel.pageInfo = pageInfo;
  62 +
  63 + Logger.debug(TAG, 'getPageInfo go on')
  64 + }).catch(() => {
  65 + this.refreshUIEnd(pageModel, false)
  66 + if (this.isPageLoaded(pageModel)) {
  67 + return
  68 + }
  69 + pageModel.viewType = ViewType.EMPTY;
  70 + pageModel.emptyType = WDViewDefaultType.WDViewDefaultType_ContentFailed;
  71 + })
  72 + }
  73 +
  74 + private isPageLoaded(pageModel: PageModel) {
  75 + if (pageModel.compList.size() > 0) {
  76 + return true
  77 + }
  78 + return false
  79 + }
  80 +}
  81 +
  82 +
  83 +
  84 +
  85 +let pageHelper = new PageFollowHelper();
  86 +
  87 +export default pageHelper as PageFollowHelper;
@@ -4,7 +4,7 @@ import { ContentType } from 'wdRouter/Index'; @@ -4,7 +4,7 @@ import { ContentType } from 'wdRouter/Index';
4 4
5 export class DeepLinkUtil { 5 export class DeepLinkUtil {
6 6
7 - private static DEEP_LINK_PREFIX = "rmrbapp:rmrb.app/openwith" 7 + private static DEEP_LINK_PREFIX = "rmrbapp://rmrb.app/openwith"
8 8
9 static generateDeepLinkWithConent(content: ContentDetailDTO): string { 9 static generateDeepLinkWithConent(content: ContentDetailDTO): string {
10 10
@@ -23,7 +23,7 @@ export class DeepLinkUtil { @@ -23,7 +23,7 @@ export class DeepLinkUtil {
23 private static generate(contentType: number, contentId?: string, relId?: string, link?: string): string { 23 private static generate(contentType: number, contentId?: string, relId?: string, link?: string): string {
24 let deeplink = DeepLinkUtil.DEEP_LINK_PREFIX 24 let deeplink = DeepLinkUtil.DEEP_LINK_PREFIX
25 25
26 - let pubParam = `&contentId=${contentId}}&relId=${relId}&skipType=1` 26 + let pubParam = `&contentId=${contentId}&relId=${relId}&skipType=1`
27 27
28 let type: ContentType = Number(contentType) 28 let type: ContentType = Number(contentType)
29 switch (type) { 29 switch (type) {
@@ -38,7 +38,7 @@ export class DeepLinkUtil { @@ -38,7 +38,7 @@ export class DeepLinkUtil {
38 deeplink += "?type=article&subType=h5" 38 deeplink += "?type=article&subType=h5"
39 deeplink += "&url=" + encodeURIComponent(link) 39 deeplink += "&url=" + encodeURIComponent(link)
40 } else { 40 } else {
41 - deeplink += "type=article&subType=h5_template_article" 41 + deeplink += "?type=article&subType=h5_template_article"
42 } 42 }
43 break 43 break
44 case ContentType.DynamicImageText: 44 case ContentType.DynamicImageText:
1 import { formBindingData, FormExtensionAbility, formInfo, formProvider } from '@kit.FormKit'; 1 import { formBindingData, FormExtensionAbility, formInfo, formProvider } from '@kit.FormKit';
2 import { Want } from '@kit.AbilityKit'; 2 import { Want } from '@kit.AbilityKit';
3 -import { Logger, NetworkManager, SPHelper, StringUtils } from 'wdKit/Index'; 3 +import { FileUtils, Logger, NetworkManager, SPHelper, StringUtils } from 'wdKit/Index';
4 import { BusinessError } from '@kit.BasicServicesKit'; 4 import { BusinessError } from '@kit.BasicServicesKit';
5 -import { FormDataType, NewspaperDataFetcher } from './NewspaperDataFetcher'; 5 +import { NewspaperDataFetcher } from './NewspaperDataFetcher';
6 import { JSON } from '@kit.ArkTS'; 6 import { JSON } from '@kit.ArkTS';
7 -import { FormNewspaperPaperType } from '../dailynewspaperwidget/common/NewspaperWidgetData'; 7 +import { FormNewspaperData, FormNewspaperPaperType } from '../dailynewspaperwidget/common/NewspaperWidgetData';
8 import { HostEnum, HostManager, WDHttp } from 'wdNetwork/Index'; 8 import { HostEnum, HostManager, WDHttp } from 'wdNetwork/Index';
  9 +import fs from '@ohos.file.fs';
9 10
10 const TAG = "DailyNewspaperFormAbility" 11 const TAG = "DailyNewspaperFormAbility"
11 12
12 export default class DailyNewspaperFormAbility extends FormExtensionAbility { 13 export default class DailyNewspaperFormAbility extends FormExtensionAbility {
  14 + lastDatas: Record<string, FormNewspaperData> = {}
  15 +
13 onAddForm(want: Want) { 16 onAddForm(want: Want) {
14 Logger.debug(TAG, "onAddForm with " + JSON.stringify(want)) 17 Logger.debug(TAG, "onAddForm with " + JSON.stringify(want))
15 18
16 this.initApp() 19 this.initApp()
17 - 20 +
18 if (want.parameters) { 21 if (want.parameters) {
19 let formId = want.parameters[formInfo.FormParam.IDENTITY_KEY] as string 22 let formId = want.parameters[formInfo.FormParam.IDENTITY_KEY] as string
20 let isTempCard = want.parameters[formInfo.FormParam.TEMPORARY_KEY] as boolean 23 let isTempCard = want.parameters[formInfo.FormParam.TEMPORARY_KEY] as boolean
21 if (isTempCard === false) { // 如果为常态卡片,直接进行信息持久化 24 if (isTempCard === false) { // 如果为常态卡片,直接进行信息持久化
22 25
23 - Logger.debug(TAG, "开始刷新数据");  
24 - NewspaperDataFetcher.refreshDailyPaper().then((data) => {  
25 -  
26 - let formData = formBindingData.createFormBindingData(data);  
27 - formProvider.updateForm(formId, formData).catch((err: BusinessError) => {  
28 - Logger.debug(TAG, ` xFailed to updateForm. Code: ${err.code}, message: ${err.message}`);  
29 - });  
30 - }) 26 + this.fetchAndRefreshData(formId)
31 } 27 }
32 } 28 }
33 29
34 - let obj: FormDataType = {} 30 + let obj: FormNewspaperData = {} as FormNewspaperData
35 obj.paperType = FormNewspaperPaperType.unknown 31 obj.paperType = FormNewspaperPaperType.unknown
36 let formData = formBindingData.createFormBindingData(obj); 32 let formData = formBindingData.createFormBindingData(obj);
37 return formData; 33 return formData;
@@ -45,13 +41,9 @@ export default class DailyNewspaperFormAbility extends FormExtensionAbility { @@ -45,13 +41,9 @@ export default class DailyNewspaperFormAbility extends FormExtensionAbility {
45 onUpdateForm(formId: string) { 41 onUpdateForm(formId: string) {
46 // 若卡片支持定时更新/定点更新/卡片使用方主动请求更新功能,则提供方需要重写该方法以支持数据更新 42 // 若卡片支持定时更新/定点更新/卡片使用方主动请求更新功能,则提供方需要重写该方法以支持数据更新
47 Logger.debug(TAG, 'onUpdateForm ' + formId); 43 Logger.debug(TAG, 'onUpdateForm ' + formId);
48 - NewspaperDataFetcher.refreshDailyPaper().then((data) => {  
49 44
50 - let formData = formBindingData.createFormBindingData(data);  
51 - formProvider.updateForm(formId, formData).catch((err: BusinessError) => {  
52 - Logger.debug(TAG, ` xFailed to updateForm. Code: ${err.code}, message: ${err.message}`);  
53 - });  
54 - }) 45 + this.initApp()
  46 + this.fetchAndRefreshData(formId)
55 } 47 }
56 48
57 onFormEvent(formId: string, message: string) { 49 onFormEvent(formId: string, message: string) {
@@ -61,7 +53,9 @@ export default class DailyNewspaperFormAbility extends FormExtensionAbility { @@ -61,7 +53,9 @@ export default class DailyNewspaperFormAbility extends FormExtensionAbility {
61 53
62 onRemoveForm(formId: string) { 54 onRemoveForm(formId: string) {
63 // 当对应的卡片删除时触发的回调,入参是被删除的卡片ID 55 // 当对应的卡片删除时触发的回调,入参是被删除的卡片ID
64 - Logger.debug(TAG, 'onRemoveForm'); 56 + Logger.debug(TAG, 'onRemoveForm / formId: ' + formId);
  57 + let data = this.lastDatas[formId]
  58 + NewspaperDataFetcher.closeFilesWith(data)
65 } 59 }
66 60
67 // onConfigurationUpdate(config: Configuration) { 61 // onConfigurationUpdate(config: Configuration) {
@@ -75,6 +69,32 @@ export default class DailyNewspaperFormAbility extends FormExtensionAbility { @@ -75,6 +69,32 @@ export default class DailyNewspaperFormAbility extends FormExtensionAbility {
75 return formInfo.FormState.READY; 69 return formInfo.FormState.READY;
76 } 70 }
77 71
  72 + fetchAndRefreshData(formId: string) {
  73 + Logger.debug(TAG, "开始刷新数据");
  74 + NewspaperDataFetcher.refreshDailyPaper().then(async (data) => {
  75 +
  76 + let formData = formBindingData.createFormBindingData(data);
  77 + formProvider.updateForm(formId, formData).then(() => {
  78 + this.lastDatas[formId] = data
  79 + }).catch((err: BusinessError) => {
  80 + Logger.debug(TAG, ` xFailed to updateForm. Code: ${err.code}, message: ${err.message}`);
  81 + });
  82 +
  83 + let fileDir = this.context.getApplicationContext().filesDir + "/widget-daily-newspaper"
  84 + await FileUtils.makeDirIfNotExsit(fileDir)
  85 +
  86 + NewspaperDataFetcher.dealWithPictures(data, formId, fileDir, (data) => {
  87 + Logger.debug(TAG, `refresh ui with new pictuers`);
  88 + let formData = formBindingData.createFormBindingData(data);
  89 + formProvider.updateForm(formId, formData).then(() => {
  90 + this.lastDatas[formId] = data
  91 + }).catch((err: BusinessError) => {
  92 + Logger.error(TAG, ` xFailed to updateForm. Code: ${err.code}, message: ${err.message}`);
  93 + });
  94 + })
  95 + })
  96 + }
  97 +
78 initApp() { 98 initApp() {
79 // KV存储 99 // KV存储
80 SPHelper.init(this.context); 100 SPHelper.init(this.context);
1 import { CompInfoBean, ContentDTO, PageInfoBean } from 'wdBean/Index'; 1 import { CompInfoBean, ContentDTO, PageInfoBean } from 'wdBean/Index';
2 import { MorningEveningViewModel } from 'wdComponent/Index'; 2 import { MorningEveningViewModel } from 'wdComponent/Index';
3 -import { Logger } from 'wdKit/Index'; 3 +import { CrptoUtils, FileUtils, Logger } from 'wdKit/Index';
4 import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork/Index'; 4 import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork/Index';
5 import { DeepLinkUtil } from 'wdShare/Index' 5 import { DeepLinkUtil } from 'wdShare/Index'
6 -import { FormNewspaperPaperType, FormNewspaperPaperInfo, FormNewspaperPaperContent } from "../dailynewspaperwidget/common/NewspaperWidgetData" 6 +import { FormNewspaperPaperType, FormNewspaperPaperInfo, FormNewspaperPaperContent,
  7 + FormNewspaperData } from "../dailynewspaperwidget/common/NewspaperWidgetData"
  8 +import { http } from '@kit.NetworkKit';
  9 +import fs from '@ohos.file.fs';
  10 +import { BusinessError } from '@kit.BasicServicesKit';
  11 +import { JSON } from '@kit.ArkTS';
7 12
8 const TAG = "NewspaperDataFetcher" 13 const TAG = "NewspaperDataFetcher"
9 14
10 -export type FormDataType = Record<string, FormNewspaperPaperType | FormNewspaperPaperInfo | FormNewspaperPaperContent[]> 15 +// export type FormDataType = Record<string, FormNewspaperPaperType | FormNewspaperPaperInfo | FormNewspaperPaperContent[]>
11 16
12 export class NewspaperDataFetcher { 17 export class NewspaperDataFetcher {
13 18
14 - public static async refreshDailyPaper(): Promise<FormDataType> {  
15 - return new Promise<FormDataType>(async (reslove, fail) => { 19 + public static async refreshDailyPaper(): Promise<FormNewspaperData> {
  20 + return new Promise<FormNewspaperData>(async (reslove, fail) => {
16 21
17 - let data: FormDataType = { 'paperType': FormNewspaperPaperType.unknown } 22 + let data: FormNewspaperData = new FormNewspaperData()
18 data.paperInfo = { showLeftImage: false } 23 data.paperInfo = { showLeftImage: false }
19 24
20 try { 25 try {
21 let page: PageInfoBean = await MorningEveningViewModel.getDailyPaperTopic() 26 let page: PageInfoBean = await MorningEveningViewModel.getDailyPaperTopic()
22 - data.paperType = page.topicInfo?.frontFlag || FormNewspaperPaperType.unknown 27 + data.paperType = page.topicInfo?.topicPattern || FormNewspaperPaperType.unknown
23 28
24 let currentTime = new Date().getTime() 29 let currentTime = new Date().getTime()
25 let compInfo = await MorningEveningViewModel.getMorningEveningCompInfo( 30 let compInfo = await MorningEveningViewModel.getMorningEveningCompInfo(
@@ -29,7 +34,7 @@ export class NewspaperDataFetcher { @@ -29,7 +34,7 @@ export class NewspaperDataFetcher {
29 page.topicInfo?.topicId 34 page.topicInfo?.topicId
30 ) 35 )
31 36
32 - if (page.topicInfo.frontLinkObject) { 37 + if (page.topicInfo?.frontFlag && page.topicInfo.frontLinkObject) {
33 data.paperInfo.showLeftImage = true 38 data.paperInfo.showLeftImage = true
34 data.paperInfo.leftImageUrl = page.topicInfo.frontLinkObject.coverUrl 39 data.paperInfo.leftImageUrl = page.topicInfo.frontLinkObject.coverUrl
35 data.paperInfo.leftTitle = page.topicInfo.frontLinkObject.title 40 data.paperInfo.leftTitle = page.topicInfo.frontLinkObject.title
@@ -60,7 +65,7 @@ export class NewspaperDataFetcher { @@ -60,7 +65,7 @@ export class NewspaperDataFetcher {
60 }) 65 })
61 } 66 }
62 67
63 - static fakeData(): FormDataType { 68 + static fakeData(): FormNewspaperData {
64 let data : FormNewspaperPaperContent = { 69 let data : FormNewspaperPaperContent = {
65 title: "标题标题标题标题标题标题标题标题", 70 title: "标题标题标题标题标题标题标题标题",
66 coverUrl: "https://" 71 coverUrl: "https://"
@@ -72,6 +77,135 @@ export class NewspaperDataFetcher { @@ -72,6 +77,135 @@ export class NewspaperDataFetcher {
72 leftTitle: "leftTitleleftTitleleftTitleleftTitleleftTitleleftTitle" 77 leftTitle: "leftTitleleftTitleleftTitleleftTitleleftTitleleftTitle"
73 }, 78 },
74 "paperContents": [data, data, data] 79 "paperContents": [data, data, data]
  80 + } as FormNewspaperData
  81 + }
  82 +
  83 + static dealWithPictures(data: FormNewspaperData, formId: string ,tempDir: string, refreshCallback:(data: FormNewspaperData) => void) {
  84 +
  85 + let donwloadCount = data.paperContents.filter((value) => {
  86 + return value.coverUrl && value.coverUrl.length > 0
  87 + }).length
  88 +
  89 + let fileFDs: Record<string, string | number> = {};
  90 + if (data.paperInfo.leftImageUrl) {
  91 + donwloadCount += 1
  92 +
  93 + CrptoUtils.md5(data.paperInfo.leftImageUrl).then((md5String) => {
  94 +
  95 + const fileName = formId + "file" + md5String;
  96 + const filePath = tempDir + "/" + fileName
  97 + NewspaperDataFetcher.downloadUrlToPath(data.paperInfo.leftImageUrl!, filePath).then(() => {
  98 + let file = fs.openSync(filePath)
  99 + fileFDs[fileName] = file.fd
  100 + data.paperInfo.localLeftImageFileName = fileName
  101 + data.formImages = fileFDs
  102 +
  103 + if (--donwloadCount == 0) { refreshCallback(data) }
  104 + }).catch((e : BusinessError) => {
  105 + Logger.debug(TAG, "download file failed.");
  106 + if (--donwloadCount == 0) { refreshCallback(data) }
  107 + })
  108 + }).catch((e: BusinessError) => {
  109 + if (--donwloadCount == 0) { refreshCallback(data) }
  110 + })
  111 + }
  112 +
  113 +
  114 + for (let index = 0; index < data.paperContents.length; index++) {
  115 + const content = data.paperContents[index];
  116 + if (!content.coverUrl || content.coverUrl.length == 0) {
  117 + continue
  118 + }
  119 +
  120 + CrptoUtils.md5(content.coverUrl).then((md5String) => {
  121 + const fileName = formId + "file" + md5String;
  122 + const filePath = tempDir + "/" + fileName
  123 + NewspaperDataFetcher.downloadUrlToPath(content.coverUrl!, filePath).then(() => {
  124 + Logger.debug(TAG, "open file for display ");
  125 + let file = fs.openSync(filePath)
  126 + fileFDs[fileName] = file.fd
  127 + data.paperContents[index].localCoverFileName = fileName
  128 + data.formImages = fileFDs
  129 +
  130 + if (--donwloadCount == 0) { refreshCallback(data) }
  131 + }).catch((e : BusinessError) => {
  132 + Logger.debug(TAG, "download file failed." + JSON.stringify(e));
  133 + if (--donwloadCount == 0) { refreshCallback(data) }
  134 + })
  135 + }).catch((e: BusinessError) => {
  136 + if (--donwloadCount == 0) { refreshCallback(data) }
  137 + })
75 } 138 }
76 } 139 }
  140 +
  141 + static closeFilesWith(data?: FormNewspaperData) {
  142 + if (data && data.formImages) {
  143 + for (const obj of Object.entries(data.formImages)) {
  144 + const fileName = obj[0]
  145 + let fd: number = obj[1] as number
  146 + fs.close(fd)
  147 + }
  148 + }
  149 + }
  150 +
  151 + static downloadUrlToPath(url: string, toFilePath: string): Promise<void> {
  152 + Logger.debug(TAG, "will donwload url:" + url + " ======> " + toFilePath);
  153 +
  154 + return new Promise((reslove, fail) => {
  155 +
  156 + FileUtils.fileExsit(toFilePath).then((exsit: boolean) => {
  157 + if (exsit) {
  158 + Logger.debug(TAG, "file is exsit. " + toFilePath);
  159 + reslove()
  160 + return
  161 + }
  162 +
  163 + NewspaperDataFetcher.downloadUrlToPathWithout(url, toFilePath).then(() => {
  164 + reslove()
  165 + }).catch((e: BusinessError) => {
  166 + fail(e)
  167 + })
  168 + }).catch((e: BusinessError) => {
  169 + NewspaperDataFetcher.downloadUrlToPathWithout(url, toFilePath).then(() => {
  170 + reslove()
  171 + }).catch((e: BusinessError) => {
  172 + fail(e)
  173 + })
  174 + })
  175 + })
  176 + }
  177 +
  178 + static downloadUrlToPathWithout(url: string, toFilePath: string): Promise<void> {
  179 + Logger.debug(TAG, "will donwload url:" + url + " ======> " + toFilePath);
  180 +
  181 + return new Promise((reslove, fail) => {
  182 +
  183 + let httpRequest = http.createHttp()
  184 + httpRequest.request(url, (err, data) => {
  185 +
  186 + if (!err && data.responseCode == http.ResponseCode.OK) {
  187 + let imgFile = fs.openSync(toFilePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
  188 + let wroteLength = 0
  189 + fs.write(imgFile.fd, data.result as ArrayBuffer).then((writeLen: number) => {
  190 + Logger.debug(TAG, "write data to file succeed and size is:" + writeLen);
  191 + wroteLength = writeLen
  192 + }).catch((err: BusinessError) => {
  193 + Logger.error(TAG, "write data to file failed with error message: " + err.message + ", error code: " + err.code);
  194 + }).finally(() => {
  195 + fs.closeSync(imgFile);
  196 + httpRequest.destroy()
  197 +
  198 + wroteLength > 0 ? reslove() : fail("failed")
  199 + });
  200 + return
  201 + }
  202 +
  203 + httpRequest.destroy()
  204 + fail("failed")
  205 + });
  206 +
  207 + })
  208 + }
  209 +
  210 +
77 } 211 }
@@ -11,6 +11,8 @@ export class FormNewspaperPaperInfo { @@ -11,6 +11,8 @@ export class FormNewspaperPaperInfo {
11 showLeftImage: boolean = false 11 showLeftImage: boolean = false
12 12
13 leftImageUrl?: string 13 leftImageUrl?: string
  14 + localLeftImageFileName?: ResourceStr // 传递图片用
  15 + localLeftImageFileFD? : number // 传递图片用
14 leftTitle?: string 16 leftTitle?: string
15 leftDeepLink?: string 17 leftDeepLink?: string
16 18
@@ -20,5 +22,15 @@ export class FormNewspaperPaperInfo { @@ -20,5 +22,15 @@ export class FormNewspaperPaperInfo {
20 export class FormNewspaperPaperContent { 22 export class FormNewspaperPaperContent {
21 title: string = "" 23 title: string = ""
22 coverUrl?: string 24 coverUrl?: string
  25 + localCoverFileName?: ResourceStr // 传递图片用
  26 + localCoverFileFD? : number // 传递图片用
23 deepLink: string = "" 27 deepLink: string = ""
24 } 28 }
  29 +
  30 +export class FormNewspaperData {
  31 + paperType: FormNewspaperPaperType = FormNewspaperPaperType.unknown
  32 + paperInfo: FormNewspaperPaperInfo = {} as FormNewspaperPaperInfo
  33 + paperContents: FormNewspaperPaperContent[] = []
  34 +
  35 + formImages: Record<string, string | number> = {}
  36 +}
@@ -43,8 +43,8 @@ struct DailyNewspaperWidgetCard { @@ -43,8 +43,8 @@ struct DailyNewspaperWidgetCard {
43 43
44 @Builder leftImageView() { 44 @Builder leftImageView() {
45 Stack({ alignContent: Alignment.Bottom }) { 45 Stack({ alignContent: Alignment.Bottom }) {
46 - Image(this.paperInfo.leftImageUrl)  
47 - // Image($r("app.media.desktop_card_comp_place_holder_16_9")) 46 + Image("memory://" + this.paperInfo.localLeftImageFileName)
  47 + // Image(this.paperInfo.leftImageUrl)
48 .alt($r("app.media.desktop_card_comp_place_holder_16_9")) 48 .alt($r("app.media.desktop_card_comp_place_holder_16_9"))
49 .objectFit(ImageFit.Cover) 49 .objectFit(ImageFit.Cover)
50 .aspectRatio(87/116) 50 .aspectRatio(87/116)
@@ -109,8 +109,8 @@ struct ContentCellView { @@ -109,8 +109,8 @@ struct ContentCellView {
109 bottom: this.hasImage ? 0 : 6}) 109 bottom: this.hasImage ? 0 : 6})
110 110
111 if (this.hasImage) { 111 if (this.hasImage) {
112 - Image(this.content.coverUrl)  
113 - // Image($r("app.media.desktop_card_comp_place_holder_3_4")) 112 + Image("memory://" + this.content.localCoverFileName)
  113 + // Image(this.content.coverUrl)
114 .alt($r("app.media.desktop_card_comp_place_holder_3_4")) 114 .alt($r("app.media.desktop_card_comp_place_holder_3_4"))
115 .objectFit(ImageFit.Cover) 115 .objectFit(ImageFit.Cover)
116 .height(40) 116 .height(40)
@@ -151,14 +151,12 @@ function jumpWithDeepLink(deepLink: string, component: Object) { @@ -151,14 +151,12 @@ function jumpWithDeepLink(deepLink: string, component: Object) {
151 if (deepLink.length == 0) { 151 if (deepLink.length == 0) {
152 return 152 return
153 } 153 }
154 - const deepLinkKey: string = NewspaperWidgetCommon.JumpParam.DeepLinkKey  
155 - const fromDailyNewspaperKey: string = NewspaperWidgetCommon.JumpParam.FromNewspaperWidgetKey  
156 postCardAction(component, { 154 postCardAction(component, {
157 action: NewspaperWidgetCommon.PosterCardAction.ActionRouter, 155 action: NewspaperWidgetCommon.PosterCardAction.ActionRouter,
158 abilityName: NewspaperWidgetCommon.PosterCardAction.MainAbilityName, 156 abilityName: NewspaperWidgetCommon.PosterCardAction.MainAbilityName,
159 params: { 157 params: {
160 - deepLinkKey: deepLink,  
161 - fromDailyNewspaperKey: true 158 + "newspaper.widget.jump.deeplink": deepLink,
  159 + "newspaper.widget.jump.fromNewspaperWidget": 1
162 } 160 }
163 }); 161 });
164 } 162 }
@@ -53,7 +53,7 @@ export struct BottomNavigationComponent { @@ -53,7 +53,7 @@ export struct BottomNavigationComponent {
53 // 自动刷新触发(双击tab自动刷新) 53 // 自动刷新触发(双击tab自动刷新)
54 @State autoRefresh: number = 0 54 @State autoRefresh: number = 0
55 // 顶导数据,从接口获取 TODO 顶导业务逻辑没看懂,暂时不替换顶导list。频道管理数据待梳理 55 // 顶导数据,从接口获取 TODO 顶导业务逻辑没看懂,暂时不替换顶导list。频道管理数据待梳理
56 - @State topNavMap: Record<string, TopNavDTO[]> = {} 56 + // @State topNavMap: Record<string, TopNavDTO[]> = {}
57 57
58 async aboutToAppear() { 58 async aboutToAppear() {
59 Logger.info(TAG, `aboutToAppear currentNavIndex: ${this.currentNavIndex}`); 59 Logger.info(TAG, `aboutToAppear currentNavIndex: ${this.currentNavIndex}`);
@@ -12,13 +12,14 @@ import { DeviceUtil, @@ -12,13 +12,14 @@ import { DeviceUtil,
12 UmengStats } from 'wdKit/Index' 12 UmengStats } from 'wdKit/Index'
13 import { LoginModule } from 'wdLogin/Index' 13 import { LoginModule } from 'wdLogin/Index'
14 import { HostEnum, HostManager, WDHttp } from 'wdNetwork/Index' 14 import { HostEnum, HostManager, WDHttp } from 'wdNetwork/Index'
15 -import { registerRouter } from 'wdRouter/Index' 15 +import { AppInnerLink, registerRouter } from 'wdRouter/Index'
16 import { TrackingModule } from 'wdTracking/Index' 16 import { TrackingModule } from 'wdTracking/Index'
17 import { JSON } from '@kit.ArkTS' 17 import { JSON } from '@kit.ArkTS'
18 import app from '@system.app' 18 import app from '@system.app'
19 import { GetuiPush, HWLocationUtils } from 'wdHwAbility/Index' 19 import { GetuiPush, HWLocationUtils } from 'wdHwAbility/Index'
20 import { ImageKnife, ImageKnifeGlobal } from '@ohos/imageknife' 20 import { ImageKnife, ImageKnifeGlobal } from '@ohos/imageknife'
21 import { webview } from '@kit.ArkWeb' 21 import { webview } from '@kit.ArkWeb'
  22 +import { NewspaperWidgetCommon } from '../dailynewspaperwidget/common/NewspaperWidgetCommon'
22 23
23 const TAG = "[StartupManager]" 24 const TAG = "[StartupManager]"
24 25
@@ -26,6 +27,7 @@ const TAG = "[StartupManager]" @@ -26,6 +27,7 @@ const TAG = "[StartupManager]"
26 export class StartupManager { 27 export class StartupManager {
27 28
28 private context?: common.UIAbilityContext 29 private context?: common.UIAbilityContext
  30 + private lastStartupWant?: Want
29 31
30 private constructor() { 32 private constructor() {
31 } 33 }
@@ -74,10 +76,14 @@ export class StartupManager { @@ -74,10 +76,14 @@ export class StartupManager {
74 // 通知栏点击后启动 76 // 通知栏点击后启动
75 GetuiPush.sharedInstance().onWant(want) 77 GetuiPush.sharedInstance().onWant(want)
76 Logger.debug(TAG, "App onCreate: finised") 78 Logger.debug(TAG, "App onCreate: finised")
  79 +
  80 + this.lastStartupWant = want
77 } 81 }
78 82
79 appOnNewWant(want: Want, launchParam: AbilityConstant.LaunchParam) { 83 appOnNewWant(want: Want, launchParam: AbilityConstant.LaunchParam) {
80 GetuiPush.sharedInstance().onNewWant(want) 84 GetuiPush.sharedInstance().onNewWant(want)
  85 +
  86 + this.dealWithDeepLink(want)
81 } 87 }
82 88
83 appOnDestory() { 89 appOnDestory() {
@@ -124,6 +130,10 @@ export class StartupManager { @@ -124,6 +130,10 @@ export class StartupManager {
124 //TODO: 130 //TODO:
125 // 提前初始化webview 131 // 提前初始化webview
126 webview.WebviewController.initializeWebEngine() 132 webview.WebviewController.initializeWebEngine()
  133 +
  134 + if (this.lastStartupWant && this.dealWithDeepLink(this.lastStartupWant)) {
  135 + this.lastStartupWant = undefined
  136 + }
127 resolve() 137 resolve()
128 }) 138 })
129 } 139 }
@@ -195,4 +205,20 @@ export class StartupManager { @@ -195,4 +205,20 @@ export class StartupManager {
195 private initOthers() { 205 private initOthers() {
196 206
197 } 207 }
  208 +
  209 + private dealWithDeepLink(want: Want): boolean {
  210 +
  211 + if (!want.parameters) {
  212 + return false
  213 + }
  214 +
  215 + let deepLink = want.parameters[NewspaperWidgetCommon.JumpParam.DeepLinkKey] as string
  216 +
  217 + if (deepLink && deepLink.length) {
  218 +
  219 + AppInnerLink.jumpWithLink(deepLink)
  220 + return true
  221 + }
  222 + return false
  223 + }
198 } 224 }
@@ -14,8 +14,8 @@ @@ -14,8 +14,8 @@
14 "isDynamic": true, 14 "isDynamic": true,
15 "isDefault": true, 15 "isDefault": true,
16 "updateEnabled": true, 16 "updateEnabled": true,
17 - "scheduledUpdateTime": "10:30",  
18 - "updateDuration": 1, 17 + "scheduledUpdateTime": "18:26",
  18 + "updateDuration": 4,
19 "defaultDimension": "2*4", 19 "defaultDimension": "2*4",
20 "supportDimensions": [ 20 "supportDimensions": [
21 "2*4" 21 "2*4"