mirror of
https://github.com/ZiuChen/ClipboardManager.git
synced 2025-10-23 20:51:18 +08:00
feat: 组件解耦 提取样式文件
This commit is contained in:
22
src/utils/index.js
Normal file
22
src/utils/index.js
Normal file
@@ -0,0 +1,22 @@
|
||||
const dateFormat = (timeStamp) => {
|
||||
const startTime = new Date(timeStamp) // 开始时间
|
||||
const endTime = new Date() // 结束时间
|
||||
const gaps = [
|
||||
Math.floor((endTime - startTime) / 1000 / 60), // 分钟
|
||||
Math.floor((endTime - startTime) / 1000 / 60 / 60), // 小时
|
||||
Math.floor((endTime - startTime) / 1000 / 60 / 60 / 24) // 天
|
||||
]
|
||||
let info = ''
|
||||
if (gaps[2] > 0) {
|
||||
info = `${gaps[2]}天前`
|
||||
} else if (gaps[1] > 0) {
|
||||
info = `${gaps[1]}小时前`
|
||||
} else if (gaps[0] > 0) {
|
||||
info = `${gaps[0]}分钟前`
|
||||
} else {
|
||||
info = '刚刚'
|
||||
}
|
||||
return info
|
||||
}
|
||||
|
||||
export { dateFormat }
|
Reference in New Issue
Block a user