feat: 增加license过期时间提示
This commit is contained in:
parent
76a995d7e3
commit
d8f9622931
@ -17,7 +17,13 @@
|
|||||||
<span class="label">ISV</span><span>{{ licenseInfo?.isv || '-' }}</span>
|
<span class="label">ISV</span><span>{{ licenseInfo?.isv || '-' }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex">
|
<div class="flex">
|
||||||
<span class="label">过期时间</span><span>{{ licenseInfo?.expired || '-' }}</span>
|
<span class="label">过期时间</span>
|
||||||
|
<span
|
||||||
|
>{{ licenseInfo?.expired || '-' }}
|
||||||
|
<span class="danger" v-if="fromNowDate(licenseInfo?.expired)"
|
||||||
|
>({{ fromNowDate(licenseInfo?.expired) }})</span
|
||||||
|
></span
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex">
|
<div class="flex">
|
||||||
<span class="label">版本</span
|
<span class="label">版本</span
|
||||||
@ -58,6 +64,7 @@ import { ref, computed } from 'vue'
|
|||||||
import licenseApi from '@/api/license'
|
import licenseApi from '@/api/license'
|
||||||
import { EditionType } from '@/enums/common'
|
import { EditionType } from '@/enums/common'
|
||||||
import { Role } from '@/utils/permission/type'
|
import { Role } from '@/utils/permission/type'
|
||||||
|
import { fromNowDate } from '@/utils/time'
|
||||||
import useStore from '@/stores'
|
import useStore from '@/stores'
|
||||||
const { user } = useStore()
|
const { user } = useStore()
|
||||||
const isDefaultTheme = computed(() => {
|
const isDefaultTheme = computed(() => {
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
|
import 'moment/dist/locale/zh-cn'
|
||||||
|
moment.locale('zh-cn')
|
||||||
|
|
||||||
// 当天日期 YYYY-MM-DD
|
// 当天日期 YYYY-MM-DD
|
||||||
export const nowDate = moment().format('YYYY-MM-DD')
|
export const nowDate = moment().format('YYYY-MM-DD')
|
||||||
@ -38,3 +40,41 @@ export const dateFormat = (timestamp: any) => {
|
|||||||
|
|
||||||
return `${y}-${m}-${d}`
|
return `${y}-${m}-${d}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function fromNowDate(time: any) {
|
||||||
|
// 拿到当前时间戳和发布时的时间戳,然后得出时间戳差
|
||||||
|
const curTime = new Date()
|
||||||
|
const futureTime = new Date(time)
|
||||||
|
const timeDiff = futureTime.getTime() - curTime.getTime()
|
||||||
|
|
||||||
|
// 单位换算
|
||||||
|
const min = 60 * 1000
|
||||||
|
const hour = min * 60
|
||||||
|
const day = hour * 24
|
||||||
|
const week = day * 7
|
||||||
|
|
||||||
|
// 计算发布时间距离当前时间的周、天、时、分
|
||||||
|
const exceedWeek = Math.floor(timeDiff / week)
|
||||||
|
const exceedDay = Math.floor(timeDiff / day)
|
||||||
|
const exceedHour = Math.floor(timeDiff / hour)
|
||||||
|
const exceedMin = Math.floor(timeDiff / min)
|
||||||
|
|
||||||
|
// 最后判断时间差到底是属于哪个区间,然后return
|
||||||
|
if (exceedWeek > 0) {
|
||||||
|
return ''
|
||||||
|
} else {
|
||||||
|
if (exceedDay < 7 && exceedDay > 0) {
|
||||||
|
return exceedDay + '天后'
|
||||||
|
} else {
|
||||||
|
if (exceedHour < 24 && exceedHour > 0) {
|
||||||
|
return exceedHour + '小时后'
|
||||||
|
} else {
|
||||||
|
if (exceedMin < 0) {
|
||||||
|
return '已过期'
|
||||||
|
} else {
|
||||||
|
return '即将到期'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user