From 9c7caab990548f97342a95b51dd40a42833c3585 Mon Sep 17 00:00:00 2001 From: ssongliu Date: Wed, 24 Sep 2025 14:37:23 +0800 Subject: [PATCH] feat: Support customizing the master node name --- frontend/src/api/interface/auth.ts | 1 + .../src/layout/components/Sidebar/components/Collapse.vue | 6 +++--- frontend/src/layout/index.vue | 3 +-- frontend/src/store/interface/index.ts | 1 + frontend/src/store/modules/global.ts | 1 + frontend/src/utils/xpack.ts | 2 ++ frontend/src/views/container/container/operate/volume.vue | 1 - frontend/src/views/cronjob/library/index.vue | 2 +- frontend/src/views/log/operation/index.vue | 4 ++-- frontend/src/views/setting/license/bind/xpack.vue | 2 +- frontend/src/views/setting/license/index.vue | 6 ++++-- frontend/src/views/setting/panel/watermark/index.vue | 2 +- 12 files changed, 18 insertions(+), 13 deletions(-) diff --git a/frontend/src/api/interface/auth.ts b/frontend/src/api/interface/auth.ts index 6de5ea44dd4f..bb53b8320ded 100644 --- a/frontend/src/api/interface/auth.ts +++ b/frontend/src/api/interface/auth.ts @@ -34,5 +34,6 @@ export namespace Login { menuTabs: string; panelName: string; theme: string; + isOffLine: boolean; } } diff --git a/frontend/src/layout/components/Sidebar/components/Collapse.vue b/frontend/src/layout/components/Sidebar/components/Collapse.vue index 3a9e3ffccb53..7c64fbe15b30 100644 --- a/frontend/src/layout/components/Sidebar/components/Collapse.vue +++ b/frontend/src/layout/components/Sidebar/components/Collapse.vue @@ -57,7 +57,7 @@ { const loadCurrentName = () => { if (globalStore.currentNode) { if (globalStore.currentNode === 'local') { - return i18n.global.t('xpack.node.master'); + return globalStore.masterAlias; } return globalStore.currentNode; } - return i18n.global.t('xpack.node.master'); + return globalStore.masterAlias; }; const showPopover = () => { diff --git a/frontend/src/layout/index.vue b/frontend/src/layout/index.vue index a35e5aa20b16..3c15beee7ba8 100644 --- a/frontend/src/layout/index.vue +++ b/frontend/src/layout/index.vue @@ -57,7 +57,6 @@ import { useRoute, useRouter } from 'vue-router'; import { loadMasterProductProFromDB, loadProductProFromDB } from '@/utils/xpack'; import { useTheme } from '@/global/use-theme'; import TaskList from '@/components/task-list/index.vue'; -import i18n from '@/lang'; const { switchTheme } = useTheme(); useResize(); @@ -101,7 +100,7 @@ const handleCollapse = () => { const loadContent = () => { let itemName = globalStore.watermark.content.replaceAll( '${nodeName}', - globalStore.currentNode === 'local' ? i18n.global.t('xpack.node.master') : globalStore.currentNode, + globalStore.currentNode === 'local' ? globalStore.masterAlias : globalStore.currentNode, ); itemName = itemName.replaceAll('${nodeAddr}', globalStore.currentNodeAddr); return itemName; diff --git a/frontend/src/store/interface/index.ts b/frontend/src/store/interface/index.ts index 9013fadf2bd0..7487586debad 100644 --- a/frontend/src/store/interface/index.ts +++ b/frontend/src/store/interface/index.ts @@ -52,6 +52,7 @@ export interface GlobalState { isMasterProductPro: boolean; isOffLine: boolean; + masterAlias: string; currentNode: string; currentNodeAddr: string; } diff --git a/frontend/src/store/modules/global.ts b/frontend/src/store/modules/global.ts index fc4f2018ddb2..b7e18d4dc3aa 100644 --- a/frontend/src/store/modules/global.ts +++ b/frontend/src/store/modules/global.ts @@ -47,6 +47,7 @@ const GlobalStore = defineStore({ isMasterProductPro: false, isOffLine: false, + masterAlias: i18n.global.t('xpack.node.master'), currentNode: 'local', currentNodeAddr: '', }), diff --git a/frontend/src/utils/xpack.ts b/frontend/src/utils/xpack.ts index c7e34a3e451c..3df5b38f700c 100644 --- a/frontend/src/utils/xpack.ts +++ b/frontend/src/utils/xpack.ts @@ -10,6 +10,7 @@ export function resetXSetting() { globalStore.themeConfig.logoWithText = ''; globalStore.themeConfig.favicon = ''; globalStore.watermark = null; + globalStore.masterAlias = ''; } export function initFavicon() { @@ -117,6 +118,7 @@ export async function getXpackSettingForTheme() { globalStore.themeConfig.loginBackground = res2.data?.loginBackground; globalStore.themeConfig.loginBtnLinkColor = res2.data?.loginBtnLinkColor; globalStore.themeConfig.themeColor = res2.data?.themeColor; + globalStore.masterAlias = res2.data.masterAlias; if (res2.data?.theme) { globalStore.themeConfig.theme = res2.data.theme; } diff --git a/frontend/src/views/container/container/operate/volume.vue b/frontend/src/views/container/container/operate/volume.vue index 9c506c2b2e37..db56b48403c7 100644 --- a/frontend/src/views/container/container/operate/volume.vue +++ b/frontend/src/views/container/container/operate/volume.vue @@ -92,7 +92,6 @@ const props = defineProps({ watch( () => props.volumes, (newVal) => { - console.log(newVal); tmpVolumes.value = newVal || []; }, ); diff --git a/frontend/src/views/cronjob/library/index.vue b/frontend/src/views/cronjob/library/index.vue index 16a283cda80b..883261c36a68 100644 --- a/frontend/src/views/cronjob/library/index.vue +++ b/frontend/src/views/cronjob/library/index.vue @@ -247,7 +247,7 @@ const buttons = [ click: (row: Cronjob.ScriptInfo) => { ElMessageBox.confirm( i18n.global.t('cronjob.library.handleHelper', [ - globalStore.currentNode === 'local' ? i18n.global.t('xpack.node.master') : globalStore.currentNode, + globalStore.currentNode === 'local' ? globalStore.masterAlias : globalStore.currentNode, row.name, ]), i18n.global.t('commons.button.handle'), diff --git a/frontend/src/views/log/operation/index.vue b/frontend/src/views/log/operation/index.vue index f73f15e94de2..f1b7f03e4722 100644 --- a/frontend/src/views/log/operation/index.vue +++ b/frontend/src/views/log/operation/index.vue @@ -44,7 +44,7 @@ - + @@ -70,7 +70,7 @@ diff --git a/frontend/src/views/setting/license/bind/xpack.vue b/frontend/src/views/setting/license/bind/xpack.vue index 63f401140486..466f0725befb 100644 --- a/frontend/src/views/setting/license/bind/xpack.vue +++ b/frontend/src/views/setting/license/bind/xpack.vue @@ -113,7 +113,7 @@ const submit = async () => { const loadNodes = async () => { if (!globalStore.isMasterProductPro) { - freeNodes.value = [{ id: 0, name: i18n.global.t('xpack.node.master') }]; + freeNodes.value = [{ id: 0, name: globalStore.masterAlias }]; return; } await listNodeOptions('free') diff --git a/frontend/src/views/setting/license/index.vue b/frontend/src/views/setting/license/index.vue index 3163bcf69d85..d926c022853c 100644 --- a/frontend/src/views/setting/license/index.vue +++ b/frontend/src/views/setting/license/index.vue @@ -108,6 +108,8 @@ import BindXpack from '@/views/setting/license/bind/xpack.vue'; import { dateFormat } from '@/utils/util'; import i18n from '@/lang'; import { MsgError, MsgSuccess } from '@/utils/message'; +import { GlobalStore } from '@/store'; +const globalStore = GlobalStore(); const loading = ref(); const licenseRef = ref(); @@ -168,7 +170,7 @@ const loadBindNode = (row: any) => { if (row.freeNodes) { for (const item of row.freeNodes) { if (item.addr === row.bindNode) { - return item.name === 'local' ? i18n.global.t('xpack.node.master') : item.addr; + return item.name === 'local' ? globalStore.masterAlias : item.addr; } } } @@ -221,7 +223,7 @@ const search = async () => { item.expiresAt = item.productPro === '0' ? '' : timestampToDate(Number(item.productPro)); } data.value.sort((a, b) => { - const masterLabel = i18n.global.t('xpack.node.master'); + const masterLabel = globalStore.masterAlias; const nodeA = loadBindNode(a); const nodeB = loadBindNode(b); diff --git a/frontend/src/views/setting/panel/watermark/index.vue b/frontend/src/views/setting/panel/watermark/index.vue index a47f72d5e3ae..b90be6475388 100644 --- a/frontend/src/views/setting/panel/watermark/index.vue +++ b/frontend/src/views/setting/panel/watermark/index.vue @@ -84,7 +84,7 @@ const acceptParams = (watermark: string): void => { const loadContent = () => { let itemName = form.content.replaceAll( '${nodeName}', - globalStore.currentNode === 'local' ? i18n.global.t('xpack.node.master') : globalStore.currentNode, + globalStore.currentNode === 'local' ? globalStore.masterAlias : globalStore.currentNode, ); itemName = itemName.replaceAll('${nodeAddr}', globalStore.currentNodeAddr); return itemName;