perf(licenseExpired): 优化license过期提醒

This commit is contained in:
jym503558564
2020-09-22 14:33:02 +08:00
committed by Orange
parent c0f7d6e7ff
commit 537c385ecf
3 changed files with 28 additions and 2 deletions

View File

@@ -722,7 +722,10 @@
"userGuideUrl": "用户向导URL",
"username": "用户名",
"usernamePlaceholder": "请输入用户名",
"refreshLdapCache":"刷新Ldap缓存请稍后"
"refreshLdapCache":"刷新Ldap缓存请稍后",
"LicenseExpired": "许可证已经过期",
"LicenseWillBe": "许可证即将在 ",
"Expire": " 过期"
},
"settings": {
"setting": "设置"

View File

@@ -720,7 +720,10 @@
"userGuideUrl": "User Guide URL",
"username": "Username",
"usernamePlaceholder": "Please input username",
"refreshLdapCache":"Refreshing Ldap cache "
"refreshLdapCache":"Refreshing Ldap cache ",
"LicenseExpired": "License expired",
"LicenseWillBe": "License will expire at ",
"Expire": ""
},
"settings": {
"setting": "Setting"

View File

@@ -1,5 +1,8 @@
<template>
<div v-if="!loading">
<el-alert v-if="isExpire" type="error">
{{ isExpire }}
</el-alert>
<el-alert v-if="!isValidateLicense" type="success">
{{ this.$t('setting.ImportLicenseTip') }}
</el-alert>
@@ -30,6 +33,7 @@ import { QuickActions, Dialog } from '@/components'
import DetailCard from '@/components/DetailCard/index'
import { importLicense } from '@/api/settings'
import { mapGetters } from 'vuex'
import { toSafeLocalDateStr } from '@/utils/common'
export default {
name: 'License',
@@ -85,6 +89,16 @@ export default {
}
return true
},
isExpire() {
const intervalDays = this.getIntervalDays(this.licenseData.date_expired)
if (intervalDays < 0) {
return this.$t('setting.LicenseExpired')
}
if (intervalDays < 7) {
return this.$t('setting.LicenseWillBe') + this.licenseData.date_expired + this.$t('setting.Expire')
}
return false
},
cardTitle() {
return ''
},
@@ -158,6 +172,12 @@ export default {
},
fileChange(e) {
this.licenseFile['file'] = e.target.files[0]
},
getIntervalDays(date) {
const dateExpired = new Date(toSafeLocalDateStr(date))
const dateNow = new Date()
const intervalTime = dateExpired.getTime() - dateNow.getTime()
return Math.floor(intervalTime / (24 * 3600 * 1000))
}
}
}