From 551a99f6947caf88c448e0c2a5deb7f5e9a04933 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Wed, 10 Aug 2022 02:08:03 -0400 Subject: [PATCH] =?UTF-8?q?feat(=E7=B3=BB=E7=BB=9F):=20=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=B3=BB=E7=BB=9F=E5=9B=BE=E6=A0=87favicon?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/lang/en.js | 1 + frontend/src/lang/tw.js | 1 + frontend/src/lang/zh.js | 1 + frontend/src/layout/components/Topbar.vue | 13 ++++++------- frontend/src/utils/index.js | 12 ++++++++++++ frontend/src/views/login/index.vue | 13 ++++++------- 6 files changed, 27 insertions(+), 14 deletions(-) diff --git a/frontend/src/lang/en.js b/frontend/src/lang/en.js index 4a2c80ece0..29704317bc 100644 --- a/frontend/src/lang/en.js +++ b/frontend/src/lang/en.js @@ -1890,6 +1890,7 @@ export default { un_install_error: 'Uninstall failed, please contact the administrator' }, display: { + favicon: 'Favicon', logo: 'Head system logo', loginLogo: 'Login page header logo', loginImage: 'Picture on the right side of the login page', diff --git a/frontend/src/lang/tw.js b/frontend/src/lang/tw.js index 937408af50..653415b5ee 100644 --- a/frontend/src/lang/tw.js +++ b/frontend/src/lang/tw.js @@ -1890,6 +1890,7 @@ export default { un_install_error: '卸載失敗,請聯系管理員' }, display: { + favicon: '系統圖標', logo: '頭部繫統logo', loginLogo: '登錄頁面頭部logo', loginImage: '登錄頁面右側圖片', diff --git a/frontend/src/lang/zh.js b/frontend/src/lang/zh.js index 0669a1c323..70cc7a1bff 100644 --- a/frontend/src/lang/zh.js +++ b/frontend/src/lang/zh.js @@ -1900,6 +1900,7 @@ export default { un_install_error: '卸载失败,请联系管理员' }, display: { + favicon: '系统图标', logo: '头部系统logo', loginLogo: '登录页面头部logo', loginImage: '登录页面右侧图片', diff --git a/frontend/src/layout/components/Topbar.vue b/frontend/src/layout/components/Topbar.vue index 56b77881c6..caa4875664 100644 --- a/frontend/src/layout/components/Topbar.vue +++ b/frontend/src/layout/components/Topbar.vue @@ -104,6 +104,7 @@ import { initTheme } from '@/utils/ThemeUtil' import TemplateMarket from '@/views/panel/templateMarket' +import { changeFavicon } from '@/utils/index' export default { name: 'Topbar', components: { @@ -346,13 +347,11 @@ export default { }) } - /* if (this.uiInfo['ui.themeStr'] && this.uiInfo['ui.themeStr'].paramValue) { - if (this.uiInfo['ui.themeStr'].paramValue === 'dark') { - document.body.className = 'blackTheme' - } else if (this.uiInfo['ui.themeStr'].paramValue === 'light') { - document.body.className = '' - } - } */ + if (this.uiInfo['ui.favicon'] && this.uiInfo['ui.favicon'].paramValue) { + const faviconUrl = '/system/ui/image/' + this.uiInfo['ui.favicon'].paramValue + changeFavicon(faviconUrl) + } + this.axiosFinished = true }) }, diff --git a/frontend/src/utils/index.js b/frontend/src/utils/index.js index 2a2cff8a49..e81de74ae2 100644 --- a/frontend/src/utils/index.js +++ b/frontend/src/utils/index.js @@ -313,3 +313,15 @@ export const isSameVueObj = (source, target) => { } return false } + +export const changeFavicon = link => { + let $favicon = document.querySelector('link[rel="icon"]') + if ($favicon !== null) { + $favicon.href = link + } else { + $favicon = document.createElement('link') + $favicon.rel = 'icon' + $favicon.href = link + document.head.appendChild($favicon) + } +} diff --git a/frontend/src/views/login/index.vue b/frontend/src/views/login/index.vue index 41a773e541..e53381778b 100644 --- a/frontend/src/views/login/index.vue +++ b/frontend/src/views/login/index.vue @@ -67,6 +67,7 @@ import { encrypt } from '@/utils/rsaEncrypt' import { ldapStatus, oidcStatus, getPublicKey, pluginLoaded, defaultLoginType } from '@/api/user' import { getSysUI } from '@/utils/auth' +import { changeFavicon } from '@/utils/index' import { initTheme } from '@/utils/ThemeUtil' import PluginCom from '@/views/system/plugin/PluginCom' import Cookies from 'js-cookie' @@ -195,13 +196,11 @@ export default { if (this.uiInfo['ui.loginLogo'] && this.uiInfo['ui.loginLogo'].paramValue) { this.loginLogoUrl = '/system/ui/image/' + this.uiInfo['ui.loginLogo'].paramValue } - /* if (this.uiInfo['ui.themeStr'] && this.uiInfo['ui.themeStr'].paramValue) { - if (this.uiInfo['ui.themeStr'].paramValue === 'dark') { - document.body.className = 'blackTheme' - } else if (this.uiInfo['ui.themeStr'].paramValue === 'light') { - document.body.className = '' - } - } */ + + if (this.uiInfo['ui.favicon'] && this.uiInfo['ui.favicon'].paramValue) { + const faviconUrl = '/system/ui/image/' + this.uiInfo['ui.favicon'].paramValue + changeFavicon(faviconUrl) + } }, initCache() { this.clearLocalStorage.forEach(item => {