yangchenggong1_wd

Merge branch 'temp_comment'

@@ -44,7 +44,8 @@ export struct CommentText { @@ -44,7 +44,8 @@ export struct CommentText {
44 textContent: this.longMessage, 44 textContent: this.longMessage,
45 fontSize: this.fontSize, 45 fontSize: this.fontSize,
46 fontWeight: this.fontWeight, 46 fontWeight: this.fontWeight,
47 - constraintWidth: (this.screenWidth - padding) 47 + constraintWidth: (this.screenWidth - padding),
  48 + wordBreak:WordBreak.BREAK_ALL
48 }) 49 })
49 50
50 console.log(`文本宽度为:${this.textWidth}`) 51 console.log(`文本宽度为:${this.textWidth}`)
@@ -71,7 +72,8 @@ export struct CommentText { @@ -71,7 +72,8 @@ export struct CommentText {
71 textContent: string, 72 textContent: string,
72 fontSize: this.fontSize, 73 fontSize: this.fontSize,
73 fontWeight: this.fontWeight, 74 fontWeight: this.fontWeight,
74 - constraintWidth: (this.screenWidth - padding) 75 + constraintWidth: (this.screenWidth - padding),
  76 + wordBreak:WordBreak.BREAK_ALL
75 }) 77 })
76 78
77 //计算有误差20 79 //计算有误差20
@@ -130,6 +132,7 @@ export struct CommentText { @@ -130,6 +132,7 @@ export struct CommentText {
130 .fontWeight(this.fontWeight) 132 .fontWeight(this.fontWeight)
131 .fontColor(this.fontColor) 133 .fontColor(this.fontColor)
132 .maxLines(this.lines) 134 .maxLines(this.lines)
  135 + .wordBreak(WordBreak.BREAK_ALL)
133 136
134 // .backgroundColor(Color.Red) 137 // .backgroundColor(Color.Red)
135 138
@@ -15,6 +15,7 @@ export struct ChildCommentComponent { @@ -15,6 +15,7 @@ export struct ChildCommentComponent {
15 @State isExpandParent: boolean = false; 15 @State isExpandParent: boolean = false;
16 @State isOverLines: boolean = false 16 @State isOverLines: boolean = false
17 @State isOverLinesParent: boolean = false 17 @State isOverLinesParent: boolean = false
  18 + testText:string = "1,因为读书的人\n是低着头向上看的人\n身处一隅,却能放眼世界\n2,因为读书的人\n总是比不读书的人\n活得有趣一点\n3,因为读书的人\n即使平凡,绝不平庸"
18 19
19 build() { 20 build() {
20 Column() { 21 Column() {
@@ -71,7 +72,7 @@ export struct ChildCommentComponent { @@ -71,7 +72,7 @@ export struct ChildCommentComponent {
71 }) 72 })
72 } 73 }
73 } 74 }
74 - .margin({ bottom: '10lpx' }) 75 + .margin({ bottom: '5lpx' })
75 .width('100%') 76 .width('100%')
76 .height('108lpx') 77 .height('108lpx')
77 .padding({ left: '31lpx', right: '31lpx' }) 78 .padding({ left: '31lpx', right: '31lpx' })
@@ -93,6 +94,7 @@ export struct ChildCommentComponent { @@ -93,6 +94,7 @@ export struct ChildCommentComponent {
93 }) 94 })
94 } 95 }
95 }.maxLines(5) 96 }.maxLines(5)
  97 + .wordBreak(WordBreak.BREAK_ALL)
96 .textStyle() 98 .textStyle()
97 } 99 }
98 }.padding({ left: '31lpx', right: '31lpx' }) 100 }.padding({ left: '31lpx', right: '31lpx' })
@@ -138,6 +140,7 @@ export struct ChildCommentComponent { @@ -138,6 +140,7 @@ export struct ChildCommentComponent {
138 }) 140 })
139 } 141 }
140 }.maxLines(5) 142 }.maxLines(5)
  143 + .wordBreak(WordBreak.BREAK_ALL)
141 .textAlign(TextAlign.Start) 144 .textAlign(TextAlign.Start)
142 .width('100%') 145 .width('100%')
143 } 146 }
@@ -243,11 +246,13 @@ export struct ChildCommentComponent { @@ -243,11 +246,13 @@ export struct ChildCommentComponent {
243 let measureTruncateWidth: number = measure.measureText({ 246 let measureTruncateWidth: number = measure.measureText({
244 textContent: truncateContent, 247 textContent: truncateContent,
245 fontSize: px2fp(fontSize), 248 fontSize: px2fp(fontSize),
  249 + wordBreak:WordBreak.BREAK_ALL
246 }) 250 })
247 if(type === 1){ 251 if(type === 1){
248 measureTruncateWidth = measureTruncateWidth + measure.measureText({ 252 measureTruncateWidth = measureTruncateWidth + measure.measureText({
249 textContent: `@${this.data.parentCommentUserName}:`, 253 textContent: `@${this.data.parentCommentUserName}:`,
250 fontSize: px2fp(fontSize), 254 fontSize: px2fp(fontSize),
  255 + wordBreak:WordBreak.BREAK_ALL
251 }) 256 })
252 } 257 }
253 let clipStr: string = '' 258 let clipStr: string = ''
@@ -255,6 +260,7 @@ export struct ChildCommentComponent { @@ -255,6 +260,7 @@ export struct ChildCommentComponent {
255 if (measure.measureText({ 260 if (measure.measureText({
256 textContent: clipStr, 261 textContent: clipStr,
257 fontSize: px2fp(fontSize), 262 fontSize: px2fp(fontSize),
  263 + wordBreak:WordBreak.BREAK_ALL
258 }) >= textWidth * maxLines - measureTruncateWidth) { 264 }) >= textWidth * maxLines - measureTruncateWidth) {
259 if (type === 0) { 265 if (type === 0) {
260 this.isOverLines = true 266 this.isOverLines = true