feat: 社区版资源同步到企业版

This commit is contained in:
fit2cloud-chenyw 2024-01-17 19:03:01 +08:00
parent 207abf0f6e
commit 846aebaf6d
5 changed files with 76 additions and 4 deletions

View File

@ -3,3 +3,7 @@ import request from '@/config/axios'
export const validateApi = data => request.post({ url: '/license/validate', data }) export const validateApi = data => request.post({ url: '/license/validate', data })
export const buildVersionApi = () => request.get({ url: '/license/version' }) export const buildVersionApi = () => request.get({ url: '/license/version' })
export const updateInfoApi = data => request.post({ url: '/license/update', data }) export const updateInfoApi = data => request.post({ url: '/license/update', data })
export const checkFreeApi = () => request.get({ url: '/rmonitor/existFree' })
export const syncFreeApi = () => request.post({ url: '/rmonitor/sync' })
export const delFreeApi = () => request.post({ url: '/rmonitor/delete' })

View File

@ -1,10 +1,17 @@
<script lang="ts" setup> <script lang="ts" setup>
import aboutBg from '@/assets/img/about-bg.png' import aboutBg from '@/assets/img/about-bg.png'
import { ref, reactive, onMounted } from 'vue' import { ref, reactive, onMounted, h } from 'vue'
import { useUserStoreWithOut } from '@/store/modules/user' import { useUserStoreWithOut } from '@/store/modules/user'
import { F2CLicense } from './index' import { F2CLicense } from './index'
import { validateApi, buildVersionApi, updateInfoApi } from '@/api/about' import {
import { ElMessage } from 'element-plus-secondary' validateApi,
buildVersionApi,
updateInfoApi,
checkFreeApi,
syncFreeApi,
delFreeApi
} from '@/api/about'
import { ElMessage, ElMessageBox } from 'element-plus-secondary'
import { useI18n } from '@/hooks/web/useI18n' import { useI18n } from '@/hooks/web/useI18n'
import { useEmitt } from '@/hooks/web/useEmitt' import { useEmitt } from '@/hooks/web/useEmitt'
const dialogVisible = ref(false) const dialogVisible = ref(false)
@ -113,11 +120,54 @@ const update = (licKey: string) => {
ElMessage.success(t('about.update_success')) ElMessage.success(t('about.update_success'))
const info = getLicense(response.data) const info = getLicense(response.data)
setLicense(info) setLicense(info)
checkFree()
} else { } else {
ElMessage.warning(response.data.message) ElMessage.warning(response.data.message)
} }
}) })
} }
const checkFree = () => {
checkFreeApi().then(res => {
if (res.data) {
// do something
const title = '存在未同步的资源数据,请谨慎操作!'
const childrenDomList = [h('strong', null, title)]
ElMessageBox.confirm('', {
confirmButtonType: 'primary',
type: 'warning',
autofocus: false,
dangerouslyUseHTMLString: true,
message: h('div', { class: 'free-sync-tip-box' }, childrenDomList),
showClose: false,
cancelButtonText: '删除',
confirmButtonText: '同步'
})
.then(() => {
syncFree()
})
.catch(() => {
delFree()
})
}
})
}
const delFree = () => {
delFreeApi().then(res => {
if (!res.code && !res.msg) {
ElMessage.success(t('common.delete_success'))
}
})
}
const syncFree = () => {
syncFreeApi().then(res => {
if (!res.code && !res.msg) {
ElMessage.success('同步成功')
}
})
}
</script> </script>
<template> <template>

@ -1 +1 @@
Subproject commit c941619c1cb929453b6a8bf4517e3f0036232128 Subproject commit e71e6152874ed49933d3befeee6ea2c9310a94f4

View File

@ -0,0 +1,16 @@
package io.dataease.api.rmonitor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
public interface ResourceMonitorApi {
@GetMapping("/existFree")
boolean existFree();
@PostMapping("/delete")
void delete();
@PostMapping("/sync")
void sync();
}

View File

@ -75,4 +75,6 @@ public interface InteractiveAuthApi {
@GetMapping("/query2Root/{id}/{flag}") @GetMapping("/query2Root/{id}/{flag}")
List<ResourceNodeVO> query2Root(@PathVariable("id") Long id, @PathVariable("flag") Integer flag); List<ResourceNodeVO> query2Root(@PathVariable("id") Long id, @PathVariable("flag") Integer flag);
@GetMapping("/checkEmpty")
boolean checkEmpty();
} }