Showing
2 changed files
with
12 additions
and
11 deletions
| @@ -751,7 +751,7 @@ struct commentHeaderView { | @@ -751,7 +751,7 @@ struct commentHeaderView { | ||
| 751 | maxline: 3, | 751 | maxline: 3, |
| 752 | fontSize: 16, | 752 | fontSize: 16, |
| 753 | fontWeight: FontWeight.Regular, | 753 | fontWeight: FontWeight.Regular, |
| 754 | - marginWidth: (this.isZD?60:70 + 16) | 754 | + marginWidth: (this.isZD?60:this.leftGap + 16) |
| 755 | }) | 755 | }) |
| 756 | .margin({ left: this.leftGap, right: 16,top:-12 }) | 756 | .margin({ left: this.leftGap, right: 16,top:-12 }) |
| 757 | .onClick(() => { | 757 | .onClick(() => { |
| @@ -41,36 +41,37 @@ export struct CommentText { | @@ -41,36 +41,37 @@ export struct CommentText { | ||
| 41 | promise: Promise<Array<display.Display>> = display.getAllDisplays() | 41 | promise: Promise<Array<display.Display>> = display.getAllDisplays() |
| 42 | 42 | ||
| 43 | aboutToAppear() { | 43 | aboutToAppear() { |
| 44 | - // this.longMessage = TestLongText | 44 | + let tempMessage = new String(this.longMessage) |
| 45 | + tempMessage = tempMessage.replace(/\n/g,'') | ||
| 46 | + // console.log(`>>>>>>>文本:${this.longMessage}-${tempMessage}`) | ||
| 45 | 47 | ||
| 46 | - console.log(`文本宽度为:${this.textWidth}`) | ||
| 47 | let padding = vp2px(5 + this.marginWidth) | 48 | let padding = vp2px(5 + this.marginWidth) |
| 48 | 49 | ||
| 49 | this.textWidth = measure.measureText({ | 50 | this.textWidth = measure.measureText({ |
| 50 | - textContent: this.longMessage, | 51 | + textContent: tempMessage.toString(), |
| 51 | fontSize: this.fontSize, | 52 | fontSize: this.fontSize, |
| 52 | fontWeight: this.fontWeight, | 53 | fontWeight: this.fontWeight, |
| 53 | - constraintWidth: (this.screenWidth - padding), | ||
| 54 | wordBreak:WordBreak.BREAK_ALL | 54 | wordBreak:WordBreak.BREAK_ALL |
| 55 | }) | 55 | }) |
| 56 | 56 | ||
| 57 | - console.log(`文本宽度为:${this.textWidth}`) | ||
| 58 | - | 57 | + // console.log(`>>>>>>>文本宽度为:${this.textWidth}-${this.contentText}`) |
| 59 | this.promise.then((data: Array<display.Display>) => { | 58 | this.promise.then((data: Array<display.Display>) => { |
| 60 | console.log(`所有的屏幕信息:${JSON.stringify(data)}`) | 59 | console.log(`所有的屏幕信息:${JSON.stringify(data)}`) |
| 61 | //单位为像素 | 60 | //单位为像素 |
| 62 | this.screenWidth = data[0]["width"] | 61 | this.screenWidth = data[0]["width"] |
| 63 | - // 屏幕宽度 * 最大行数 * 组件宽度比例 和 文字测量宽度 | 62 | + // 屏幕宽度 * 最大行数 * 组件宽度比例 和 文字测量宽度3900,,3951 |
| 64 | this.isExpanded = (this.screenWidth - padding) * this.lines <= this.textWidth | 63 | this.isExpanded = (this.screenWidth - padding) * this.lines <= this.textWidth |
| 65 | // this.expandedStates = this.isExpanded; | 64 | // this.expandedStates = this.isExpanded; |
| 66 | 65 | ||
| 67 | let lines = this.getTextLineNum( | 66 | let lines = this.getTextLineNum( |
| 68 | - this.longMessage, | 67 | + tempMessage.toString(), |
| 69 | (this.screenWidth - padding), | 68 | (this.screenWidth - padding), |
| 70 | this.lineHeight, | 69 | this.lineHeight, |
| 71 | this.fontSize, | 70 | this.fontSize, |
| 72 | this.fontWeight | 71 | this.fontWeight |
| 73 | ) | 72 | ) |
| 73 | + | ||
| 74 | + console.log(`>>>>>>>行高数:${lines}-${this.screenWidth}-${this.longMessage}`) | ||
| 74 | if (lines > 3) { | 75 | if (lines > 3) { |
| 75 | this.isExpanded = true | 76 | this.isExpanded = true |
| 76 | } | 77 | } |
| @@ -82,8 +83,8 @@ export struct CommentText { | @@ -82,8 +83,8 @@ export struct CommentText { | ||
| 82 | let padding = vp2px(5 + this.marginWidth) | 83 | let padding = vp2px(5 + this.marginWidth) |
| 83 | let maxLineTextWidth = (this.screenWidth - padding) * this.maxline; | 84 | let maxLineTextWidth = (this.screenWidth - padding) * this.maxline; |
| 84 | 85 | ||
| 85 | - for (let index = 0; index < this.longMessage.length; index++) { | ||
| 86 | - const element = this.longMessage.substring(0, index) | 86 | + for (let index = 0; index < tempMessage.length; index++) { |
| 87 | + const element = tempMessage.substring(0, index) | ||
| 87 | const string = element + this.collapseText; //截取 | 88 | const string = element + this.collapseText; //截取 |
| 88 | const thisTextWidth = measure.measureText({ | 89 | const thisTextWidth = measure.measureText({ |
| 89 | textContent: string, | 90 | textContent: string, |
-
Please register or login to post a comment