mirror of
https://github.com/hi2shark/nazhua.git
synced 2026-01-17 17:50:43 +08:00
🪄 添加自定义 favicon 功能,支持在配置中设置网站图标
This commit is contained in:
parent
13d66010df
commit
2344200815
@ -44,4 +44,5 @@ window.$$nazhuaConfig = {
|
|||||||
// v1DashboardUrl: '/dashboard', // v1版本控制台地址
|
// v1DashboardUrl: '/dashboard', // v1版本控制台地址
|
||||||
// v1HideNezhaDashboardBtn: true, // v1版本导航栏控制台入口/登录按钮 在nezhaVersion为v1时有效
|
// v1HideNezhaDashboardBtn: true, // v1版本导航栏控制台入口/登录按钮 在nezhaVersion为v1时有效
|
||||||
// routeMode: 'h5', // 路由模式
|
// routeMode: 'h5', // 路由模式
|
||||||
|
// customFavicon: '', // 自定义favicon, 填写完整的url地址
|
||||||
};
|
};
|
||||||
|
|||||||
@ -33,10 +33,27 @@ if (config.nazhua.nezhaVersion) {
|
|||||||
config.init = true;
|
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) {
|
export function mergeNazhuaConfig(customConfig) {
|
||||||
Object.keys(customConfig).forEach((key) => {
|
Object.keys(customConfig).forEach((key) => {
|
||||||
config.nazhua[key] = customConfig[key];
|
config.nazhua[key] = customConfig[key];
|
||||||
});
|
});
|
||||||
|
replaceFavicon();
|
||||||
}
|
}
|
||||||
// 暴露合并配置方法
|
// 暴露合并配置方法
|
||||||
window.$mergeNazhuaConfig = mergeNazhuaConfig;
|
window.$mergeNazhuaConfig = mergeNazhuaConfig;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user