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
guochunsong
2024-02-04 18:32:32 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
07d40aeb4271dd929788fef9c4b179cfaa347cc3
07d40aeb
1 parent
a4b313ed
优化过长问题,合并datetimeUtils代码
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
14 deletions
sight_harmony/wdComponent/src/main/ets/components/view/AlbumCardComponent.ets
sight_harmony/wdComponent/src/main/ets/components/view/SingleImageCardAppComponent.ets
sight_harmony/wdComponent/src/main/ets/components/view/SingleImageCardComponent.ets
sight_harmony/wdKit/src/main/ets/utils/DateTimeUtils.ts
sight_harmony/wdComponent/src/main/ets/components/view/AlbumCardComponent.ets
View file @
07d40ae
...
...
@@ -99,33 +99,32 @@ export struct AlbumCardComponent {
.height(154)
Row() {
if (this.compDTO.operDataList[0].source) {
Text(this.compDTO.operDataList[0].source)
.fontSize(13)
.fontColor(0xB0B0B0)
.margin({
left: 16
})
Image($r('app.media.point'))
.width(16)
.height(16)
Text('45分钟')
}
if (this.compDTO.operDataList[0].publishTime && this.compDTO.operDataList[0].publishTime.length === 13) {
Text(DateTimeUtils.getCommentTime(Number.parseFloat(this.compDTO.operDataList[0].publishTime)))
.fontSize(13)
.fontColor(0xB0B0B0)
}
Text('328评')
.fontSize(13)
.fontColor(0xB0B0B0)
.margin({
left: 6
})
}
}
.margin({ left: 24 })
.width(375)
.height(16)
.id('label')
}
.width(375)
// .backgroundColor(0x000000)
}
}
\ No newline at end of file
...
...
sight_harmony/wdComponent/src/main/ets/components/view/SingleImageCardAppComponent.ets
View file @
07d40ae
...
...
@@ -95,7 +95,6 @@ export struct SingleImageCardAppComponent {
.width(16)
.height(16)
.margin(10)
.backgroundColor(Color.Brown)
}.width(FULL_PARENT)
.justifyContent(FlexAlign.SpaceBetween)
}
...
...
sight_harmony/wdComponent/src/main/ets/components/view/SingleImageCardComponent.ets
View file @
07d40ae
...
...
@@ -34,20 +34,27 @@ export struct SingleImageCardComponent {
.textOverflow({ overflow: TextOverflow.Ellipsis })// 超出的部分显示省略号。
.height("80%")
Row() {
Text(this.compDTO.operDataList[0].source ? this.compDTO.operDataList[0].source : '人民日报')
if (this.compDTO.operDataList[0].source) {
Text(this.compDTO.operDataList[0].source)
.height(40)
.fontSize(14
)
.fontSize($r('app.float.font_size_12')
)
.fontColor(Color.Gray)
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })// 超出的部分显示省略号。
.width('50%')
Image($r('app.media.point'))
.width(16)
.height(16)
Text('45分钟前')
}
if (this.compDTO.operDataList[0].publishTime && this.compDTO.operDataList[0].publishTime.length === 13) {
Text(DateTimeUtils.getCommentTime(Number.parseFloat(this.compDTO.operDataList[0].publishTime)))
.height(40)
.fontSize(14
)
.fontSize($r('app.float.font_size_12')
)
.fontColor(Color.Gray)
}
Text(this.compDTO.operDataList[0].visitorComment + '评')
.height(40)
.fontSize(
14
)
.fontSize(
$r('app.float.font_size_12')
)
.fontColor(Color.Gray)
.padding({
left: 10
...
...
sight_harmony/wdKit/src/main/ets/utils/DateTimeUtils.ts
View file @
07d40ae
...
...
@@ -45,6 +45,7 @@ export class DateTimeUtils {
static
readonly
PATTERN_DATE_TIME_MS
:
string
=
'yyyyMMddHHmmssSSS'
;
// 时间中包含毫秒
static
readonly
PATTERN_DATE_TIME_WITHOUT_SECOND
:
string
=
'yyyyMMddHHmm'
;
// 时间中不包含秒
static
readonly
PATTERN_DATE_TIME_SIMPLIFY
:
string
=
'MM/dd HH:mm'
;
// 精简的日期+时间(不包含年份和秒), 月/日 时:分
static
readonly
PATTERN_DATE_SLASH_WITHOUT_YEAR2
:
string
=
'MM-dd'
;
// 日期中不包含年份
// 仅日期格式(不包含时间)
static
readonly
PATTERN_DATE_DEFAULT
:
string
=
'yyyyMMdd'
;
// 年月日
...
...
@@ -428,6 +429,34 @@ export class DateTimeUtils {
static
isBefore
(
_date
:
Date
,
dateToCompare
:
Date
):
boolean
{
return
_date
.
getTime
()
<
dateToCompare
.
getTime
();
}
/**
* 获取文章发布时间
* */
public
static
getCommentTime
(
publishTime
:
number
):
string
{
let
currentTime
:
number
=
new
Date
().
getTime
();
let
timeGap
=
currentTime
-
publishTime
;
let
timeStr
=
""
if
(
timeGap
>=
60
*
60
*
1000
*
48
)
{
let
publishYear
=
new
Date
(
publishTime
).
getFullYear
();
let
currentYear
=
new
Date
(
currentTime
).
getFullYear
();
if
(
publishYear
==
currentYear
)
{
timeStr
=
this
.
formatDate
(
publishTime
,
DateTimeUtils
.
PATTERN_DATE_SLASH_WITHOUT_YEAR2
)
}
else
{
timeStr
=
this
.
formatDate
(
publishTime
)
}
}
else
if
(
timeGap
>
60
*
60
*
1000
*
24
)
{
timeStr
=
Math
.
floor
(
timeGap
/
(
60
*
60
*
1000
*
24
))
+
"天前"
;
}
else
if
(
timeGap
>
60
*
60
*
1000
)
{
// 1小时-24小时
timeStr
=
Math
.
floor
(
timeGap
/
(
60
*
60
*
1000
))
+
"小时前"
;
}
else
if
(
timeGap
>
60
*
1000
)
{
// 1分钟-59分钟
timeStr
=
Math
.
floor
(
timeGap
/
(
60
*
1000
))
+
"分钟前"
;
}
else
{
// 1秒钟-59秒钟
timeStr
=
"刚刚"
;
}
return
timeStr
;
}
}
// const dateTimeUtils = new DateTimeUtils()
\ No newline at end of file
...
...
Please
register
or
login
to post a comment