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(); + } +});