Showing
11 changed files
with
145 additions
and
40 deletions
| @@ -4,6 +4,7 @@ import { ProcessUtils } from 'wdRouter'; | @@ -4,6 +4,7 @@ import { ProcessUtils } from 'wdRouter'; | ||
| 4 | import { CardSourceInfo } from '../cardCommon/CardSourceInfo'; | 4 | import { CardSourceInfo } from '../cardCommon/CardSourceInfo'; |
| 5 | import { CardMediaInfo } from '../cardCommon/CardMediaInfo'; | 5 | import { CardMediaInfo } from '../cardCommon/CardMediaInfo'; |
| 6 | import { Notes } from './notes'; | 6 | import { Notes } from './notes'; |
| 7 | +import { getNotesContentWidth } from '../../utils/FuncUtils' | ||
| 7 | import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; | 8 | import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; |
| 8 | import { InfomationCardClick } from '../../utils/infomationCardClick'; | 9 | import { InfomationCardClick } from '../../utils/infomationCardClick'; |
| 9 | import { SearchShowRed, textItem, titleInitRes } from '../../utils/searchShowRed'; | 10 | import { SearchShowRed, textItem, titleInitRes } from '../../utils/searchShowRed'; |
| @@ -221,7 +222,13 @@ export struct Card10ComponentTimelineItem { | @@ -221,7 +222,13 @@ export struct Card10ComponentTimelineItem { | ||
| 221 | .fontColor(this.isRead ? 0x848484 : '#222222') | 222 | .fontColor(this.isRead ? 0x848484 : '#222222') |
| 222 | .maxLines(2) | 223 | .maxLines(2) |
| 223 | .textOverflow({ overflow: TextOverflow.Ellipsis }) | 224 | .textOverflow({ overflow: TextOverflow.Ellipsis }) |
| 224 | - .textIndent(this.slideItem.objectType == '5' ? 38 : 0) | 225 | + .textIndent( |
| 226 | + getNotesContentWidth( | ||
| 227 | + this.contentDTO.seoTags || this.contentDTO.newTags, | ||
| 228 | + this.contentDTO.objectType, | ||
| 229 | + this.contentDTO.objectLevel | ||
| 230 | + ) | ||
| 231 | + ) | ||
| 225 | }.alignContent(Alignment.TopStart) | 232 | }.alignContent(Alignment.TopStart) |
| 226 | 233 | ||
| 227 | Blank() | 234 | Blank() |
| @@ -264,7 +271,13 @@ export struct Card10ComponentTimelineItem { | @@ -264,7 +271,13 @@ export struct Card10ComponentTimelineItem { | ||
| 264 | .fontColor($r('app.color.color_222222')) | 271 | .fontColor($r('app.color.color_222222')) |
| 265 | .maxLines(2) | 272 | .maxLines(2) |
| 266 | .textOverflow({ overflow: TextOverflow.Ellipsis }) | 273 | .textOverflow({ overflow: TextOverflow.Ellipsis }) |
| 267 | - .textIndent(this.slideItem.objectType == '5' ? 38 : 0) | 274 | + .textIndent( |
| 275 | + getNotesContentWidth( | ||
| 276 | + this.contentDTO.seoTags || this.contentDTO.newTags, | ||
| 277 | + this.contentDTO.objectType, | ||
| 278 | + this.contentDTO.objectLevel | ||
| 279 | + ) | ||
| 280 | + ) | ||
| 268 | }.alignContent(Alignment.TopStart) | 281 | }.alignContent(Alignment.TopStart) |
| 269 | 282 | ||
| 270 | //bottom 评论等信息 | 283 | //bottom 评论等信息 |
| @@ -5,6 +5,7 @@ import { CommonConstants } from 'wdConstant'; | @@ -5,6 +5,7 @@ import { CommonConstants } from 'wdConstant'; | ||
| 5 | import { ProcessUtils } from 'wdRouter'; | 5 | import { ProcessUtils } from 'wdRouter'; |
| 6 | import { CardSourceInfo } from '../cardCommon/CardSourceInfo'; | 6 | import { CardSourceInfo } from '../cardCommon/CardSourceInfo'; |
| 7 | import { Notes } from './notes'; | 7 | import { Notes } from './notes'; |
| 8 | +import { getNotesContentWidth } from '../../utils/FuncUtils' | ||
| 8 | import { persistentStorage, hasClicked } from '../../utils/persistentStorage'; | 9 | import { persistentStorage, hasClicked } from '../../utils/persistentStorage'; |
| 9 | import { InfomationCardClick } from '../../utils/infomationCardClick' | 10 | import { InfomationCardClick } from '../../utils/infomationCardClick' |
| 10 | import { SearchShowRed, titleInitRes, textItem } from '../../utils/searchShowRed'; | 11 | import { SearchShowRed, titleInitRes, textItem } from '../../utils/searchShowRed'; |
| @@ -73,10 +74,13 @@ export struct Card11Component { | @@ -73,10 +74,13 @@ export struct Card11Component { | ||
| 73 | .maxLines(3) | 74 | .maxLines(3) |
| 74 | .textOverflow({ overflow: TextOverflow.Ellipsis }) | 75 | .textOverflow({ overflow: TextOverflow.Ellipsis }) |
| 75 | .width(CommonConstants.FULL_WIDTH) | 76 | .width(CommonConstants.FULL_WIDTH) |
| 76 | - .textIndent((this.contentDTO.newTags?.length || this.contentDTO.seoTags?.length) > 2 && | ||
| 77 | - (this.contentDTO.newTags?.length || this.contentDTO.seoTags?.length) < 5 ? 58 : | ||
| 78 | - ((this.contentDTO.newTags?.length > 0 || this.contentDTO.seoTags?.length > 0) || this.contentDTO.objectType == '5' || this.contentDTO.top === 1) ? 35 : | ||
| 79 | - 0 ) | 77 | + .textIndent( |
| 78 | + getNotesContentWidth( | ||
| 79 | + this.contentDTO.seoTags || this.contentDTO.newTags, | ||
| 80 | + this.contentDTO.objectType, | ||
| 81 | + this.contentDTO.objectLevel | ||
| 82 | + ) | ||
| 83 | + ) | ||
| 80 | }.alignContent(Alignment.TopStart) | 84 | }.alignContent(Alignment.TopStart) |
| 81 | 85 | ||
| 82 | 86 |
| @@ -10,6 +10,7 @@ import { InfomationCardClick } from '../../utils/infomationCardClick' | @@ -10,6 +10,7 @@ import { InfomationCardClick } from '../../utils/infomationCardClick' | ||
| 10 | import { SearchShowRed, titleInitRes, textItem } from '../../utils/searchShowRed'; | 10 | import { SearchShowRed, titleInitRes, textItem } from '../../utils/searchShowRed'; |
| 11 | import router from '@ohos.router' | 11 | import router from '@ohos.router' |
| 12 | import { Notes } from './notes'; | 12 | import { Notes } from './notes'; |
| 13 | +import { getNotesContentWidth } from '../../utils/FuncUtils' | ||
| 13 | 14 | ||
| 14 | const TAG = 'Card20Component'; | 15 | const TAG = 'Card20Component'; |
| 15 | 16 | ||
| @@ -90,10 +91,13 @@ export struct Card20Component { | @@ -90,10 +91,13 @@ export struct Card20Component { | ||
| 90 | .margin({bottom:8}) | 91 | .margin({bottom:8}) |
| 91 | .textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。 | 92 | .textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。 |
| 92 | .align(Alignment.Start) | 93 | .align(Alignment.Start) |
| 93 | - .textIndent((this.contentDTO.newTags?.length || this.contentDTO.seoTags?.length) > 2 && | ||
| 94 | - (this.contentDTO.newTags?.length || this.contentDTO.seoTags?.length) < 5 ? 58 : | ||
| 95 | - ((this.contentDTO.newTags?.length > 0 || this.contentDTO.seoTags?.length > 0) || this.contentDTO.objectType == '5' || this.contentDTO.top === 1) ? 35 : | ||
| 96 | - 0 ) | 94 | + .textIndent( |
| 95 | + getNotesContentWidth( | ||
| 96 | + this.contentDTO.seoTags || this.contentDTO.newTags, | ||
| 97 | + this.contentDTO.objectType, | ||
| 98 | + this.contentDTO.objectLevel | ||
| 99 | + ) | ||
| 100 | + ) | ||
| 97 | .width('100%') | 101 | .width('100%') |
| 98 | }.alignContent(Alignment.TopStart) | 102 | }.alignContent(Alignment.TopStart) |
| 99 | } | 103 | } |
| @@ -5,6 +5,7 @@ import { ProcessUtils } from 'wdRouter'; | @@ -5,6 +5,7 @@ import { ProcessUtils } from 'wdRouter'; | ||
| 5 | import { CardMediaInfo } from '../cardCommon/CardMediaInfo'; | 5 | import { CardMediaInfo } from '../cardCommon/CardMediaInfo'; |
| 6 | import { CardSourceInfo } from '../cardCommon/CardSourceInfo'; | 6 | import { CardSourceInfo } from '../cardCommon/CardSourceInfo'; |
| 7 | import { Notes } from './notes'; | 7 | import { Notes } from './notes'; |
| 8 | +import { getNotesContentWidth } from '../../utils/FuncUtils' | ||
| 8 | import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; | 9 | import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; |
| 9 | import { persistentStorage, hasClicked } from '../../utils/persistentStorage'; | 10 | import { persistentStorage, hasClicked } from '../../utils/persistentStorage'; |
| 10 | import { InfomationCardClick } from '../../utils/infomationCardClick'; | 11 | import { InfomationCardClick } from '../../utils/infomationCardClick'; |
| @@ -82,17 +83,16 @@ export struct Card2Component { | @@ -82,17 +83,16 @@ export struct Card2Component { | ||
| 82 | .lineHeight(25) | 83 | .lineHeight(25) |
| 83 | .textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。 | 84 | .textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。 |
| 84 | .align(Alignment.Start) | 85 | .align(Alignment.Start) |
| 85 | - .textIndent((this.contentDTO.newTags?.length || this.contentDTO.seoTags?.length) > 2 && | ||
| 86 | - (this.contentDTO.newTags?.length || this.contentDTO.seoTags?.length) < 5 ? 58 : | ||
| 87 | - ((this.contentDTO.newTags?.length > 0 || this.contentDTO.seoTags?.length > 0) || this.contentDTO.objectType == '5' || this.contentDTO.top === 1) ? 35 : | ||
| 88 | - 0 ) | 86 | + .textIndent( |
| 87 | + getNotesContentWidth( | ||
| 88 | + this.contentDTO.seoTags || this.contentDTO.newTags, | ||
| 89 | + this.contentDTO.objectType, | ||
| 90 | + this.contentDTO.objectLevel | ||
| 91 | + ) | ||
| 92 | + ) | ||
| 89 | .width('100%') | 93 | .width('100%') |
| 90 | }.alignContent(Alignment.TopStart) | 94 | }.alignContent(Alignment.TopStart) |
| 91 | 95 | ||
| 92 | - //.textIndent(this.contentDTO.objectType == '5' ? 35 : 0) | ||
| 93 | - // } | ||
| 94 | - // .alignContent(Alignment.TopStart) | ||
| 95 | - | ||
| 96 | //大图 | 96 | //大图 |
| 97 | Stack() { | 97 | Stack() { |
| 98 | Image(this.loadImg ? this.contentDTO.coverUrl : '') | 98 | Image(this.loadImg ? this.contentDTO.coverUrl : '') |
| @@ -3,6 +3,7 @@ import { CompDTO, ContentDTO } from 'wdBean'; | @@ -3,6 +3,7 @@ import { CompDTO, ContentDTO } from 'wdBean'; | ||
| 3 | import { ProcessUtils } from 'wdRouter'; | 3 | import { ProcessUtils } from 'wdRouter'; |
| 4 | import { CardSourceInfo } from '../cardCommon/CardSourceInfo'; | 4 | import { CardSourceInfo } from '../cardCommon/CardSourceInfo'; |
| 5 | import { Notes } from './notes'; | 5 | import { Notes } from './notes'; |
| 6 | +import { getNotesContentWidth } from '../../utils/FuncUtils' | ||
| 6 | import { persistentStorage, hasClicked } from '../../utils/persistentStorage'; | 7 | import { persistentStorage, hasClicked } from '../../utils/persistentStorage'; |
| 7 | import { InfomationCardClick } from '../../utils/infomationCardClick' | 8 | import { InfomationCardClick } from '../../utils/infomationCardClick' |
| 8 | import { SearchShowRed, titleInitRes, textItem } from '../../utils/searchShowRed'; | 9 | import { SearchShowRed, titleInitRes, textItem } from '../../utils/searchShowRed'; |
| @@ -69,10 +70,13 @@ export struct Card3Component { | @@ -69,10 +70,13 @@ export struct Card3Component { | ||
| 69 | .fontSize($r("app.float.font_size_18")) | 70 | .fontSize($r("app.float.font_size_18")) |
| 70 | .fontColor(this.clicked ? 0x848484 : $r("app.color.color_222222")) | 71 | .fontColor(this.clicked ? 0x848484 : $r("app.color.color_222222")) |
| 71 | .width(CommonConstants.FULL_WIDTH) | 72 | .width(CommonConstants.FULL_WIDTH) |
| 72 | - .textIndent((this.contentDTO.newTags?.length || this.contentDTO.seoTags?.length) > 2 && | ||
| 73 | - (this.contentDTO.newTags?.length || this.contentDTO.seoTags?.length) < 5 ? 58 : | ||
| 74 | - ((this.contentDTO.newTags?.length > 0 || this.contentDTO.seoTags?.length > 0) || this.contentDTO.objectType == '5' || this.contentDTO.top === 1) ? 35 : | ||
| 75 | - 0 ) | 73 | + .textIndent( |
| 74 | + getNotesContentWidth( | ||
| 75 | + this.contentDTO.seoTags || this.contentDTO.newTags, | ||
| 76 | + this.contentDTO.objectType, | ||
| 77 | + this.contentDTO.objectLevel | ||
| 78 | + ) | ||
| 79 | + ) | ||
| 76 | }.alignContent(Alignment.TopStart) | 80 | }.alignContent(Alignment.TopStart) |
| 77 | 81 | ||
| 78 | // 评论等信息 | 82 | // 评论等信息 |
| @@ -5,6 +5,7 @@ import { CardSourceInfo } from '../cardCommon/CardSourceInfo' | @@ -5,6 +5,7 @@ import { CardSourceInfo } from '../cardCommon/CardSourceInfo' | ||
| 5 | import { CardMediaInfo } from '../cardCommon/CardMediaInfo' | 5 | import { CardMediaInfo } from '../cardCommon/CardMediaInfo' |
| 6 | import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; | 6 | import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; |
| 7 | import { Notes } from './notes'; | 7 | import { Notes } from './notes'; |
| 8 | +import { getNotesContentWidth } from '../../utils/FuncUtils' | ||
| 8 | import { persistentStorage, hasClicked } from '../../utils/persistentStorage'; | 9 | import { persistentStorage, hasClicked } from '../../utils/persistentStorage'; |
| 9 | import { InfomationCardClick } from '../../utils/infomationCardClick' | 10 | import { InfomationCardClick } from '../../utils/infomationCardClick' |
| 10 | import { SearchShowRed, titleInitRes, textItem } from '../../utils/searchShowRed'; | 11 | import { SearchShowRed, titleInitRes, textItem } from '../../utils/searchShowRed'; |
| @@ -80,10 +81,13 @@ export struct Card4Component { | @@ -80,10 +81,13 @@ export struct Card4Component { | ||
| 80 | .fontColor(this.clicked ? 0x848484 : $r('app.color.color_222222')) | 81 | .fontColor(this.clicked ? 0x848484 : $r('app.color.color_222222')) |
| 81 | .maxLines(3) | 82 | .maxLines(3) |
| 82 | .textOverflow({ overflow: TextOverflow.Ellipsis }) | 83 | .textOverflow({ overflow: TextOverflow.Ellipsis }) |
| 83 | - .textIndent((this.contentDTO.newTags?.length || this.contentDTO.seoTags?.length) > 2 && | ||
| 84 | - (this.contentDTO.newTags?.length || this.contentDTO.seoTags?.length) < 5 ? 58 : | ||
| 85 | - ((this.contentDTO.newTags?.length > 0 || this.contentDTO.seoTags?.length > 0) || this.contentDTO.objectType == '5' || this.contentDTO.top === 1) ? 35 : | ||
| 86 | - 0 ) | 84 | + .textIndent( |
| 85 | + getNotesContentWidth( | ||
| 86 | + this.contentDTO.seoTags || this.contentDTO.newTags, | ||
| 87 | + this.contentDTO.objectType, | ||
| 88 | + this.contentDTO.objectLevel | ||
| 89 | + ) | ||
| 90 | + ) | ||
| 87 | .width('100%') | 91 | .width('100%') |
| 88 | }.alignContent(Alignment.TopStart) | 92 | }.alignContent(Alignment.TopStart) |
| 89 | //新闻标题 | 93 | //新闻标题 |
| @@ -3,6 +3,7 @@ import { CommonConstants } from 'wdConstant'; | @@ -3,6 +3,7 @@ import { CommonConstants } from 'wdConstant'; | ||
| 3 | import { ProcessUtils } from 'wdRouter'; | 3 | import { ProcessUtils } from 'wdRouter'; |
| 4 | import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; | 4 | import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; |
| 5 | import { Notes } from './notes'; | 5 | import { Notes } from './notes'; |
| 6 | +import { getNotesContentWidth } from '../../utils/FuncUtils' | ||
| 6 | import { persistentStorage, hasClicked } from '../../utils/persistentStorage'; | 7 | import { persistentStorage, hasClicked } from '../../utils/persistentStorage'; |
| 7 | import { InfomationCardClick } from '../../utils/infomationCardClick' | 8 | import { InfomationCardClick } from '../../utils/infomationCardClick' |
| 8 | import { SearchShowRed, titleInitRes, textItem } from '../../utils/searchShowRed'; | 9 | import { SearchShowRed, titleInitRes, textItem } from '../../utils/searchShowRed'; |
| @@ -110,10 +111,13 @@ export struct Card5Component { | @@ -110,10 +111,13 @@ export struct Card5Component { | ||
| 110 | .maxLines(2) | 111 | .maxLines(2) |
| 111 | .align(Alignment.TopStart) | 112 | .align(Alignment.TopStart) |
| 112 | .textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。 | 113 | .textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。 |
| 113 | - .textIndent((this.contentDTO.newTags?.length || this.contentDTO.seoTags?.length) > 2 && | ||
| 114 | - (this.contentDTO.newTags?.length || this.contentDTO.seoTags?.length) < 5 ? 58 : | ||
| 115 | - ((this.contentDTO.newTags?.length > 0 || this.contentDTO.seoTags?.length > 0) || this.contentDTO.objectType == '5' || this.contentDTO.top === 1) ? 35 : | ||
| 116 | - 0 ) | 114 | + .textIndent( |
| 115 | + getNotesContentWidth( | ||
| 116 | + this.contentDTO.seoTags || this.contentDTO.newTags, | ||
| 117 | + this.contentDTO.objectType, | ||
| 118 | + this.contentDTO.objectLevel | ||
| 119 | + ) | ||
| 120 | + ) | ||
| 117 | }.alignContent(Alignment.TopStart) | 121 | }.alignContent(Alignment.TopStart) |
| 118 | } | 122 | } |
| 119 | .justifyContent(FlexAlign.Start) | 123 | .justifyContent(FlexAlign.Start) |
| @@ -4,6 +4,7 @@ import { ProcessUtils } from 'wdRouter'; | @@ -4,6 +4,7 @@ import { ProcessUtils } from 'wdRouter'; | ||
| 4 | import { CardSourceInfo } from '../cardCommon/CardSourceInfo'; | 4 | import { CardSourceInfo } from '../cardCommon/CardSourceInfo'; |
| 5 | import { CardMediaInfo } from '../cardCommon/CardMediaInfo'; | 5 | import { CardMediaInfo } from '../cardCommon/CardMediaInfo'; |
| 6 | import { Notes } from './notes'; | 6 | import { Notes } from './notes'; |
| 7 | +import { getNotesContentWidth } from '../../utils/FuncUtils'; | ||
| 7 | import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; | 8 | import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; |
| 8 | import { Logger } from 'wdKit/Index'; | 9 | import { Logger } from 'wdKit/Index'; |
| 9 | import { persistentStorage, hasClicked } from '../../utils/persistentStorage'; | 10 | import { persistentStorage, hasClicked } from '../../utils/persistentStorage'; |
| @@ -81,10 +82,13 @@ export struct Card6Component { | @@ -81,10 +82,13 @@ export struct Card6Component { | ||
| 81 | .maxLines(this.contentDTO.appStyle === '6' ? 4 : 3) | 82 | .maxLines(this.contentDTO.appStyle === '6' ? 4 : 3) |
| 82 | .alignSelf(ItemAlign.Start) | 83 | .alignSelf(ItemAlign.Start) |
| 83 | .textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。 | 84 | .textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。 |
| 84 | - .textIndent((this.contentDTO.newTags?.length || this.contentDTO.seoTags?.length) > 2 && | ||
| 85 | - (this.contentDTO.newTags?.length || this.contentDTO.seoTags?.length) < 5 ? (12 + (this.contentDTO.newTags?.length || this.contentDTO.seoTags?.length) * 11) : | ||
| 86 | - ((this.contentDTO.newTags?.length > 0 || this.contentDTO.seoTags?.length > 0) || this.contentDTO.objectType == '5' || this.contentDTO.top === 1) ? 35 : | ||
| 87 | - 0 ) | 85 | + .textIndent( |
| 86 | + getNotesContentWidth( | ||
| 87 | + this.contentDTO.seoTags || this.contentDTO.newTags, | ||
| 88 | + this.contentDTO.objectType, | ||
| 89 | + this.contentDTO.objectLevel | ||
| 90 | + ) | ||
| 91 | + ) | ||
| 88 | .width('100%') | 92 | .width('100%') |
| 89 | } | 93 | } |
| 90 | .alignContent(Alignment.TopStart) | 94 | .alignContent(Alignment.TopStart) |
| @@ -4,6 +4,7 @@ | @@ -4,6 +4,7 @@ | ||
| 4 | 14动态图文,15动态视频16问政;100人民号,101标签 | 4 | 14动态图文,15动态视频16问政;100人民号,101标签 |
| 5 | * objectLevel: 对象分类;频道(1:一级频道,2:二级频道),专题(21:文章专题,22:音频专题,23:直播专题,24:话题专题) | 5 | * objectLevel: 对象分类;频道(1:一级频道,2:二级频道),专题(21:文章专题,22:音频专题,23:直播专题,24:话题专题) |
| 6 | */ | 6 | */ |
| 7 | +import { returnTypeTitleFn } from '../../utils/FuncUtils' | ||
| 7 | 8 | ||
| 8 | @Preview | 9 | @Preview |
| 9 | @Component | 10 | @Component |
| @@ -12,9 +13,11 @@ export struct Notes { | @@ -12,9 +13,11 @@ export struct Notes { | ||
| 12 | @State objectLevel: number | string = -1 | 13 | @State objectLevel: number | string = -1 |
| 13 | @State newTags: string = '' | 14 | @State newTags: string = '' |
| 14 | @State seoTags: string = '' | 15 | @State seoTags: string = '' |
| 16 | + @State marginTop: number = 0; | ||
| 17 | + | ||
| 15 | build() { | 18 | build() { |
| 16 | if (this.returnTypeTitleFn()) { | 19 | if (this.returnTypeTitleFn()) { |
| 17 | - Text(this.returnTypeTitleFn()) | 20 | + Text(returnTypeTitleFn(this.newTags, this.objectType, this.objectLevel)) |
| 18 | .fontSize($r('app.float.font_size_11')) | 21 | .fontSize($r('app.float.font_size_11')) |
| 19 | .padding({ | 22 | .padding({ |
| 20 | left: 4, | 23 | left: 4, |
| @@ -25,7 +28,7 @@ export struct Notes { | @@ -25,7 +28,7 @@ export struct Notes { | ||
| 25 | .linearGradient({ angle: 90, colors: [['#FFFF2B00', 0.0], ['#FFFE6A00', 1.0]] }) | 28 | .linearGradient({ angle: 90, colors: [['#FFFF2B00', 0.0], ['#FFFE6A00', 1.0]] }) |
| 26 | .fontColor(Color.White)// .borderRadius($r('app.float.button_border_radius')) | 29 | .fontColor(Color.White)// .borderRadius($r('app.float.button_border_radius')) |
| 27 | .borderRadius(2) | 30 | .borderRadius(2) |
| 28 | - .margin({ top: 1 }) | 31 | + .margin({ top: this.marginTop}) |
| 29 | } | 32 | } |
| 30 | } | 33 | } |
| 31 | 34 |
| @@ -242,10 +242,13 @@ struct CarouselLayout01CardView { | @@ -242,10 +242,13 @@ struct CarouselLayout01CardView { | ||
| 242 | .align(Alignment.Bottom) | 242 | .align(Alignment.Bottom) |
| 243 | .maxLines(CompUtils.MAX_LINES_2) | 243 | .maxLines(CompUtils.MAX_LINES_2) |
| 244 | .textOverflow({ overflow: TextOverflow.Ellipsis }) | 244 | .textOverflow({ overflow: TextOverflow.Ellipsis }) |
| 245 | - .textIndent((this.item.newTags?.length || this.item.seoTags?.length) > 2 && | ||
| 246 | - (this.item.newTags?.length ||this.item.seoTags?.length) < 5 ? 58 : | ||
| 247 | - ((this.item.newTags?.length > 0 || this.item.seoTags?.length > 0) ||this.item.objectType == '5') ? 35 : | ||
| 248 | - 0 ) | 245 | + .textIndent( |
| 246 | + getNotesContentWidth( | ||
| 247 | + this.item.seoTags || this.item.newTags, | ||
| 248 | + this.item.objectType, | ||
| 249 | + this.item.objectLevel | ||
| 250 | + ) | ||
| 251 | + ) | ||
| 249 | } | 252 | } |
| 250 | // .height(39) | 253 | // .height(39) |
| 251 | .padding({ | 254 | .padding({ |
| @@ -5,6 +5,7 @@ | @@ -5,6 +5,7 @@ | ||
| 5 | * @param curve:动画区线 | 5 | * @param curve:动画区线 |
| 6 | */ | 6 | */ |
| 7 | import { ImageViewerConstants } from '../constants/ImageViewerConstants'; | 7 | import { ImageViewerConstants } from '../constants/ImageViewerConstants'; |
| 8 | +import measure from '@ohos.measure' | ||
| 8 | 9 | ||
| 9 | export function runWithAnimation( | 10 | export function runWithAnimation( |
| 10 | fn: Function, | 11 | fn: Function, |
| @@ -14,3 +15,64 @@ export function runWithAnimation( | @@ -14,3 +15,64 @@ export function runWithAnimation( | ||
| 14 | fn(); | 15 | fn(); |
| 15 | }) | 16 | }) |
| 16 | } | 17 | } |
| 18 | + | ||
| 19 | +export function getNotesContentWidth( | ||
| 20 | + newTags: string, | ||
| 21 | + objectType: number | string, | ||
| 22 | + objectLevel: number | string, | ||
| 23 | + fontSize?: string | number | Resource | ||
| 24 | +) { | ||
| 25 | + let textContent: string = returnTypeTitleFn(newTags, objectType, objectLevel) | ||
| 26 | + let px = 0 | ||
| 27 | + const paddingRightAndLeft = vp2px(8) | ||
| 28 | + const marginRight = vp2px(6); | ||
| 29 | + | ||
| 30 | + if(objectType == '5'){ | ||
| 31 | + textContent = returnTypeTitleFn('', objectType, objectLevel) | ||
| 32 | + } else { | ||
| 33 | + textContent = returnTypeTitleFn(newTags) | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + if (textContent) { | ||
| 37 | + px = measure.measureText({ | ||
| 38 | + textContent: textContent, | ||
| 39 | + fontSize: fontSize || $r('app.float.font_size_11') | ||
| 40 | + }) | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + if (px) { | ||
| 44 | + px = px + paddingRightAndLeft + marginRight | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + return px2vp(px) | ||
| 48 | +} | ||
| 49 | + | ||
| 50 | +/** | ||
| 51 | + * 根据接口返回字段显示不同的内容 | ||
| 52 | + * @param newTags | ||
| 53 | + * @param objectType | ||
| 54 | + * @param objectLevel | ||
| 55 | + * @returns | ||
| 56 | + */ | ||
| 57 | +export function returnTypeTitleFn( | ||
| 58 | + newTags?: string, | ||
| 59 | + objectType?: number | string, | ||
| 60 | + objectLevel?: number | string | ||
| 61 | +): string { | ||
| 62 | + if (newTags) { | ||
| 63 | + return newTags | ||
| 64 | + } | ||
| 65 | + if (objectType == 5) { | ||
| 66 | + if (objectLevel == 24) { | ||
| 67 | + return '调查' | ||
| 68 | + } | ||
| 69 | + return '专题' | ||
| 70 | + } | ||
| 71 | + if (objectType == 10) { | ||
| 72 | + return 'H5' | ||
| 73 | + } | ||
| 74 | + if (objectType == 8) { | ||
| 75 | + return '文章' | ||
| 76 | + } | ||
| 77 | + return '' | ||
| 78 | +} |
-
Please register or login to post a comment