Showing
1 changed file
with
28 additions
and
5 deletions
| @@ -86,6 +86,9 @@ export struct DynamicDetailComponent { | @@ -86,6 +86,9 @@ export struct DynamicDetailComponent { | ||
| 86 | @State isScrollTop: boolean = true | 86 | @State isScrollTop: boolean = true |
| 87 | @State executedStartTime: number = new Date().getTime() | 87 | @State executedStartTime: number = new Date().getTime() |
| 88 | 88 | ||
| 89 | + @State onePicW: number = 0; // 只有一张图时候图片的宽度 | ||
| 90 | + @State onePicH: number = 0; // 只有一张图时候图片的高度 | ||
| 91 | + | ||
| 89 | pageParam: ParamType = {} | 92 | pageParam: ParamType = {} |
| 90 | commentListAreaInfo?: Area | 93 | commentListAreaInfo?: Area |
| 91 | lastTimeoutId?: number | 94 | lastTimeoutId?: number |
| @@ -361,17 +364,37 @@ export struct DynamicDetailComponent { | @@ -361,17 +364,37 @@ export struct DynamicDetailComponent { | ||
| 361 | ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList, index) | 364 | ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList, index) |
| 362 | }) | 365 | }) |
| 363 | } else { | 366 | } else { |
| 367 | + // GridCol({ | ||
| 368 | + // span: { xs: 8 } | ||
| 369 | + // }) { | ||
| 370 | + // Image(item.picPath) | ||
| 371 | + // .width('100%') | ||
| 372 | + // .borderRadius(this.caclImageRadius(index)) | ||
| 373 | + // .autoResize(true) | ||
| 374 | + // .opacity(!item.width && !item.height ? 0 : 1) | ||
| 375 | + // .onComplete(callback => { | ||
| 376 | + // item.width = callback?.width || 0; | ||
| 377 | + // item.height = callback?.height || 0; | ||
| 378 | + // }) | ||
| 379 | + // } | ||
| 364 | GridCol({ | 380 | GridCol({ |
| 365 | - span: { xs: 8 } | 381 | + span: this.onePicW > this.onePicH ? 12 : 8 |
| 366 | }) { | 382 | }) { |
| 367 | Image(item.picPath) | 383 | Image(item.picPath) |
| 384 | + .backgroundColor(0xf5f5f5) | ||
| 368 | .width('100%') | 385 | .width('100%') |
| 369 | - .borderRadius(this.caclImageRadius(index)) | ||
| 370 | .autoResize(true) | 386 | .autoResize(true) |
| 387 | + .objectFit(ImageFit.Cover) | ||
| 388 | + .autoResize(true) | ||
| 389 | + .aspectRatio(3/4) | ||
| 390 | + .borderRadius(this.caclImageRadius(index)) | ||
| 391 | + .borderStyle(BorderStyle.Solid) | ||
| 392 | + .borderWidth(0.5) | ||
| 393 | + .borderColor($r('app.color.color_0D000000')) | ||
| 371 | .opacity(!item.width && !item.height ? 0 : 1) | 394 | .opacity(!item.width && !item.height ? 0 : 1) |
| 372 | - .onComplete(callback => { | ||
| 373 | - item.width = callback?.width || 0; | ||
| 374 | - item.height = callback?.height || 0; | 395 | + .onComplete((event?) => { |
| 396 | + this.onePicW = event?.width || 0; | ||
| 397 | + this.onePicH = event?.height || 0; | ||
| 375 | }) | 398 | }) |
| 376 | } | 399 | } |
| 377 | .onClick(async (event: ClickEvent) => { | 400 | .onClick(async (event: ClickEvent) => { |
-
Please register or login to post a comment