Showing
1 changed file
with
18 additions
and
5 deletions
| @@ -134,6 +134,10 @@ export struct RmhTitle { | @@ -134,6 +134,10 @@ export struct RmhTitle { | ||
| 134 | return this.rmhInfo?.cnIsAttention && this.rmhInfo?.userType != "5" | 134 | return this.rmhInfo?.cnIsAttention && this.rmhInfo?.userType != "5" |
| 135 | } | 135 | } |
| 136 | 136 | ||
| 137 | + getFollowText() { | ||
| 138 | + return Number(this.followStatus) === 0 ? '关注' : '已关注' | ||
| 139 | + } | ||
| 140 | + | ||
| 137 | build() { | 141 | build() { |
| 138 | Flex() { | 142 | Flex() { |
| 139 | if (this.rmhInfo.userType != '5') { | 143 | if (this.rmhInfo.userType != '5') { |
| @@ -201,8 +205,17 @@ export struct RmhTitle { | @@ -201,8 +205,17 @@ export struct RmhTitle { | ||
| 201 | .textAlign(TextAlign.Start) | 205 | .textAlign(TextAlign.Start) |
| 202 | .height(14) | 206 | .height(14) |
| 203 | .lineHeight(14) | 207 | .lineHeight(14) |
| 204 | - .width('calc(100% - 65vp)') | ||
| 205 | - // .constraintSize({maxWidth:(DisplayUtils.getDeviceWidth() - 32 - 36 - 18 - this.getTextWidth(DateTimeUtils.getCommentTime(Number.parseFloat(this.publishTime))))}) | 208 | + // .width('calc(100% - 65vp)') |
| 209 | + .constraintSize({ | ||
| 210 | + maxWidth:( | ||
| 211 | + DisplayUtils.getDeviceWidth() | ||
| 212 | + - 32 | ||
| 213 | + - 8 - 12 | ||
| 214 | + - 36 | ||
| 215 | + - (this.hasRightFollow() ? (19 + 6 + this.getTextWidth(this.getFollowText(), $r('app.float.font_size_13'))) : 0) | ||
| 216 | + - this.getTextWidth(DateTimeUtils.getCommentTime(Number.parseFloat(this.publishTime)), $r("app.float.font_size_12")) | ||
| 217 | + ) | ||
| 218 | + }) | ||
| 206 | } | 219 | } |
| 207 | 220 | ||
| 208 | } | 221 | } |
| @@ -226,7 +239,7 @@ export struct RmhTitle { | @@ -226,7 +239,7 @@ export struct RmhTitle { | ||
| 226 | .margin({right: 3}) | 239 | .margin({right: 3}) |
| 227 | } | 240 | } |
| 228 | 241 | ||
| 229 | - Text(Number(this.followStatus) === 0 ? '关注' : '已关注') | 242 | + Text(this.getFollowText()) |
| 230 | .fontSize($r('app.float.font_size_13')) | 243 | .fontSize($r('app.float.font_size_13')) |
| 231 | .fontWeight(600) | 244 | .fontWeight(600) |
| 232 | .fontColor(Number(this.followStatus) === 0 ? $r('app.color.color_ED2800') : 0xc6c6c6) | 245 | .fontColor(Number(this.followStatus) === 0 ? $r('app.color.color_ED2800') : 0xc6c6c6) |
| @@ -266,10 +279,10 @@ export struct RmhTitle { | @@ -266,10 +279,10 @@ export struct RmhTitle { | ||
| 266 | } | 279 | } |
| 267 | 280 | ||
| 268 | // 获取文本宽度 | 281 | // 获取文本宽度 |
| 269 | - private getTextWidth(text: string) { | 282 | + private getTextWidth(text: string, fontSize: Resource) { |
| 270 | let size = measure.measureTextSize({ | 283 | let size = measure.measureTextSize({ |
| 271 | textContent: text, | 284 | textContent: text, |
| 272 | - fontSize: $r("app.float.font_size_12") | 285 | + fontSize: fontSize |
| 273 | }) | 286 | }) |
| 274 | return px2vp(Number(size.width)) | 287 | return px2vp(Number(size.width)) |
| 275 | } | 288 | } |
-
Please register or login to post a comment