Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
chenjun
2024-08-08 17:20:51 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
de435ed45f57136f02039df63bc620a8252ce0b9
de435ed4
1 parent
0c96044f
来源超过16个字符时隐藏时间和评论
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
4 deletions
sight_harmony/features/wdComponent/src/main/ets/components/cardCommon/CardSourceInfo.ets
sight_harmony/features/wdComponent/src/main/ets/components/cardCommon/CardSourceInfo.ets
View file @
de435ed
import { CompDTO, ContentDTO } from 'wdBean'
import { CommonConstants } from 'wdConstant/Index';
import { DateTimeUtils } from 'wdKit/Index';
import { DateTimeUtils
, Logger
} from 'wdKit/Index';
import router from '@ohos.router'
@Reusable
...
...
@@ -12,8 +12,24 @@ export struct CardSourceInfo {
isCompInnerSource: boolean = false
// 是否有展示的信息,如来源,标签、时间、评论
@State viewShowData: boolean = true
private maxLength: number = 16;
@State private isEllipsisActive: boolean = false;
@State private displayText: string = '';
aboutToAppear(): void {
this.processText();
}
processText() {
const sourceText = this.contentDTO.rmhPlatform === 1 ? this.contentDTO.rmhInfo?.rmhName : this.contentDTO.source;
if (sourceText.length > this.maxLength) {
this.displayText = sourceText.substring(0, this.maxLength) + '...';
this.isEllipsisActive = true;
} else {
this.displayText = sourceText;
this.isEllipsisActive = false;
}
//Logger.warn(`cj2024 sourceText displayText=${this.displayText} isEllipsisActive=${this.isEllipsisActive}`)
}
aboutToReuse(params: Record<string, object>): void {
...
...
@@ -110,7 +126,7 @@ export struct CardSourceInfo {
// 来源信息
if (this.contentDTO.rmhPlatform === 1 || this.contentDTO.source) {
Text(this.
contentDTO.rmhPlatform === 1 ? this.contentDTO.rmhInfo?.rmhName : this.contentDTO.source
)
Text(this.
displayText
)
.fontSize($r("app.float.font_size_11"))
.fontColor($r("app.color.color_B0B0B0"))
.maxLines(1)
...
...
@@ -134,11 +150,12 @@ export struct CardSourceInfo {
Image($r("app.media.point"))
.width(11)
.height(11)
.visibility(!this.isEllipsisActive ? Visibility.Visible : Visibility.Hidden)
}
// 发布日期
if (this.showTime()) {
if (this.showTime()
&& !this.isEllipsisActive
) {
Text(this.handleTimeStr())
.fontSize($r("app.float.font_size_11"))
.fontColor($r("app.color.color_B0B0B0"))
...
...
@@ -147,7 +164,7 @@ export struct CardSourceInfo {
}
// 评论数
if (!this.contentDTO.cornerMark && !this.contentDTO.corner) {
if (!this.contentDTO.cornerMark && !this.contentDTO.corner
&& !this.isEllipsisActive
) {
if (this.contentDTO.objectType !=='2' && !this.isCompInnerSource && Number(this.getContentDtoBean()?.interactData?.commentNum) > 0 &&
this.showCommentNum()) {
Text(`${this.handlerNum(this.getContentDtoBean()?.interactData?.commentNum.toString())}评`)
...
...
Please
register
or
login
to post a comment