mirror of
https://github.com/dataease/dataease.git
synced 2026-05-14 21:12:33 +08:00
feat(X-Pack): 新增还原至社区版功能
This commit is contained in:
@@ -2,10 +2,14 @@ package io.dataease.license.server;
|
||||
|
||||
import io.dataease.api.license.LicenseApi;
|
||||
import io.dataease.api.license.dto.LicenseRequest;
|
||||
import io.dataease.exception.DEException;
|
||||
import io.dataease.license.bo.F2CLicResult;
|
||||
import io.dataease.license.manage.CoreLicManage;
|
||||
import io.dataease.license.manage.F2CLicManage;
|
||||
import io.dataease.license.utils.LicenseUtil;
|
||||
import io.dataease.utils.AuthUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@@ -39,4 +43,13 @@ public class LicenseServer implements LicenseApi {
|
||||
public String version() {
|
||||
return coreLicManage.getVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void revert() {
|
||||
F2CLicResult f2CLicResult = null;
|
||||
if (!AuthUtils.isSysAdmin() || ObjectUtils.isEmpty(f2CLicResult = LicenseUtil.get()) || f2CLicResult.getStatus() != F2CLicResult.Status.expired) {
|
||||
DEException.throwException("不能进行还原操作!");
|
||||
}
|
||||
f2CLicManage.revert();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,3 +3,4 @@ import request from '@/config/axios'
|
||||
export const validateApi = data => request.post({ url: '/license/validate', data })
|
||||
export const buildVersionApi = () => request.get({ url: '/license/version' })
|
||||
export const updateInfoApi = data => request.post({ url: '/license/update', data })
|
||||
export const revertApi = () => request.post({ url: '/license/revert' })
|
||||
|
||||
@@ -2461,7 +2461,9 @@ export default {
|
||||
support: 'Get technical support',
|
||||
update_success: 'Update successful',
|
||||
serial_no: 'Serial number',
|
||||
remark: 'Remark'
|
||||
remark: 'Remark',
|
||||
back_community: 'Revert to Community Edition',
|
||||
confirm_tips: 'Are you sure you want to restore to the community edition? '
|
||||
},
|
||||
cron: {
|
||||
second: 'Seconds',
|
||||
|
||||
@@ -2392,7 +2392,9 @@ export default {
|
||||
support: '取得技術支援',
|
||||
update_success: '更新成功',
|
||||
serial_no: '序號',
|
||||
remark: '備註'
|
||||
remark: '備註',
|
||||
back_community: '還原至社區版',
|
||||
confirm_tips: '确定還原至社區版?'
|
||||
},
|
||||
cron: {
|
||||
second: '秒',
|
||||
|
||||
@@ -2398,7 +2398,9 @@ export default {
|
||||
support: '获取技术支持',
|
||||
update_success: '更新成功',
|
||||
serial_no: '序列号',
|
||||
remark: '备注'
|
||||
remark: '备注',
|
||||
back_community: '还原至社区版',
|
||||
confirm_tips: '确定还原至社区版?'
|
||||
},
|
||||
cron: {
|
||||
second: '秒',
|
||||
|
||||
@@ -4,8 +4,8 @@ import aboutBg from '@/assets/img/about-bg.png'
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { useUserStoreWithOut } from '@/store/modules/user'
|
||||
import { F2CLicense } from './index'
|
||||
import { validateApi, buildVersionApi, updateInfoApi } from '@/api/about'
|
||||
import { ElMessage } from 'element-plus-secondary'
|
||||
import { validateApi, buildVersionApi, updateInfoApi, revertApi } from '@/api/about'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus-secondary'
|
||||
import { useI18n } from '@/hooks/web/useI18n'
|
||||
import { useEmitt } from '@/hooks/web/useEmitt'
|
||||
import { useCache } from '@/hooks/web/useCache'
|
||||
@@ -58,7 +58,25 @@ const support = () => {
|
||||
const openType = wsCache.get('open-backend') === '1' ? '_self' : '_blank'
|
||||
window.open(url, openType)
|
||||
}
|
||||
|
||||
const back2Community = () => {
|
||||
ElMessageBox.confirm(t('about.confirm_tips'), {
|
||||
confirmButtonType: 'danger',
|
||||
type: 'warning',
|
||||
confirmButtonText: t('common.sure'),
|
||||
cancelButtonText: t('dataset.cancel'),
|
||||
autofocus: false,
|
||||
showClose: false
|
||||
})
|
||||
.then(() => {
|
||||
revertApi().then(() => {
|
||||
ElMessage.success(t('about.update_success'))
|
||||
window.location.reload()
|
||||
})
|
||||
})
|
||||
.catch(e => {
|
||||
console.error(e)
|
||||
})
|
||||
}
|
||||
const getLicenseInfo = () => {
|
||||
validateHandler({}, res => {
|
||||
const info = getLicense(res.data)
|
||||
@@ -203,6 +221,9 @@ const update = (licKey: string) => {
|
||||
<el-button plain> {{ $t('about.update_license') }} </el-button>
|
||||
</el-upload>
|
||||
<el-button plain @click="support"> {{ $t('about.support') }} </el-button>
|
||||
<el-button v-if="license.status === 'expired'" plain @click="back2Community">
|
||||
{{ $t('about.back_community') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
@@ -17,4 +17,7 @@ public interface LicenseApi {
|
||||
|
||||
@GetMapping("/version")
|
||||
String version();
|
||||
|
||||
@PostMapping("/revert")
|
||||
void revert();
|
||||
}
|
||||
|
||||
@@ -89,4 +89,8 @@ public interface InteractiveAuthApi {
|
||||
|
||||
@PostMapping("/batchAuthorize")
|
||||
void batchAuthorize(@RequestBody BusiBatchAuthorizeRequest request);
|
||||
|
||||
@Hidden
|
||||
@PostMapping("/revert")
|
||||
void revert();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user