feat: 增加许可证解绑功能 (#4522)

This commit is contained in:
ssongliu 2024-04-15 18:37:05 +08:00 committed by GitHub
parent 735fc75e35
commit ed13136221
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 34 additions and 2 deletions

View File

@ -18,6 +18,10 @@ export const syncLicense = () => {
return http.post(`/licenses/sync`);
};
export const unbindLicense = () => {
return http.post(`/licenses/unbind`);
};
export const getSettingInfo = () => {
return http.post<Setting.SettingInfo>(`/settings/search`);
};

View File

@ -1516,6 +1516,8 @@ const message = {
quickUpdate: 'Quick Update',
import: 'Import',
power: 'Authorize',
unbind: 'Unbind License',
unbindHelper: 'All Pro related Settings will be cleared after unbinding. Do you want to continue? ',
importLicense: 'Import License',
importHelper: 'Please click or drag the license file here',
technicalAdvice: 'Technical Advice',

View File

@ -1414,6 +1414,8 @@ const message = {
quickUpdate: '快速更新',
import: '導入',
power: ' ',
unbind: '解除綁定',
unbindHelper: '解除綁定後將清除所有專業版相關設置是否繼續',
importLicense: '導入許可證',
importHelper: '請點擊或拖動許可文件到此處',
technicalAdvice: '技術諮詢',

View File

@ -1415,6 +1415,8 @@ const message = {
quickUpdate: '快速更新',
import: '导入',
power: ' ',
unbind: '解除绑定',
unbindHelper: '解除绑定后将清除所有专业版相关设置是否继续',
importLicense: '导入许可证',
importHelper: '请点击或拖动许可文件到此处',
technicalAdvice: '技术咨询',

View File

@ -18,6 +18,9 @@
>
{{ $t('commons.button.sync') }}
</el-button>
<el-button type="primary" class="ml-3" plain @click="onUnBind()" size="small">
{{ $t('license.unbind') }}
</el-button>
</el-descriptions-item>
<el-descriptions-item :label="$t('license.authorizedUser')">
{{ license.assigneeName || '-' }}
@ -104,7 +107,7 @@
<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue';
import { getLicense, syncLicense } from '@/api/modules/setting';
import { getLicense, syncLicense, unbindLicense } from '@/api/modules/setting';
import CardWithHeader from '@/components/card-with-header/index.vue';
import LicenseImport from '@/components/license-import/index.vue';
import i18n from '@/lang';
@ -135,13 +138,32 @@ const onSync = async () => {
.then(() => {
loading.value = false;
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
search();
window.location.reload();
})
.catch(() => {
loading.value = false;
});
};
const onUnBind = async () => {
ElMessageBox.confirm(i18n.global.t('license.unbindHelper'), i18n.global.t('license.unbind'), {
confirmButtonText: i18n.global.t('commons.button.confirm'),
cancelButtonText: i18n.global.t('commons.button.cancel'),
type: 'info',
}).then(async () => {
loading.value = true;
await unbindLicense()
.then(() => {
loading.value = false;
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
window.location.reload();
})
.catch(() => {
loading.value = false;
});
});
};
const timestampToDate = (timestamp: number) => {
const date = new Date(timestamp * 1000);
const y = date.getFullYear();