From 4e2ff5b84e5b733e574bfb4962833310e3505ef9 Mon Sep 17 00:00:00 2001 From: hi2hi Date: Fri, 6 Dec 2024 16:34:31 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=200.4.3=20=E6=8B=86=E5=88=86?= =?UTF-8?q?=E7=82=B9=E9=98=B5=E8=83=8C=E6=99=AF=E5=9B=BE=E4=B8=BA=E7=8B=AC?= =?UTF-8?q?=E7=AB=8B=E7=BB=84=E4=BB=B6=EF=BC=8C=E6=94=AF=E6=8C=81=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=8E=A7=E5=88=B6=EF=BC=9B=20config=E6=8C=82=E4=B8=8A?= =?UTF-8?q?reactive=EF=BC=8C=E6=94=AF=E6=8C=81=E5=8A=A8=E6=80=81=E5=93=8D?= =?UTF-8?q?=E5=BA=94=EF=BC=8C=E6=9C=AA=E6=9D=A5=E6=9B=B4=E4=BC=98=E9=9B=85?= =?UTF-8?q?=E7=9A=84=E6=94=AF=E6=8C=81=E9=85=8D=E7=BD=AE=EF=BC=9B=20?= =?UTF-8?q?=E6=89=A7=E8=A1=8Csetting=E7=9A=84custom=5Fcode=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- public/config.js | 1 + src/components/dot-dot-box.vue | 83 +++++++++++++++++++ src/config/index.js | 19 ++--- src/layout/components/footer.vue | 53 ++++++++++++ src/layout/components/header.vue | 14 +--- src/use.js | 5 ++ .../server-detail/server-info-box.vue | 17 +--- .../server-detail/server-monitor.vue | 18 +--- .../components/server-detail/server-name.vue | 13 ++- .../server-detail/server-status-box.vue | 32 +++---- .../server-list/server-list-item-bill.vue | 8 ++ .../server-list/server-list-item.vue | 25 +++--- vite.config.js | 12 +++ 14 files changed, 212 insertions(+), 90 deletions(-) create mode 100644 src/components/dot-dot-box.vue diff --git a/package.json b/package.json index 84494cc..1ef387d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nazhua", - "version": "0.4.2", + "version": "0.4.3", "type": "module", "scripts": { "dev": "vite", diff --git a/public/config.js b/public/config.js index acdaeed..dd0a90b 100644 --- a/public/config.js +++ b/public/config.js @@ -16,6 +16,7 @@ window.$$nazhuaConfig = { // hideListItemBill: false, // 隐藏列表项的账单信息 // hideFilter: false, // 隐藏筛选 // hideTag: false, // 隐藏标签 + // hideDotBG: true, // 隐藏框框里面的点点背景 // customCodeMap: {}, // 自定义的地图点信息 // nezhaVersion: 'v1', // 哪吒版本 // apiMonitorPath: '/api/v1/monitor/{id}', diff --git a/src/components/dot-dot-box.vue b/src/components/dot-dot-box.vue new file mode 100644 index 0000000..5d334e4 --- /dev/null +++ b/src/components/dot-dot-box.vue @@ -0,0 +1,83 @@ + + + + + diff --git a/src/config/index.js b/src/config/index.js index cfcd36d..b136110 100644 --- a/src/config/index.js +++ b/src/config/index.js @@ -1,17 +1,10 @@ +import { + reactive, +} from 'vue'; + const defaultNezhaVersion = import.meta.env.VITE_NEZHA_VERSION; -const config = { - request: { - headers: { - // 如果设置的是json请求。api的defaultContentType为false的时候,contentType为form请求,反之亦如此 - 'Content-Type': 'application/json', - }, - codeField: 'code', // code字段 - dataField: 'result', // 数据字段 - msgField: 'message', // 消息字段 - okCode: '0', // 数据通过code - limit: 10, - }, +const config = reactive({ nazhua: { title: '哪吒监控', nezhaVersion: ['v0', 'v1'].includes(defaultNezhaVersion) ? defaultNezhaVersion : 'v0', @@ -27,7 +20,7 @@ const config = { // 解构载入自定义配置 ...(window.$$nazhuaConfig || {}), }, -}; +}); export function mergeNazhuaConfig(customConfig) { Object.keys(customConfig).forEach((key) => { diff --git a/src/layout/components/footer.vue b/src/layout/components/footer.vue index bde3134..83e9ec5 100644 --- a/src/layout/components/footer.vue +++ b/src/layout/components/footer.vue @@ -19,6 +19,10 @@ {{ version }} +
@@ -27,7 +31,56 @@ * Footer */ +import { + ref, + computed, + watch, + onMounted, + nextTick, +} from 'vue'; +import { useStore } from 'vuex'; + const version = import.meta.env.VITE_APP_VERSION; +const store = useStore(); +const dynamicContentRef = ref(); + +const dynamicContent = computed(() => { + if (store.state.setting?.custom_code) { + return store.state.setting.custom_code; + } + return ''; +}); + +// 执行动态脚本的方法 +const executeScripts = () => { + nextTick(() => { + if (!dynamicContentRef.value) return; + const scripts = dynamicContentRef.value.querySelectorAll('script'); + scripts.forEach((script) => { + const newScript = document.createElement('script'); + newScript.type = 'text/javascript'; + if (script.src) { + newScript.src = script.src; // 拷贝外部脚本的 src + } else { + newScript.textContent = script.textContent; // 拷贝内联脚本 + } + document.body.appendChild(newScript); + document.body.removeChild(newScript); // 可选:移除以保持整洁 + }); + }); +}; + +watch(dynamicContent, () => { + if (dynamicContent.value) { + executeScripts(); + } +}); + +onMounted(() => { + if (dynamicContent.value) { + executeScripts(); + } +});