wangliang_wd

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

... ... @@ -142,6 +142,8 @@ export class ContentDTO implements BaseDTO {
// 是否国殇
isMourning?: boolean = false;
author: string = ""; ///撰稿人
static clone(old: ContentDTO): ContentDTO {
let content = new ContentDTO();
content.liveType = old.liveType;
... ...
... ... @@ -2,6 +2,7 @@ import { CompDTO, ContentDTO } from 'wdBean'
import { CommonConstants } from 'wdConstant/Index';
import { DateTimeUtils, Logger } from 'wdKit/Index';
import router from '@ohos.router'
import { SearchShowRed, textItem, titleInitRes } from '../../utils/searchShowRed';
@Reusable
@Component
... ... @@ -16,13 +17,27 @@ export struct CardSourceInfo {
@State private isEllipsisActive: boolean = false;
@State private displayText: string = '';
@State authorMarked: boolean = false;
@State authorArr: textItem[] = []
aboutToAppear(): void {
this.processText();
this.titleInit();
}
titleInit() {
if (this.contentDTO?.author&&this.contentDTO?.author.length > 0) {
const titleInitRes:titleInitRes = SearchShowRed.titleInit(this.contentDTO.author);
this.authorMarked = titleInitRes.titleMarked;
this.authorArr = titleInitRes.textArr;
}
}
processText() {
const sourceText = this.contentDTO.rmhPlatform === 1 ? this.contentDTO.rmhInfo?.rmhName : this.contentDTO.source;
if (sourceText.length > this.maxLength) {
const sourceText = this.contentDTO?.rmhPlatform === 1 ? this.contentDTO.rmhInfo?.rmhName : this.contentDTO?.source;
if (sourceText && (sourceText.length > this.maxLength)) {
this.displayText = sourceText.substring(0, this.maxLength) + '...';
this.isEllipsisActive = true;
} else {
... ... @@ -114,6 +129,7 @@ export struct CardSourceInfo {
}
build() {
Column(){
Flex({ justifyContent: FlexAlign.Start, direction: FlexDirection.Row }) {
// 标签
if (this.contentDTO.cornerMark || this.contentDTO.corner) {
... ... @@ -185,7 +201,32 @@ export struct CardSourceInfo {
}
.width(CommonConstants.FULL_WIDTH)
if (this.contentDTO?.author&&this.contentDTO?.author.length > 0){
Text() {
if (this.authorMarked) {
ForEach(this.authorArr, (textItem: textItem) => {
if (textItem.isRed) {
Span(textItem.content)
.fontColor(0xED2800)
} else {
Span(textItem.content)
}
})
} else {
Span(this.contentDTO.newsTitle)
}
}
.fontSize($r('app.float.font_size_11'))
.fontColor($r("app.color.color_B0B0B0"))
.align(Alignment.Start)
.width('100%')
.margin({top:5})
}
}
.width(CommonConstants.FULL_WIDTH)
.margin({ top: this.viewShowData ? 8 : 0 })
}
/**
... ...
... ... @@ -547,6 +547,7 @@ export struct SearchResultContentComponent {
contentDTO.rmhInfo = rmhInfo
contentDTO.shareFlag = value.data.shareFlag
contentDTO.contentText = value.data.contentText
contentDTO.author = value.data.author
return contentDTO;
}
... ...