From 2344200815d43ed372543d2848cb88ae7fc9804a Mon Sep 17 00:00:00 2001 From: hi2hi Date: Thu, 6 Feb 2025 06:04:39 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=AA=84=20=E6=B7=BB=E5=8A=A0=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=20favicon=20=E5=8A=9F=E8=83=BD=EF=BC=8C?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=9C=A8=E9=85=8D=E7=BD=AE=E4=B8=AD=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E7=BD=91=E7=AB=99=E5=9B=BE=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/config.js | 1 + src/config/index.js | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/public/config.js b/public/config.js index d53254b..70fe8af 100644 --- a/public/config.js +++ b/public/config.js @@ -44,4 +44,5 @@ window.$$nazhuaConfig = { // v1DashboardUrl: '/dashboard', // v1版本控制台地址 // v1HideNezhaDashboardBtn: true, // v1版本导航栏控制台入口/登录按钮 在nezhaVersion为v1时有效 // routeMode: 'h5', // 路由模式 + // customFavicon: '', // 自定义favicon, 填写完整的url地址 }; diff --git a/src/config/index.js b/src/config/index.js index 8a606d9..7da1696 100644 --- a/src/config/index.js +++ b/src/config/index.js @@ -33,10 +33,27 @@ if (config.nazhua.nezhaVersion) { config.init = true; } +/** + * 替换网站图标 + */ +function replaceFavicon() { + if (config.nazhua.customFavicon) { + const link = document.querySelector("link[rel*='icon']"); + link.type = 'image/x-icon'; + link.rel = 'shortcut icon'; + link.href = config.nazhua.customFavicon; + } +} +replaceFavicon(); + +/** + * 合并自定义配置 + */ export function mergeNazhuaConfig(customConfig) { Object.keys(customConfig).forEach((key) => { config.nazhua[key] = customConfig[key]; }); + replaceFavicon(); } // 暴露合并配置方法 window.$mergeNazhuaConfig = mergeNazhuaConfig;