From b4e8c8503c1e58800bd0bfbbf526b833022f44d4 Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Mon, 25 Mar 2024 22:49:39 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=B0=83=E6=95=B4=20License=20?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E6=A0=B7=E5=BC=8F=20(#4305)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/system-upgrade/index.vue | 10 ++ frontend/src/lang/modules/en.ts | 5 +- frontend/src/lang/modules/tw.ts | 5 +- frontend/src/lang/modules/zh.ts | 11 +- frontend/src/views/home/index.vue | 74 ++---------- frontend/src/views/home/license/index.vue | 113 ++++++++++++++++++ frontend/src/views/setting/license/index.vue | 41 ++++--- .../views/setting/license/upload/index.vue | 4 +- 8 files changed, 170 insertions(+), 93 deletions(-) create mode 100644 frontend/src/views/home/license/index.vue diff --git a/frontend/src/components/system-upgrade/index.vue b/frontend/src/components/system-upgrade/index.vue index 70e84b725..21df65844 100644 --- a/frontend/src/components/system-upgrade/index.vue +++ b/frontend/src/components/system-upgrade/index.vue @@ -14,6 +14,10 @@ + + {{ isProductPro ? $t('license.pro') : $t('license.community') }} + {{ ': ' + version }} + ({{ $t('setting.hasNewVersion') }}) @@ -77,6 +81,7 @@ import { ElMessageBox } from 'element-plus'; const globalStore = GlobalStore(); const version = ref(''); +const isProductPro = ref(); const loading = ref(false); const drawerVisible = ref(false); const upgradeInfo = ref(); @@ -98,6 +103,10 @@ const handleClose = () => { drawerVisible.value = false; }; +const toHalo = () => { + window.open('https://halo.test.lxware.cn/', '_blank', 'noopener,noreferrer'); +}; + const toDoc = () => { window.open('https://1panel.cn/docs/', '_blank', 'noopener,noreferrer'); }; @@ -149,6 +158,7 @@ const onUpgrade = async () => { }; onMounted(() => { + isProductPro.value = globalStore.isProductPro; search(); }); diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index c5fa77f23..6a34803e8 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -1462,8 +1462,9 @@ const message = { expiresAt: 'Expiration Time', productName: 'Product Name', productStatus: 'Product Status', - lost01: 'Lost * 1', - lost02: 'Lost * 2', + Lost01: 'Lost * 1', + Lost02: 'Lost * 2', + Lost03: 'Lost', Enable: 'Enabled', Disable: 'Disabled', lostHelper: diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts index 952d38250..55c5bca5f 100644 --- a/frontend/src/lang/modules/tw.ts +++ b/frontend/src/lang/modules/tw.ts @@ -1362,8 +1362,9 @@ const message = { authorizedUser: '被授權方', productName: '產品名稱', productStatus: '產品狀態', - lost01: '失聯 * 1', - lost02: '失聯 * 2', + Lost01: '失聯 * 1', + Lost02: '失聯 * 2', + Lost03: '失聯', Enable: '已啟用', Disable: '未啟用', lostHelper: 'License 需要定時同步是否可用,請確保正常外網訪問,失聯三次後將解除 License 綁定', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index ec8acd6c5..b56bf3047 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -1357,20 +1357,23 @@ const message = { license: { community: '社区版', pro: '专业版', - trial: '实验版', + trial: '试用版', office: '正式版', + trialInfo: '版本', authorizationId: '订阅授权 ID', authorizedUser: '被授权方', expiresAt: '到期时间', productName: '产品名称', productStatus: '产品状态', - lost01: '失联 * 1', - lost02: '失联 * 2', + Lost01: '失联 * 1', + Lost02: '失联 * 2', + Lost03: '已失联', Enable: '已激活', Disable: '未激活', lostHelper: 'License 需要定时同步是否可用,请保证正常外网访问,失联三次后将解除 License 绑定', quickUpdate: '快速更新', import: '导入', + power: '授权', importLicense: '导入 License', importHelper: '点击或将 License 文件拖拽到此处', technicalAdvice: '技术咨询', @@ -1378,8 +1381,6 @@ const message = { indefinitePeriod: '无限期', levelUpPro: '升级专业版', knowMorePro: '了解更多专业版信息', - noLicense: '该部分为 Xpack 功能,请先在 面板设置-许可证 界面导入 License', - goImport: '去导入', closeAlert: '当前页面可在面板设置中关闭显示', }, clean: { diff --git a/frontend/src/views/home/index.vue b/frontend/src/views/home/index.vue index d2a54985e..68209ba6d 100644 --- a/frontend/src/views/home/index.vue +++ b/frontend/src/views/home/index.vue @@ -10,14 +10,8 @@ > - - {{ $t('license.community') }} - - {{ $t('license.pro') }} - - - - + + {{ $t('license.levelUpPro') }} @@ -25,23 +19,6 @@ - - - - - - {{ $t('setting.description') }} - - {{ $t('license.importLicense') }} - - - - {{ $t('license.knowMorePro') }} - - - - - {{ - baseInfo.platformVersion === '' + baseInfo.platformVersion ? baseInfo.platform : baseInfo.platform + '-' + baseInfo.platformVersion }} @@ -257,7 +234,7 @@ - + @@ -273,9 +250,9 @@ import { dateFormatForSecond, computeSize } from '@/utils/util'; import { useRouter } from 'vue-router'; import { loadBaseInfo, loadCurrentInfo } from '@/api/modules/dashboard'; import { getIOOptions, getNetworkOptions } from '@/api/modules/monitor'; -import { getLicense, getSettingInfo, loadUpgradeInfo } from '@/api/modules/setting'; +import { getSettingInfo, loadUpgradeInfo } from '@/api/modules/setting'; import { GlobalStore } from '@/store'; -import Upload from '@/views/setting/license/upload/index.vue'; +import License from '@/views/home/license/index.vue'; const router = useRouter(); const globalStore = GlobalStore(); @@ -300,21 +277,8 @@ const timeNetDatas = ref>([]); const ioOptions = ref(); const netOptions = ref(); -const dialogFormVisible = ref(false); - -const uploadRef = ref(); -const loading = ref(); -const show = ref(null); - -const license = reactive({ - licenseName: '', - trial: true, - expiresAt: '', - assigneeName: '', - productName: '', - - status: '', -}); +const licenseRef = ref(); +const isProductPro = ref(); const searchInfo = reactive({ ioOption: 'all', @@ -596,30 +560,12 @@ const onBlur = () => { isActive.value = false; }; -const search = async () => { - loading.value = true; - await getLicense() - .then((res) => { - loading.value = false; - license.status = res.data.status; - show.value = license.status !== 'Enable'; - }) - .catch(() => { - show.value = true; - loading.value = false; - }); -}; - -const toHalo = () => { - window.open('https://halo.test.lxware.cn/', '_blank', 'noopener,noreferrer'); -}; - const toUpload = () => { - uploadRef.value.acceptParams(); + licenseRef.value.acceptParams(); }; onMounted(() => { - search(); + isProductPro.value = globalStore.isProductPro; window.addEventListener('focus', onFocus); window.addEventListener('blur', onBlur); loadSafeStatus(); diff --git a/frontend/src/views/home/license/index.vue b/frontend/src/views/home/license/index.vue new file mode 100644 index 000000000..6afdab74c --- /dev/null +++ b/frontend/src/views/home/license/index.vue @@ -0,0 +1,113 @@ + + + + + {{ $t('license.levelUpPro') }} + + + + + + {{ $t('license.importHelper') }} + + + + + + {{ $t('license.power') }} + + + + {{ $t('license.knowMorePro') }} + + + + + + + + diff --git a/frontend/src/views/setting/license/index.vue b/frontend/src/views/setting/license/index.vue index 135d4360b..366d0cca7 100644 --- a/frontend/src/views/setting/license/index.vue +++ b/frontend/src/views/setting/license/index.vue @@ -8,23 +8,33 @@ {{ license.licenseName || '-' }} - + {{ $t('commons.button.sync') }} {{ license.assigneeName || '-' }} - - {{ license.expiresAt || '-' }} - {{ license.productName || '-' }} + + {{ license.trial ? $t('license.trial') : $t('license.office') }} + + + {{ license.expiresAt || '-' }} + @@ -40,7 +50,7 @@ - + {{ $t('setting.license') }} @@ -58,7 +68,7 @@ - + {{ $t('license.importLicense') }}: @@ -70,7 +80,7 @@ - + {{ $t('license.technicalAdvice') }}: @@ -177,6 +187,10 @@ const hasLicense = () => { return license.status === 'Enable'; }; +const showSync = () => { + return license.status.indexOf('Lost') !== -1 || license.status === 'Disable'; +}; + const toUpload = () => { uploadRef.value.acceptParams(); }; @@ -191,17 +205,6 @@ onMounted(() => { padding: 10px 15px; margin-right: 10px; line-height: 18px; - - .h-app-content { - padding-left: 15px; - .h-app-desc { - span { - font-weight: 400; - font-size: 12px; - color: var(--el-text-color-regular); - } - } - } &:hover { background-color: rgba(0, 94, 235, 0.03); } diff --git a/frontend/src/views/setting/license/upload/index.vue b/frontend/src/views/setting/license/upload/index.vue index a11a185e8..6328f89a0 100644 --- a/frontend/src/views/setting/license/upload/index.vue +++ b/frontend/src/views/setting/license/upload/index.vue @@ -46,6 +46,8 @@ import { UploadFileData } from '@/api/modules/setting'; import i18n from '@/lang'; import DrawerHeader from '@/components/drawer-header/index.vue'; import { MsgSuccess } from '@/utils/message'; +import { GlobalStore } from '@/store'; +const globalStore = GlobalStore(); const loading = ref(false); const open = ref(false); @@ -85,7 +87,7 @@ const submit = async () => { loading.value = false; uploadRef.value!.clearFiles(); uploaderFiles.value = []; - em('search'); + globalStore.isProductPro = true; open.value = false; MsgSuccess(i18n.global.t('commons.msg.operationSuccess')); window.location.reload();