wangliang_wd

feat:增加搜索撰稿人,简介标识,优化搜索闪退问题

@@ -142,6 +142,8 @@ export class ContentDTO implements BaseDTO { @@ -142,6 +142,8 @@ export class ContentDTO implements BaseDTO {
142 // 是否国殇 142 // 是否国殇
143 isMourning?: boolean = false; 143 isMourning?: boolean = false;
144 144
  145 + author: string = ""; ///撰稿人
  146 +
145 static clone(old: ContentDTO): ContentDTO { 147 static clone(old: ContentDTO): ContentDTO {
146 let content = new ContentDTO(); 148 let content = new ContentDTO();
147 content.liveType = old.liveType; 149 content.liveType = old.liveType;
@@ -2,6 +2,7 @@ import { CompDTO, ContentDTO } from 'wdBean' @@ -2,6 +2,7 @@ import { CompDTO, ContentDTO } from 'wdBean'
2 import { CommonConstants } from 'wdConstant/Index'; 2 import { CommonConstants } from 'wdConstant/Index';
3 import { DateTimeUtils, Logger } from 'wdKit/Index'; 3 import { DateTimeUtils, Logger } from 'wdKit/Index';
4 import router from '@ohos.router' 4 import router from '@ohos.router'
  5 +import { SearchShowRed, textItem, titleInitRes } from '../../utils/searchShowRed';
5 6
6 @Reusable 7 @Reusable
7 @Component 8 @Component
@@ -16,13 +17,27 @@ export struct CardSourceInfo { @@ -16,13 +17,27 @@ export struct CardSourceInfo {
16 @State private isEllipsisActive: boolean = false; 17 @State private isEllipsisActive: boolean = false;
17 @State private displayText: string = ''; 18 @State private displayText: string = '';
18 19
  20 + @State authorMarked: boolean = false;
  21 + @State authorArr: textItem[] = []
  22 +
19 aboutToAppear(): void { 23 aboutToAppear(): void {
20 this.processText(); 24 this.processText();
  25 +
  26 + this.titleInit();
21 } 27 }
22 28
  29 + titleInit() {
  30 + if (this.contentDTO?.author&&this.contentDTO?.author.length > 0) {
  31 + const titleInitRes:titleInitRes = SearchShowRed.titleInit(this.contentDTO.author);
  32 + this.authorMarked = titleInitRes.titleMarked;
  33 + this.authorArr = titleInitRes.textArr;
  34 + }
  35 + }
  36 +
  37 +
23 processText() { 38 processText() {
24 - const sourceText = this.contentDTO.rmhPlatform === 1 ? this.contentDTO.rmhInfo?.rmhName : this.contentDTO.source;  
25 - if (sourceText.length > this.maxLength) { 39 + const sourceText = this.contentDTO?.rmhPlatform === 1 ? this.contentDTO.rmhInfo?.rmhName : this.contentDTO?.source;
  40 + if (sourceText && (sourceText.length > this.maxLength)) {
26 this.displayText = sourceText.substring(0, this.maxLength) + '...'; 41 this.displayText = sourceText.substring(0, this.maxLength) + '...';
27 this.isEllipsisActive = true; 42 this.isEllipsisActive = true;
28 } else { 43 } else {
@@ -114,6 +129,7 @@ export struct CardSourceInfo { @@ -114,6 +129,7 @@ export struct CardSourceInfo {
114 } 129 }
115 130
116 build() { 131 build() {
  132 + Column(){
117 Flex({ justifyContent: FlexAlign.Start, direction: FlexDirection.Row }) { 133 Flex({ justifyContent: FlexAlign.Start, direction: FlexDirection.Row }) {
118 // 标签 134 // 标签
119 if (this.contentDTO.cornerMark || this.contentDTO.corner) { 135 if (this.contentDTO.cornerMark || this.contentDTO.corner) {
@@ -185,7 +201,32 @@ export struct CardSourceInfo { @@ -185,7 +201,32 @@ export struct CardSourceInfo {
185 201
186 } 202 }
187 .width(CommonConstants.FULL_WIDTH) 203 .width(CommonConstants.FULL_WIDTH)
188 - .margin({ top: this.viewShowData ? 8 : 0 }) 204 +
  205 + if (this.contentDTO?.author&&this.contentDTO?.author.length > 0){
  206 + Text() {
  207 + if (this.authorMarked) {
  208 + ForEach(this.authorArr, (textItem: textItem) => {
  209 + if (textItem.isRed) {
  210 + Span(textItem.content)
  211 + .fontColor(0xED2800)
  212 + } else {
  213 + Span(textItem.content)
  214 + }
  215 + })
  216 + } else {
  217 + Span(this.contentDTO.newsTitle)
  218 + }
  219 + }
  220 + .fontSize($r('app.float.font_size_11'))
  221 + .fontColor($r("app.color.color_B0B0B0"))
  222 + .align(Alignment.Start)
  223 + .width('100%')
  224 + .margin({top:5})
  225 + }
  226 + }
  227 + .width(CommonConstants.FULL_WIDTH)
  228 + .margin({ top: this.viewShowData ? 8 : 0 })
  229 +
189 } 230 }
190 231
191 /** 232 /**
@@ -547,6 +547,7 @@ export struct SearchResultContentComponent { @@ -547,6 +547,7 @@ export struct SearchResultContentComponent {
547 contentDTO.rmhInfo = rmhInfo 547 contentDTO.rmhInfo = rmhInfo
548 contentDTO.shareFlag = value.data.shareFlag 548 contentDTO.shareFlag = value.data.shareFlag
549 contentDTO.contentText = value.data.contentText 549 contentDTO.contentText = value.data.contentText
  550 + contentDTO.author = value.data.author
550 return contentDTO; 551 return contentDTO;
551 } 552 }
552 553