chenjun

设置视频缓存https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/performance/p…

…erformance-quick-switch-short-video.md
  1 +import { AuthorListDTO, FullColumnImgUrlDTO, ReLInfoDTO, RmhInfoDTO, ShareInfoDTO,
  2 + UserInfoDTO,
  3 + VideoInfoDTO } from 'wdBean';
  4 +
  5 +@Observed
  6 +export class ContentDetailModel{
  7 + newsId: number = 0;
  8 + newsTitle: string = "";
  9 + newsShortTitle: string= "";
  10 + newsDownTitle: string= "";
  11 + newsBodyTitle: string= "";
  12 + publishTime: string= "";
  13 + appstyle: number= 0;
  14 + newsType: number= 0;
  15 + newsSummary: string= "";
  16 + newsSource: string= "";
  17 + newsSourceName: string= "";
  18 + newsContent: string= "";
  19 + newsContentBak: string= "";
  20 + newsLinkUrl: string="";
  21 + bestNoticer: number= 0;
  22 + // newLinkObject?: any = null;
  23 + newIntroduction: string= "";
  24 + authorList: AuthorListDTO[]=[];
  25 + editorName: string="";
  26 + openAudio: number= 0;
  27 + // audioList: any[];
  28 + // hasPopUp?: any;
  29 + // popUps?: any[];
  30 + firstFrameImageUri: string= "";
  31 + reLInfo?: ReLInfoDTO | null = null;
  32 + fullColumnImgUrls: FullColumnImgUrlDTO[]=[];
  33 + shareInfo?: ShareInfoDTO | null = null;
  34 + // photoList: any[];
  35 + videoInfo: VideoInfoDTO[]=[];
  36 + // liveInfo?: any ;
  37 + // voteInfo?: any;
  38 + rmhInfo?: RmhInfoDTO | null = null;
  39 + userInfo?: UserInfoDTO | null = null;
  40 + openLikes: number= 0;
  41 + openComment: number= 0;
  42 + likesStyle: number= 0;
  43 + preCommentFlag: number= 0;
  44 + commentDisplay: number= 0;
  45 + keyArticle: number= 0;
  46 + rmhPlatform: number= 0;
  47 + readFlag?: number= 0;
  48 + // topicInfo?: any;
  49 + traceId: string= "";
  50 + itemId: string= "";
  51 + sceneId: string= "";
  52 + subSceneId: string= "";
  53 + // activityInfos: any[]=[];
  54 + recommendShow: number= 0;
  55 + visitorComment: number= 0;
  56 + itemTypeCode: string= "";
  57 + menuShow: number= 0;
  58 + newsTags: string= "";
  59 + // specialColumnId?: any;
  60 + specialColumnName: string= "";
  61 + // timeline?: any;
  62 +
  63 + constructor(newsId: number, newsTitle: string, newsShortTitle: string, newsDownTitle: string, newsBodyTitle: string,
  64 + publishTime: string, appstyle: number, newsType: number, newsSummary: string, newsSource: string,
  65 + newsSourceName: string, newsContent: string, newsContentBak: string, newsLinkUrl: string, bestNoticer: number,
  66 + newIntroduction: string, authorList: AuthorListDTO[], editorName: string, openAudio: number,
  67 + firstFrameImageUri: string,fullColumnImgUrls: FullColumnImgUrlDTO[], videoInfo: VideoInfoDTO[],
  68 + openLikes: number, openComment: number, likesStyle: number, preCommentFlag: number,
  69 + commentDisplay: number, keyArticle: number, rmhPlatform: number, readFlag: number, traceId: string,
  70 + itemId: string, sceneId: string, subSceneId: string, recommendShow: number,
  71 + visitorComment: number, itemTypeCode: string, menuShow: number, newsTags: string,
  72 + specialColumnName: string, traceInfo: string, viewCount: number, isNewspaper: boolean, oldNewsId: string,
  73 + showTime: boolean, isLogin: string) {
  74 + this.newsId = newsId;
  75 + this.newsTitle = newsTitle;
  76 + this.newsShortTitle = newsShortTitle;
  77 + this.newsDownTitle = newsDownTitle;
  78 + this.newsBodyTitle = newsBodyTitle;
  79 + this.publishTime = publishTime;
  80 + this.appstyle = appstyle;
  81 + this.newsType = newsType;
  82 + this.newsSummary = newsSummary;
  83 + this.newsSource = newsSource;
  84 + this.newsSourceName = newsSourceName;
  85 + this.newsContent = newsContent;
  86 + this.newsContentBak = newsContentBak;
  87 + this.newsLinkUrl = newsLinkUrl;
  88 + this.bestNoticer = bestNoticer;
  89 + this.newIntroduction = newIntroduction;
  90 + this.authorList = authorList;
  91 + this.editorName = editorName;
  92 + this.openAudio = openAudio;
  93 + this.firstFrameImageUri = firstFrameImageUri;
  94 + this.fullColumnImgUrls = fullColumnImgUrls;
  95 + this.videoInfo = videoInfo;
  96 + this.openLikes = openLikes;
  97 + this.openComment = openComment;
  98 + this.likesStyle = likesStyle;
  99 + this.preCommentFlag = preCommentFlag;
  100 + this.commentDisplay = commentDisplay;
  101 + this.keyArticle = keyArticle;
  102 + this.rmhPlatform = rmhPlatform;
  103 + this.readFlag = readFlag;
  104 + this.traceId = traceId;
  105 + this.itemId = itemId;
  106 + this.sceneId = sceneId;
  107 + this.subSceneId = subSceneId;
  108 + this.recommendShow = recommendShow;
  109 + this.visitorComment = visitorComment;
  110 + this.itemTypeCode = itemTypeCode;
  111 + this.menuShow = menuShow;
  112 + this.newsTags = newsTags;
  113 + this.specialColumnName = specialColumnName;
  114 + this.traceInfo = traceInfo;
  115 + this.viewCount = viewCount;
  116 + this.isNewspaper = isNewspaper;
  117 + this.oldNewsId = oldNewsId;
  118 + this.showTime = showTime;
  119 + this.isLogin = isLogin;
  120 + }
  121 + traceInfo: string= "";
  122 + viewCount: number= 0;
  123 + isNewspaper: boolean = false;
  124 + oldNewsId: string= "";
  125 +
  126 +
  127 + // 本地字段
  128 + showTime:boolean = false;
  129 + isLogin?:string = ""
  130 +}
@@ -9,7 +9,7 @@ import { @@ -9,7 +9,7 @@ import {
9 contentListParams, 9 contentListParams,
10 getRecCompInfoParams 10 getRecCompInfoParams
11 } from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest'; 11 } from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest';
12 -import { NetworkUtil, Logger, WindowModel, DateTimeUtils } from 'wdKit/Index'; 12 +import { NetworkUtil, Logger, WindowModel, DateTimeUtils, LazyDataSource } from 'wdKit/Index';
13 import { PictureLoading } from './PictureLoading'; 13 import { PictureLoading } from './PictureLoading';
14 import { DisplayDirection } from 'wdConstant/Index'; 14 import { DisplayDirection } from 'wdConstant/Index';
15 import { window } from '@kit.ArkUI'; 15 import { window } from '@kit.ArkUI';
@@ -57,6 +57,7 @@ export struct VideoChannelDetail { @@ -57,6 +57,7 @@ export struct VideoChannelDetail {
57 @Consume displayDirection: DisplayDirection 57 @Consume displayDirection: DisplayDirection
58 @Provide showCommentList: boolean = false 58 @Provide showCommentList: boolean = false
59 @State data: ContentDetailDTO[] = [] 59 @State data: ContentDetailDTO[] = []
  60 + @State dataContentDetail: LazyDataSource<ContentDetailDTO> = new LazyDataSource();
60 @State currentIndex: number = 0 61 @State currentIndex: number = 0
61 @State interactDataList: InteractDataDTO[] = [] 62 @State interactDataList: InteractDataDTO[] = []
62 @State totalCount: number = 0 63 @State totalCount: number = 0
@@ -256,6 +257,7 @@ export struct VideoChannelDetail { @@ -256,6 +257,7 @@ export struct VideoChannelDetail {
256 if (res.data) { 257 if (res.data) {
257 await this.getContentInteract(list2) 258 await this.getContentInteract(list2)
258 this.data = this.data.concat(res.data) 259 this.data = this.data.concat(res.data)
  260 + this.dataContentDetail.addItems(res.data)
259 } 261 }
260 console.log('根据视频楼层信息批量查询视频列表', JSON.stringify(res.data)) 262 console.log('根据视频楼层信息批量查询视频列表', JSON.stringify(res.data))
261 }).finally(() => { 263 }).finally(() => {
@@ -304,7 +306,8 @@ export struct VideoChannelDetail { @@ -304,7 +306,8 @@ export struct VideoChannelDetail {
304 .visibility(this.isMouted ? Visibility.None : Visibility.Visible) 306 .visibility(this.isMouted ? Visibility.None : Visibility.Visible)
305 307
306 Swiper(this.swiperController) { 308 Swiper(this.swiperController) {
307 - ForEach(this.data, (item: ContentDetailDTO, index: number) => { 309 + // LazyForEach(this.data, (item: ContentDetailDTO, index: number) => {
  310 + LazyForEach(this.dataContentDetail, (item: ContentDetailDTO, index: number) => {
308 DetailPlayShortVideoPage({ 311 DetailPlayShortVideoPage({
309 contentDetailData: item, 312 contentDetailData: item,
310 currentIndex: this.currentIndex, 313 currentIndex: this.currentIndex,
@@ -314,6 +317,7 @@ export struct VideoChannelDetail { @@ -314,6 +317,7 @@ export struct VideoChannelDetail {
314 }, (item: ContentDetailDTO) => item.newsId + '') 317 }, (item: ContentDetailDTO) => item.newsId + '')
315 } 318 }
316 .displayCount(1, true) 319 .displayCount(1, true)
  320 + .cachedCount(3)
317 .disableSwipe(this.displayDirection === DisplayDirection.VERTICAL || this.showCommentList ? false : true) 321 .disableSwipe(this.displayDirection === DisplayDirection.VERTICAL || this.showCommentList ? false : true)
318 .visibility(this.isMouted ? Visibility.Visible : Visibility.Hidden) 322 .visibility(this.isMouted ? Visibility.Visible : Visibility.Hidden)
319 .indicator(false) 323 .indicator(false)