feat: 组件解耦 提取样式文件

This commit is contained in:
ZiuChen
2022-08-15 13:58:11 +08:00
parent 2840f21b63
commit b4bb815ac8
9 changed files with 302 additions and 244 deletions

22
src/utils/index.js Normal file
View 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 }