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
chenquansheng
2024-10-28 14:33:33 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
1c786ebebda418740ff8703ccf6c1c94242feb51
1c786ebe
1 parent
40e4bfd0
fix |> 评论行数显示优化
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
11 deletions
sight_harmony/features/wdComponent/src/main/ets/components/comment/view/CommentComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/comment/view/CommentText.ets
sight_harmony/features/wdComponent/src/main/ets/components/comment/view/CommentComponent.ets
View file @
1c786eb
...
...
@@ -751,7 +751,7 @@ struct commentHeaderView {
maxline: 3,
fontSize: 16,
fontWeight: FontWeight.Regular,
marginWidth: (this.isZD?60:
70
+ 16)
marginWidth: (this.isZD?60:
this.leftGap
+ 16)
})
.margin({ left: this.leftGap, right: 16,top:-12 })
.onClick(() => {
...
...
sight_harmony/features/wdComponent/src/main/ets/components/comment/view/CommentText.ets
View file @
1c786eb
...
...
@@ -41,36 +41,37 @@ export struct CommentText {
promise: Promise<Array<display.Display>> = display.getAllDisplays()
aboutToAppear() {
// this.longMessage = TestLongText
let tempMessage = new String(this.longMessage)
tempMessage = tempMessage.replace(/\n/g,'')
// console.log(`>>>>>>>文本:${this.longMessage}-${tempMessage}`)
console.log(`文本宽度为:${this.textWidth}`)
let padding = vp2px(5 + this.marginWidth)
this.textWidth = measure.measureText({
textContent: t
his.longMessage
,
textContent: t
empMessage.toString()
,
fontSize: this.fontSize,
fontWeight: this.fontWeight,
constraintWidth: (this.screenWidth - padding),
wordBreak:WordBreak.BREAK_ALL
})
console.log(`文本宽度为:${this.textWidth}`)
// console.log(`>>>>>>>文本宽度为:${this.textWidth}-${this.contentText}`)
this.promise.then((data: Array<display.Display>) => {
console.log(`所有的屏幕信息:${JSON.stringify(data)}`)
//单位为像素
this.screenWidth = data[0]["width"]
// 屏幕宽度 * 最大行数 * 组件宽度比例 和 文字测量宽度
// 屏幕宽度 * 最大行数 * 组件宽度比例 和 文字测量宽度
3900,,3951
this.isExpanded = (this.screenWidth - padding) * this.lines <= this.textWidth
// this.expandedStates = this.isExpanded;
let lines = this.getTextLineNum(
t
his.longMessage
,
t
empMessage.toString()
,
(this.screenWidth - padding),
this.lineHeight,
this.fontSize,
this.fontWeight
)
console.log(`>>>>>>>行高数:${lines}-${this.screenWidth}-${this.longMessage}`)
if (lines > 3) {
this.isExpanded = true
}
...
...
@@ -82,8 +83,8 @@ export struct CommentText {
let padding = vp2px(5 + this.marginWidth)
let maxLineTextWidth = (this.screenWidth - padding) * this.maxline;
for (let index = 0; index < this.longMessage.length; index++) {
const element = this.longMessage.substring(0, index)
for (let index = 0; index < tempMessage.length; index++) {
const element = tempMessage.substring(0, index)
const string = element + this.collapseText; //截取
const thisTextWidth = measure.measureText({
textContent: string,
...
...
Please
register
or
login
to post a comment