Skip to content

Commit

Permalink
feat: 增加许可证解绑功能 (#4522)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssongliu committed Apr 15, 2024
1 parent 735fc75 commit ed13136
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 2 deletions.
4 changes: 4 additions & 0 deletions frontend/src/api/modules/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
};
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/lang/modules/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/lang/modules/tw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1414,6 +1414,8 @@ const message = {
quickUpdate: '快速更新',
import: '導',
power: '授 ',
unbind: '解除綁定',
unbindHelper: '解除綁定後將清除所有專業版相關設置是否繼續?',
importLicense: '導入許可證',
importHelper: '請點擊或拖動許可文件到此處',
technicalAdvice: '技術諮詢',
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/lang/modules/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1415,6 +1415,8 @@ const message = {
quickUpdate: '快速更新',
import: '导',
power: '授 ',
unbind: '解除绑定',
unbindHelper: '解除绑定后将清除所有专业版相关设置是否继续?',
importLicense: '导入许可证',
importHelper: '请点击或拖动许可文件到此处',
technicalAdvice: '技术咨询',
Expand Down
26 changes: 24 additions & 2 deletions frontend/src/views/setting/license/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 || '-' }}
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit ed13136

Please sign in to comment.