feat: Support importing licenses when adding nodes (#10776)

Refs #9793
This commit is contained in:
ssongliu 2025-10-27 17:56:16 +08:00 committed by GitHub
parent 2836207850
commit f12e70ef5d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 26 additions and 7 deletions

View file

@ -63,15 +63,18 @@ import { uploadLicense } from '@/api/modules/setting';
import DockerProxy from '@/components/docker-proxy/index.vue'; import DockerProxy from '@/components/docker-proxy/index.vue';
import { GlobalStore } from '@/store'; import { GlobalStore } from '@/store';
import { UploadFile, UploadFiles, UploadInstance, UploadProps, UploadRawFile, genFileId } from 'element-plus'; import { UploadFile, UploadFiles, UploadInstance, UploadProps, UploadRawFile, genFileId } from 'element-plus';
import { getXpackSettingForTheme } from '@/utils/xpack'; import { getXpackSettingForTheme, loadMasterProductProFromDB, loadProductProFromDB } from '@/utils/xpack';
const globalStore = GlobalStore(); const globalStore = GlobalStore();
const em = defineEmits(['search']);
const loading = ref(false); const loading = ref(false);
const open = ref(false); const open = ref(false);
const uploadRef = ref<UploadInstance>(); const uploadRef = ref<UploadInstance>();
const uploaderFiles = ref<UploadFiles>([]); const uploaderFiles = ref<UploadFiles>([]);
const isImport = ref(); const isImport = ref();
const isForce = ref(); const isForce = ref();
const withoutReload = ref();
const withDockerRestart = ref(); const withDockerRestart = ref();
@ -79,6 +82,7 @@ const oldLicense = ref();
interface DialogProps { interface DialogProps {
oldLicense: string; oldLicense: string;
isImport: boolean; isImport: boolean;
withoutReload: boolean;
} }
const acceptParams = (params: DialogProps) => { const acceptParams = (params: DialogProps) => {
@ -86,6 +90,8 @@ const acceptParams = (params: DialogProps) => {
uploaderFiles.value = []; uploaderFiles.value = [];
uploadRef.value?.clearFiles(); uploadRef.value?.clearFiles();
isImport.value = params?.isImport; isImport.value = params?.isImport;
withoutReload.value = params.withoutReload;
open.value = true; open.value = true;
}; };
@ -131,17 +137,19 @@ const submit = async () => {
loading.value = true; loading.value = true;
await uploadLicense(oldLicense.value, formData) await uploadLicense(oldLicense.value, formData)
.then(async () => { .then(async () => {
globalStore.isProductPro = true;
if (globalStore.isMaster) {
globalStore.isMasterProductPro = true;
}
getXpackSettingForTheme();
loading.value = false; loading.value = false;
uploadRef.value!.clearFiles(); uploadRef.value!.clearFiles();
uploaderFiles.value = []; uploaderFiles.value = [];
open.value = false; open.value = false;
MsgSuccess(i18n.global.t('commons.msg.operationSuccess')); MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
window.location.reload(); if (!withoutReload.value) {
loadMasterProductProFromDB();
loadProductProFromDB();
getXpackSettingForTheme();
window.location.reload();
} else {
em('search');
}
}) })
.catch(() => { .catch(() => {
loading.value = false; loading.value = false;

View file

@ -2065,6 +2065,7 @@ const message = {
pro: 'Pro', pro: 'Pro',
trial: 'Trial', trial: 'Trial',
add: 'Add Community Edition', add: 'Add Community Edition',
licenseBindHelper: 'Free node quotas can only be used when the license is bound to a node',
licenseAlert: licenseAlert:
'Community Edition nodes can only be added when the license is properly bound to a node. Only nodes properly bound to the license support switching.', 'Community Edition nodes can only be added when the license is properly bound to a node. Only nodes properly bound to the license support switching.',
licenseUnbindHelper: 'Community Edition nodes detected for this license. Please unbind and try again!', licenseUnbindHelper: 'Community Edition nodes detected for this license. Please unbind and try again!',

View file

@ -2074,6 +2074,8 @@ const message = {
pro: 'Pro', pro: 'Pro',
trial: 'Prueba', trial: 'Prueba',
add: 'Agregar versión Community', add: 'Agregar versión Community',
licenseBindHelper:
'Las cuotas de nodo gratuitas solo se pueden utilizar cuando la licencia está vinculada a un nodo',
licenseAlert: licenseAlert:
'Solo se pueden agregar nodos Community cuando la licencia está correctamente vinculada. Solo los nodos vinculados admiten cambios.', 'Solo se pueden agregar nodos Community cuando la licencia está correctamente vinculada. Solo los nodos vinculados admiten cambios.',
licenseUnbindHelper: 'Nodos Community detectados en esta licencia. Desvincule e intente nuevamente.', licenseUnbindHelper: 'Nodos Community detectados en esta licencia. Desvincule e intente nuevamente.',

View file

@ -1979,6 +1979,7 @@ const message = {
pro: '専門', pro: '専門',
trial: '体験', trial: '体験',
add: 'コミュニティ版を追加', add: 'コミュニティ版を追加',
licenseBindHelper: 'ライセンスがノードにバインドされている場合にのみ無料ノードクォータを使用できます',
licenseAlert: licenseAlert:
'ライセンスがノードに正常にバインドされている場合のみコミュニティ版ノードを追加できますライセンスに正常にバインドされているノードのみ切り替えがサポートされます', 'ライセンスがノードに正常にバインドされている場合のみコミュニティ版ノードを追加できますライセンスに正常にバインドされているノードのみ切り替えがサポートされます',
licenseUnbindHelper: licenseUnbindHelper:

View file

@ -1948,6 +1948,7 @@ const message = {
pro: 'Pro', pro: 'Pro',
trial: '체험판', trial: '체험판',
add: '커뮤니티 에디션 추가', add: '커뮤니티 에디션 추가',
licenseBindHelper: '라이선스가 노드에 바인딩된 경우에만 무료 노드 할당량을 사용할 있습니다',
licenseAlert: licenseAlert:
'라이선스가 노드에 정상적으로 바인딩된 경우에만 커뮤니티 에디션 노드를 추가할 있습니다. 라이선스에 정상적으로 바인딩된 노드만 전환이 지원됩니다.', '라이선스가 노드에 정상적으로 바인딩된 경우에만 커뮤니티 에디션 노드를 추가할 있습니다. 라이선스에 정상적으로 바인딩된 노드만 전환이 지원됩니다.',
licenseUnbindHelper: ' 라이선스에 커뮤니티 에디션 노드가 존재합니다. 바인딩 해제 다시 시도하세요!', licenseUnbindHelper: ' 라이선스에 커뮤니티 에디션 노드가 존재합니다. 바인딩 해제 다시 시도하세요!',

View file

@ -2042,6 +2042,7 @@ const message = {
pro: 'Pro', pro: 'Pro',
trial: 'Percubaan', trial: 'Percubaan',
add: 'Tambah Edisi Komuniti', add: 'Tambah Edisi Komuniti',
licenseBindHelper: 'Kuota nod percuma hanya boleh digunakan apabila lesen terikat pada nod',
licenseAlert: licenseAlert:
'Nod Edisi Komuniti hanya boleh ditambah apabila lesen terikat dengan betul pada nod. Hanya nod yang terikat dengan betul pada lesen menyokong penukaran.', 'Nod Edisi Komuniti hanya boleh ditambah apabila lesen terikat dengan betul pada nod. Hanya nod yang terikat dengan betul pada lesen menyokong penukaran.',
licenseUnbindHelper: 'Nod Edisi Komuniti dikesan untuk lesen ini. Sila lepaskan ikatan dan cuba lagi!', licenseUnbindHelper: 'Nod Edisi Komuniti dikesan untuk lesen ini. Sila lepaskan ikatan dan cuba lagi!',

View file

@ -2034,6 +2034,7 @@ const message = {
pro: 'Pro', pro: 'Pro',
trial: 'Teste', trial: 'Teste',
add: 'Adicionar Edição Comunitária', add: 'Adicionar Edição Comunitária',
licenseBindHelper: 'As cotas de gratuitas podem ser usadas quando a licença está vinculada a um ',
licenseAlert: licenseAlert:
'Nós da Edição Comunitária podem ser adicionados quando a licença está devidamente vinculada a um . Apenas nós devidamente vinculados à licença suportam troca.', 'Nós da Edição Comunitária podem ser adicionados quando a licença está devidamente vinculada a um . Apenas nós devidamente vinculados à licença suportam troca.',
licenseUnbindHelper: licenseUnbindHelper:

View file

@ -2033,6 +2033,7 @@ const message = {
pro: 'Pro', pro: 'Pro',
trial: 'Пробная версия', trial: 'Пробная версия',
add: 'Добавить Community Edition', add: 'Добавить Community Edition',
licenseBindHelper: 'Бесплатные квоты узлов можно использовать только тогда, когда лицензия привязана к узлу',
licenseAlert: licenseAlert:
'Узлы Community Edition можно добавлять только при правильной привязке лицензии к узлу. Переключение поддерживается только для узлов, правильно привязанных к лицензии.', 'Узлы Community Edition можно добавлять только при правильной привязке лицензии к узлу. Переключение поддерживается только для узлов, правильно привязанных к лицензии.',
licenseUnbindHelper: licenseUnbindHelper:

View file

@ -2087,6 +2087,7 @@ const message = {
pro: 'Pro', pro: 'Pro',
trial: 'Deneme', trial: 'Deneme',
add: 'Topluluk Sürümünü Ekle', add: 'Topluluk Sürümünü Ekle',
licenseBindHelper: 'Ücretsiz düğüm kotası yalnızca lisans bir düğüme bağlı olduğunda kullanılabilir',
licenseAlert: licenseAlert:
'Topluluk Sürümü düğümleri yalnızca lisans bir düğüme düzgün şekilde bağlandığında eklenebilir. Yalnızca düzgün şekilde bağlanmış düğümler geçiş yapmayı destekler.', 'Topluluk Sürümü düğümleri yalnızca lisans bir düğüme düzgün şekilde bağlandığında eklenebilir. Yalnızca düzgün şekilde bağlanmış düğümler geçiş yapmayı destekler.',
licenseUnbindHelper: licenseUnbindHelper:

View file

@ -1927,6 +1927,7 @@ const message = {
pro: '專業版', pro: '專業版',
trial: '試用', trial: '試用',
add: '新增社區版', add: '新增社區版',
licenseBindHelper: '僅當授權已綁定節點時才能使用其免費節點額度',
licenseAlert: '僅當許可證正常綁定到節點時該許可證才能新增社區版節點只有正常綁定到許可證的節點支援切換', licenseAlert: '僅當許可證正常綁定到節點時該許可證才能新增社區版節點只有正常綁定到許可證的節點支援切換',
licenseUnbindHelper: '檢測到該許可證存在社區版節點請解除綁定後重試', licenseUnbindHelper: '檢測到該許可證存在社區版節點請解除綁定後重試',
subscription: '訂閱', subscription: '訂閱',

View file

@ -1920,6 +1920,7 @@ const message = {
pro: '专业版', pro: '专业版',
trial: '试用', trial: '试用',
add: '添加社区版', add: '添加社区版',
licenseBindHelper: '仅当许可证已绑定节点时才能使用其免费节点额度',
licenseAlert: '仅当许可证正常绑定到节点时该许可证才能添加社区版节点只有正常绑定到许可证的节点支持切换', licenseAlert: '仅当许可证正常绑定到节点时该许可证才能添加社区版节点只有正常绑定到许可证的节点支持切换',
licenseUnbindHelper: '检测到该许可证存在社区版节点请解绑后重试', licenseUnbindHelper: '检测到该许可证存在社区版节点请解绑后重试',
subscription: '订阅', subscription: '订阅',