xugenyuan

ref |> 解决桌面组件widgets间接引用wdComponent中的AudioCapture导致崩溃

Signed-off-by: xugenyuan <xugenyuan@wondertek.com.cn>
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 { CrptoUtils, FileUtils, Logger } from 'wdKit/Index'; 3 import { CrptoUtils, FileUtils, Logger } from 'wdKit/Index';
4 import { FormNewspaperPaperType, FormNewspaperPaperContent, 4 import { FormNewspaperPaperType, FormNewspaperPaperContent,
5 FormNewspaperData } from "../dailynewspaperwidget/common/NewspaperWidgetData" 5 FormNewspaperData } from "../dailynewspaperwidget/common/NewspaperWidgetData"
@@ -8,6 +8,7 @@ import fs from '@ohos.file.fs'; @@ -8,6 +8,7 @@ import fs from '@ohos.file.fs';
8 import { BusinessError } from '@kit.BasicServicesKit'; 8 import { BusinessError } from '@kit.BasicServicesKit';
9 import { JSON } from '@kit.ArkTS'; 9 import { JSON } from '@kit.ArkTS';
10 import { AppInnerLinkGenerator } from 'wdRouter'; 10 import { AppInnerLinkGenerator } from 'wdRouter';
  11 +import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork';
11 12
12 const TAG = "NewspaperDataFetcher" 13 const TAG = "NewspaperDataFetcher"
13 14
@@ -22,11 +23,11 @@ export class NewspaperDataFetcher { @@ -22,11 +23,11 @@ export class NewspaperDataFetcher {
22 data.paperInfo = { showLeftImage: false } 23 data.paperInfo = { showLeftImage: false }
23 24
24 try { 25 try {
25 - let page: PageInfoBean = await MorningEveningViewModel.getDailyPaperTopic() 26 + let page: PageInfoBean = await NewspaperDataFetcher.getDailyPaperTopic()
26 data.paperType = page.topicInfo?.topicPattern || FormNewspaperPaperType.unknown 27 data.paperType = page.topicInfo?.topicPattern || FormNewspaperPaperType.unknown
27 28
28 let currentTime = new Date().getTime() 29 let currentTime = new Date().getTime()
29 - let compInfo = await MorningEveningViewModel.getMorningEveningCompInfo( 30 + let compInfo = await NewspaperDataFetcher.getMorningEveningCompInfo(
30 page.id, 31 page.id,
31 page.groups[0]?.id, 32 page.groups[0]?.id,
32 currentTime + "", 33 currentTime + "",
@@ -208,5 +209,62 @@ export class NewspaperDataFetcher { @@ -208,5 +209,62 @@ export class NewspaperDataFetcher {
208 }) 209 })
209 } 210 }
210 211
  212 + static async getDailyPaperTopic(): Promise<PageInfoBean> {
  213 + return new Promise<PageInfoBean>((success, error) => {
  214 + Logger.info(TAG, `getDailyPaperTopic pageInfo start`);
  215 +
  216 + let url = HttpUrlUtils.getHost() + HttpUrlUtils.DAILY_PAPER_TOPIC;
  217 + WDHttp.get<ResponseDTO<PageInfoBean>>(url).then((resDTO: ResponseDTO<PageInfoBean>) => {
  218 + if (!resDTO || !resDTO.data) {
  219 + Logger.error(TAG, 'getDailyPaperTopic then navResDTO is empty');
  220 + error('resDTO is empty');
  221 + return
  222 + }
  223 + if (resDTO.code != 0) {
  224 + Logger.error(TAG, `getDailyPaperTopic then code:${resDTO.code}, message:${resDTO.message}`);
  225 + error('resDTO Response Code is failure');
  226 + return
  227 + }
  228 + // let navResStr = JSON.stringify(navResDTO);
  229 + Logger.info(TAG, "getDailyPaperTopic then,navResDTO.timestamp:" + resDTO.timestamp);
  230 + success(resDTO.data);
  231 + })
  232 + .catch((err: Error) => {
  233 + Logger.error(TAG, `getDailyPaperTopic catch, error.name : ${err.name}, error.message:${err.message}`);
  234 + error(err);
  235 + })
  236 + })
  237 + }
  238 +
  239 + static async getMorningEveningCompInfo(pageId: number, groupId: number, refreshTime: string, topicId: string, pageNum: number = 1, pageSize: number = 20): Promise<CompInfoBean> {
  240 + return new Promise<CompInfoBean>((success, error) => {
  241 + Logger.info(TAG, `getMorningEveningCompInfo pageInfo start`);
  242 +
  243 + let url = HttpUrlUtils.getHost() + HttpUrlUtils.COMP_PATH;
  244 + url = url + "?loadStrategy=first_load&pageNum=" + pageNum + "&refreshTime=" + refreshTime + "&pageId="
  245 + + pageId + "&channelStrategy=2&groupId=" + groupId + "&topicId=" + topicId + "&pageSize=" + pageSize;
  246 +
  247 + WDHttp.get<ResponseDTO<CompInfoBean>>(url).then((resDTO: ResponseDTO<CompInfoBean>) => {
  248 + if (!resDTO || !resDTO.data) {
  249 + Logger.error(TAG, 'getMorningEveningCompInfo then navResDTO is empty');
  250 + error('resDTO is empty');
  251 + return
  252 + }
  253 + if (resDTO.code != 0) {
  254 + Logger.error(TAG, `getMorningEveningCompInfo then code:${resDTO.code}, message:${resDTO.message}`);
  255 + error('resDTO Response Code is failure');
  256 + return
  257 + }
  258 + // let navResStr = JSON.stringify(navResDTO);
  259 + Logger.info(TAG, "getMorningEveningCompInfo then,navResDTO.timestamp:" + resDTO.timestamp);
  260 + success(resDTO.data);
  261 + })
  262 + .catch((err: Error) => {
  263 + Logger.error(TAG, `getMorningEveningCompInfo catch, error.name : ${err.name}, error.message:${err.message}`);
  264 + error(err);
  265 + })
  266 + })
  267 + }
  268 +
211 269
212 } 270 }