Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
陈剑华
2024-08-22 16:21:46 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
26551e5fae0a9e503d8b8018a74101c20c0aef7e
26551e5f
1 parent
8002b7c2
fix: 标签问题优化
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
145 additions
and
40 deletions
sight_harmony/features/wdComponent/src/main/ets/components/cardview/Card10Component.ets
sight_harmony/features/wdComponent/src/main/ets/components/cardview/Card11Component.ets
sight_harmony/features/wdComponent/src/main/ets/components/cardview/Card20Component.ets
sight_harmony/features/wdComponent/src/main/ets/components/cardview/Card2Component.ets
sight_harmony/features/wdComponent/src/main/ets/components/cardview/Card3Component.ets
sight_harmony/features/wdComponent/src/main/ets/components/cardview/Card4Component.ets
sight_harmony/features/wdComponent/src/main/ets/components/cardview/Card5Component.ets
sight_harmony/features/wdComponent/src/main/ets/components/cardview/Card6Component.ets
sight_harmony/features/wdComponent/src/main/ets/components/cardview/notes.ets
sight_harmony/features/wdComponent/src/main/ets/components/compview/ZhCarouselLayout01.ets
sight_harmony/features/wdComponent/src/main/ets/utils/FuncUtils.ets
sight_harmony/features/wdComponent/src/main/ets/components/cardview/Card10Component.ets
View file @
26551e5
...
...
@@ -4,6 +4,7 @@ import { ProcessUtils } from 'wdRouter';
import { CardSourceInfo } from '../cardCommon/CardSourceInfo';
import { CardMediaInfo } from '../cardCommon/CardMediaInfo';
import { Notes } from './notes';
import { getNotesContentWidth } from '../../utils/FuncUtils'
import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
import { InfomationCardClick } from '../../utils/infomationCardClick';
import { SearchShowRed, textItem, titleInitRes } from '../../utils/searchShowRed';
...
...
@@ -221,7 +222,13 @@ export struct Card10ComponentTimelineItem {
.fontColor(this.isRead ? 0x848484 : '#222222')
.maxLines(2)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.textIndent(this.slideItem.objectType == '5' ? 38 : 0)
.textIndent(
getNotesContentWidth(
this.contentDTO.seoTags || this.contentDTO.newTags,
this.contentDTO.objectType,
this.contentDTO.objectLevel
)
)
}.alignContent(Alignment.TopStart)
Blank()
...
...
@@ -264,7 +271,13 @@ export struct Card10ComponentTimelineItem {
.fontColor($r('app.color.color_222222'))
.maxLines(2)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.textIndent(this.slideItem.objectType == '5' ? 38 : 0)
.textIndent(
getNotesContentWidth(
this.contentDTO.seoTags || this.contentDTO.newTags,
this.contentDTO.objectType,
this.contentDTO.objectLevel
)
)
}.alignContent(Alignment.TopStart)
//bottom 评论等信息
...
...
sight_harmony/features/wdComponent/src/main/ets/components/cardview/Card11Component.ets
View file @
26551e5
...
...
@@ -5,6 +5,7 @@ import { CommonConstants } from 'wdConstant';
import { ProcessUtils } from 'wdRouter';
import { CardSourceInfo } from '../cardCommon/CardSourceInfo';
import { Notes } from './notes';
import { getNotesContentWidth } from '../../utils/FuncUtils'
import { persistentStorage, hasClicked } from '../../utils/persistentStorage';
import { InfomationCardClick } from '../../utils/infomationCardClick'
import { SearchShowRed, titleInitRes, textItem } from '../../utils/searchShowRed';
...
...
@@ -73,10 +74,13 @@ export struct Card11Component {
.maxLines(3)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.width(CommonConstants.FULL_WIDTH)
.textIndent((this.contentDTO.newTags?.length || this.contentDTO.seoTags?.length) > 2 &&
(this.contentDTO.newTags?.length || this.contentDTO.seoTags?.length) < 5 ? 58 :
((this.contentDTO.newTags?.length > 0 || this.contentDTO.seoTags?.length > 0) || this.contentDTO.objectType == '5' || this.contentDTO.top === 1) ? 35 :
0 )
.textIndent(
getNotesContentWidth(
this.contentDTO.seoTags || this.contentDTO.newTags,
this.contentDTO.objectType,
this.contentDTO.objectLevel
)
)
}.alignContent(Alignment.TopStart)
...
...
sight_harmony/features/wdComponent/src/main/ets/components/cardview/Card20Component.ets
View file @
26551e5
...
...
@@ -10,6 +10,7 @@ import { InfomationCardClick } from '../../utils/infomationCardClick'
import { SearchShowRed, titleInitRes, textItem } from '../../utils/searchShowRed';
import router from '@ohos.router'
import { Notes } from './notes';
import { getNotesContentWidth } from '../../utils/FuncUtils'
const TAG = 'Card20Component';
...
...
@@ -90,10 +91,13 @@ export struct Card20Component {
.margin({bottom:8})
.textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。
.align(Alignment.Start)
.textIndent((this.contentDTO.newTags?.length || this.contentDTO.seoTags?.length) > 2 &&
(this.contentDTO.newTags?.length || this.contentDTO.seoTags?.length) < 5 ? 58 :
((this.contentDTO.newTags?.length > 0 || this.contentDTO.seoTags?.length > 0) || this.contentDTO.objectType == '5' || this.contentDTO.top === 1) ? 35 :
0 )
.textIndent(
getNotesContentWidth(
this.contentDTO.seoTags || this.contentDTO.newTags,
this.contentDTO.objectType,
this.contentDTO.objectLevel
)
)
.width('100%')
}.alignContent(Alignment.TopStart)
}
...
...
sight_harmony/features/wdComponent/src/main/ets/components/cardview/Card2Component.ets
View file @
26551e5
...
...
@@ -5,6 +5,7 @@ import { ProcessUtils } from 'wdRouter';
import { CardMediaInfo } from '../cardCommon/CardMediaInfo';
import { CardSourceInfo } from '../cardCommon/CardSourceInfo';
import { Notes } from './notes';
import { getNotesContentWidth } from '../../utils/FuncUtils'
import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
import { persistentStorage, hasClicked } from '../../utils/persistentStorage';
import { InfomationCardClick } from '../../utils/infomationCardClick';
...
...
@@ -82,17 +83,16 @@ export struct Card2Component {
.lineHeight(25)
.textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。
.align(Alignment.Start)
.textIndent((this.contentDTO.newTags?.length || this.contentDTO.seoTags?.length) > 2 &&
(this.contentDTO.newTags?.length || this.contentDTO.seoTags?.length) < 5 ? 58 :
((this.contentDTO.newTags?.length > 0 || this.contentDTO.seoTags?.length > 0) || this.contentDTO.objectType == '5' || this.contentDTO.top === 1) ? 35 :
0 )
.textIndent(
getNotesContentWidth(
this.contentDTO.seoTags || this.contentDTO.newTags,
this.contentDTO.objectType,
this.contentDTO.objectLevel
)
)
.width('100%')
}.alignContent(Alignment.TopStart)
//.textIndent(this.contentDTO.objectType == '5' ? 35 : 0)
// }
// .alignContent(Alignment.TopStart)
//大图
Stack() {
Image(this.loadImg ? this.contentDTO.coverUrl : '')
...
...
sight_harmony/features/wdComponent/src/main/ets/components/cardview/Card3Component.ets
View file @
26551e5
...
...
@@ -3,6 +3,7 @@ import { CompDTO, ContentDTO } from 'wdBean';
import { ProcessUtils } from 'wdRouter';
import { CardSourceInfo } from '../cardCommon/CardSourceInfo';
import { Notes } from './notes';
import { getNotesContentWidth } from '../../utils/FuncUtils'
import { persistentStorage, hasClicked } from '../../utils/persistentStorage';
import { InfomationCardClick } from '../../utils/infomationCardClick'
import { SearchShowRed, titleInitRes, textItem } from '../../utils/searchShowRed';
...
...
@@ -69,10 +70,13 @@ export struct Card3Component {
.fontSize($r("app.float.font_size_18"))
.fontColor(this.clicked ? 0x848484 : $r("app.color.color_222222"))
.width(CommonConstants.FULL_WIDTH)
.textIndent((this.contentDTO.newTags?.length || this.contentDTO.seoTags?.length) > 2 &&
(this.contentDTO.newTags?.length || this.contentDTO.seoTags?.length) < 5 ? 58 :
((this.contentDTO.newTags?.length > 0 || this.contentDTO.seoTags?.length > 0) || this.contentDTO.objectType == '5' || this.contentDTO.top === 1) ? 35 :
0 )
.textIndent(
getNotesContentWidth(
this.contentDTO.seoTags || this.contentDTO.newTags,
this.contentDTO.objectType,
this.contentDTO.objectLevel
)
)
}.alignContent(Alignment.TopStart)
// 评论等信息
...
...
sight_harmony/features/wdComponent/src/main/ets/components/cardview/Card4Component.ets
View file @
26551e5
...
...
@@ -5,6 +5,7 @@ import { CardSourceInfo } from '../cardCommon/CardSourceInfo'
import { CardMediaInfo } from '../cardCommon/CardMediaInfo'
import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
import { Notes } from './notes';
import { getNotesContentWidth } from '../../utils/FuncUtils'
import { persistentStorage, hasClicked } from '../../utils/persistentStorage';
import { InfomationCardClick } from '../../utils/infomationCardClick'
import { SearchShowRed, titleInitRes, textItem } from '../../utils/searchShowRed';
...
...
@@ -80,10 +81,13 @@ export struct Card4Component {
.fontColor(this.clicked ? 0x848484 : $r('app.color.color_222222'))
.maxLines(3)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.textIndent((this.contentDTO.newTags?.length || this.contentDTO.seoTags?.length) > 2 &&
(this.contentDTO.newTags?.length || this.contentDTO.seoTags?.length) < 5 ? 58 :
((this.contentDTO.newTags?.length > 0 || this.contentDTO.seoTags?.length > 0) || this.contentDTO.objectType == '5' || this.contentDTO.top === 1) ? 35 :
0 )
.textIndent(
getNotesContentWidth(
this.contentDTO.seoTags || this.contentDTO.newTags,
this.contentDTO.objectType,
this.contentDTO.objectLevel
)
)
.width('100%')
}.alignContent(Alignment.TopStart)
//新闻标题
...
...
sight_harmony/features/wdComponent/src/main/ets/components/cardview/Card5Component.ets
View file @
26551e5
...
...
@@ -3,6 +3,7 @@ import { CommonConstants } from 'wdConstant';
import { ProcessUtils } from 'wdRouter';
import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
import { Notes } from './notes';
import { getNotesContentWidth } from '../../utils/FuncUtils'
import { persistentStorage, hasClicked } from '../../utils/persistentStorage';
import { InfomationCardClick } from '../../utils/infomationCardClick'
import { SearchShowRed, titleInitRes, textItem } from '../../utils/searchShowRed';
...
...
@@ -110,10 +111,13 @@ export struct Card5Component {
.maxLines(2)
.align(Alignment.TopStart)
.textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。
.textIndent((this.contentDTO.newTags?.length || this.contentDTO.seoTags?.length) > 2 &&
(this.contentDTO.newTags?.length || this.contentDTO.seoTags?.length) < 5 ? 58 :
((this.contentDTO.newTags?.length > 0 || this.contentDTO.seoTags?.length > 0) || this.contentDTO.objectType == '5' || this.contentDTO.top === 1) ? 35 :
0 )
.textIndent(
getNotesContentWidth(
this.contentDTO.seoTags || this.contentDTO.newTags,
this.contentDTO.objectType,
this.contentDTO.objectLevel
)
)
}.alignContent(Alignment.TopStart)
}
.justifyContent(FlexAlign.Start)
...
...
sight_harmony/features/wdComponent/src/main/ets/components/cardview/Card6Component.ets
View file @
26551e5
...
...
@@ -4,6 +4,7 @@ import { ProcessUtils } from 'wdRouter';
import { CardSourceInfo } from '../cardCommon/CardSourceInfo';
import { CardMediaInfo } from '../cardCommon/CardMediaInfo';
import { Notes } from './notes';
import { getNotesContentWidth } from '../../utils/FuncUtils';
import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
import { Logger } from 'wdKit/Index';
import { persistentStorage, hasClicked } from '../../utils/persistentStorage';
...
...
@@ -81,10 +82,13 @@ export struct Card6Component {
.maxLines(this.contentDTO.appStyle === '6' ? 4 : 3)
.alignSelf(ItemAlign.Start)
.textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。
.textIndent((this.contentDTO.newTags?.length || this.contentDTO.seoTags?.length) > 2 &&
(this.contentDTO.newTags?.length || this.contentDTO.seoTags?.length) < 5 ? (12 + (this.contentDTO.newTags?.length || this.contentDTO.seoTags?.length) * 11) :
((this.contentDTO.newTags?.length > 0 || this.contentDTO.seoTags?.length > 0) || this.contentDTO.objectType == '5' || this.contentDTO.top === 1) ? 35 :
0 )
.textIndent(
getNotesContentWidth(
this.contentDTO.seoTags || this.contentDTO.newTags,
this.contentDTO.objectType,
this.contentDTO.objectLevel
)
)
.width('100%')
}
.alignContent(Alignment.TopStart)
...
...
sight_harmony/features/wdComponent/src/main/ets/components/cardview/notes.ets
View file @
26551e5
...
...
@@ -4,6 +4,7 @@
14动态图文,15动态视频16问政;100人民号,101标签
* objectLevel: 对象分类;频道(1:一级频道,2:二级频道),专题(21:文章专题,22:音频专题,23:直播专题,24:话题专题)
*/
import { returnTypeTitleFn } from '../../utils/FuncUtils'
@Preview
@Component
...
...
@@ -12,9 +13,11 @@ export struct Notes {
@State objectLevel: number | string = -1
@State newTags: string = ''
@State seoTags: string = ''
@State marginTop: number = 0;
build() {
if (this.returnTypeTitleFn()) {
Text(
this.returnTypeTitleFn(
))
Text(
returnTypeTitleFn(this.newTags, this.objectType, this.objectLevel
))
.fontSize($r('app.float.font_size_11'))
.padding({
left: 4,
...
...
@@ -25,7 +28,7 @@ export struct Notes {
.linearGradient({ angle: 90, colors: [['#FFFF2B00', 0.0], ['#FFFE6A00', 1.0]] })
.fontColor(Color.White)// .borderRadius($r('app.float.button_border_radius'))
.borderRadius(2)
.margin({ top:
1
})
.margin({ top:
this.marginTop
})
}
}
...
...
sight_harmony/features/wdComponent/src/main/ets/components/compview/ZhCarouselLayout01.ets
View file @
26551e5
...
...
@@ -242,10 +242,13 @@ struct CarouselLayout01CardView {
.align(Alignment.Bottom)
.maxLines(CompUtils.MAX_LINES_2)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.textIndent((this.item.newTags?.length || this.item.seoTags?.length) > 2 &&
(this.item.newTags?.length ||this.item.seoTags?.length) < 5 ? 58 :
((this.item.newTags?.length > 0 || this.item.seoTags?.length > 0) ||this.item.objectType == '5') ? 35 :
0 )
.textIndent(
getNotesContentWidth(
this.item.seoTags || this.item.newTags,
this.item.objectType,
this.item.objectLevel
)
)
}
// .height(39)
.padding({
...
...
sight_harmony/features/wdComponent/src/main/ets/utils/FuncUtils.ets
View file @
26551e5
...
...
@@ -5,6 +5,7 @@
* @param curve:动画区线
*/
import { ImageViewerConstants } from '../constants/ImageViewerConstants';
import measure from '@ohos.measure'
export function runWithAnimation(
fn: Function,
...
...
@@ -13,4 +14,65 @@ export function runWithAnimation(
animateTo({ duration: duration, curve: curve }, () => {
fn();
})
}
export function getNotesContentWidth(
newTags: string,
objectType: number | string,
objectLevel: number | string,
fontSize?: string | number | Resource
) {
let textContent: string = returnTypeTitleFn(newTags, objectType, objectLevel)
let px = 0
const paddingRightAndLeft = vp2px(8)
const marginRight = vp2px(6);
if(objectType == '5'){
textContent = returnTypeTitleFn('', objectType, objectLevel)
} else {
textContent = returnTypeTitleFn(newTags)
}
if (textContent) {
px = measure.measureText({
textContent: textContent,
fontSize: fontSize || $r('app.float.font_size_11')
})
}
if (px) {
px = px + paddingRightAndLeft + marginRight
}
return px2vp(px)
}
/**
* 根据接口返回字段显示不同的内容
* @param newTags
* @param objectType
* @param objectLevel
* @returns
*/
export function returnTypeTitleFn(
newTags?: string,
objectType?: number | string,
objectLevel?: number | string
): string {
if (newTags) {
return newTags
}
if (objectType == 5) {
if (objectLevel == 24) {
return '调查'
}
return '专题'
}
if (objectType == 10) {
return 'H5'
}
if (objectType == 8) {
return '文章'
}
return ''
}
\ No newline at end of file
...
...
Please
register
or
login
to post a comment