Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
store-assistant
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit b7e07a5b
authored
Oct 31, 2022
by
张晓玮
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'zhangxw_dev_3.0' into 'v3.0'
访问时间公用方法修改 See merge request
!115
2 parents
7c9d7a8c
560b3818
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
16 deletions
utils/format.js
utils/format.js
View file @
b7e07a5
...
...
@@ -48,28 +48,28 @@ export function commentTime(dateTimeStamp) {
let
time
=
dateTimeStamp
let
nowTime
=
new
Date
().
getTime
()
let
timeDifference
=
nowTime
-
time
let
minTime
=
60000
let
hourTime
=
minTime
*
60
let
dayTime
=
hourTime
*
24
let
weektTime
=
dayTime
*
7
let
monthTime
=
dayTime
*
30
let
yearTime
=
dayTime
*
365
if
(
parseInt
(
timeDifference
/
minTime
)
<=
5
)
{
//五分钟内就是刚刚
result
=
'刚刚'
}
else
if
(
parseInt
(
timeDifference
/
minTime
)
>
5
)
{
result
=
parseInt
(
timeDifference
/
minTime
)
+
'分钟前'
}
else
if
(
parseInt
(
timeDifference
/
hourTime
)
>=
1
)
{
result
=
parseInt
(
timeDifference
/
hourTime
)
+
'小时前'
}
else
if
(
parseInt
(
timeDifference
/
dayTime
)
>=
1
)
{
result
=
parseInt
(
timeDifference
/
dayTime
)
+
'天前'
}
else
if
(
parseInt
(
timeDifference
/
weektTime
)
>=
1
)
{
result
=
parseInt
(
timeDifference
/
weektTime
)
+
'周前'
}
else
if
(
parseInt
(
timeDifference
/
monthTime
)
>=
1
)
{
result
=
parseInt
(
timeDifference
/
monthTime
)
+
'月前'
}
else
if
(
parseInt
(
timeDifference
/
yearTime
)
>=
1
)
{
result
=
parseInt
(
timeDifference
/
yearTime
)
+
'年前'
if
(
timeDifference
/
yearTime
>
1
&&
Math
.
floor
(
timeDifference
/
yearTime
)
>=
1
)
{
result
=
Math
.
floor
(
timeDifference
/
yearTime
)
+
'年前'
}
else
if
(
Math
.
floor
(
timeDifference
/
monthTime
)
>=
1
)
{
result
=
Math
.
floor
(
timeDifference
/
monthTime
)
+
'月前'
}
else
if
(
Math
.
floor
(
timeDifference
/
weektTime
)
>=
1
)
{
result
=
Math
.
floor
(
timeDifference
/
weektTime
)
+
'周前'
}
else
if
(
Math
.
floor
(
timeDifference
/
dayTime
)
>=
1
)
{
result
=
Math
.
floor
(
timeDifference
/
dayTime
)
+
'天前'
}
else
if
(
Math
.
floor
(
timeDifference
/
hourTime
)
>=
1
)
{
result
=
Math
.
floor
(
timeDifference
/
hourTime
)
+
'小时前'
}
else
if
(
Math
.
floor
(
timeDifference
/
minTime
)
>=
0
)
{
result
=
Math
.
floor
(
timeDifference
/
minTime
)
+
'分钟前'
if
(
Math
.
floor
(
timeDifference
/
minTime
)
<=
5
)
{
//五分钟内就是刚刚
result
=
'刚刚'
}
}
return
result
}
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment