feat(系统): 动态获取系统图标favicon

This commit is contained in:
fit2cloud-chenyw 2022-08-10 02:08:03 -04:00
parent 6f6e99bda4
commit 551a99f694
6 changed files with 27 additions and 14 deletions

View File

@ -1890,6 +1890,7 @@ export default {
un_install_error: 'Uninstall failed, please contact the administrator' un_install_error: 'Uninstall failed, please contact the administrator'
}, },
display: { display: {
favicon: 'Favicon',
logo: 'Head system logo', logo: 'Head system logo',
loginLogo: 'Login page header logo', loginLogo: 'Login page header logo',
loginImage: 'Picture on the right side of the login page', loginImage: 'Picture on the right side of the login page',

View File

@ -1890,6 +1890,7 @@ export default {
un_install_error: '卸載失敗,請聯系管理員' un_install_error: '卸載失敗,請聯系管理員'
}, },
display: { display: {
favicon: '系統圖標',
logo: '頭部繫統logo', logo: '頭部繫統logo',
loginLogo: '登錄頁面頭部logo', loginLogo: '登錄頁面頭部logo',
loginImage: '登錄頁面右側圖片', loginImage: '登錄頁面右側圖片',

View File

@ -1900,6 +1900,7 @@ export default {
un_install_error: '卸载失败,请联系管理员' un_install_error: '卸载失败,请联系管理员'
}, },
display: { display: {
favicon: '系统图标',
logo: '头部系统logo', logo: '头部系统logo',
loginLogo: '登录页面头部logo', loginLogo: '登录页面头部logo',
loginImage: '登录页面右侧图片', loginImage: '登录页面右侧图片',

View File

@ -104,6 +104,7 @@ import {
initTheme initTheme
} from '@/utils/ThemeUtil' } from '@/utils/ThemeUtil'
import TemplateMarket from '@/views/panel/templateMarket' import TemplateMarket from '@/views/panel/templateMarket'
import { changeFavicon } from '@/utils/index'
export default { export default {
name: 'Topbar', name: 'Topbar',
components: { components: {
@ -346,13 +347,11 @@ export default {
}) })
} }
/* if (this.uiInfo['ui.themeStr'] && this.uiInfo['ui.themeStr'].paramValue) { if (this.uiInfo['ui.favicon'] && this.uiInfo['ui.favicon'].paramValue) {
if (this.uiInfo['ui.themeStr'].paramValue === 'dark') { const faviconUrl = '/system/ui/image/' + this.uiInfo['ui.favicon'].paramValue
document.body.className = 'blackTheme' changeFavicon(faviconUrl)
} else if (this.uiInfo['ui.themeStr'].paramValue === 'light') { }
document.body.className = ''
}
} */
this.axiosFinished = true this.axiosFinished = true
}) })
}, },

View File

@ -313,3 +313,15 @@ export const isSameVueObj = (source, target) => {
} }
return false 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)
}
}

View File

@ -67,6 +67,7 @@
import { encrypt } from '@/utils/rsaEncrypt' import { encrypt } from '@/utils/rsaEncrypt'
import { ldapStatus, oidcStatus, getPublicKey, pluginLoaded, defaultLoginType } from '@/api/user' import { ldapStatus, oidcStatus, getPublicKey, pluginLoaded, defaultLoginType } from '@/api/user'
import { getSysUI } from '@/utils/auth' import { getSysUI } from '@/utils/auth'
import { changeFavicon } from '@/utils/index'
import { initTheme } from '@/utils/ThemeUtil' import { initTheme } from '@/utils/ThemeUtil'
import PluginCom from '@/views/system/plugin/PluginCom' import PluginCom from '@/views/system/plugin/PluginCom'
import Cookies from 'js-cookie' import Cookies from 'js-cookie'
@ -195,13 +196,11 @@ export default {
if (this.uiInfo['ui.loginLogo'] && this.uiInfo['ui.loginLogo'].paramValue) { if (this.uiInfo['ui.loginLogo'] && this.uiInfo['ui.loginLogo'].paramValue) {
this.loginLogoUrl = '/system/ui/image/' + 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') { if (this.uiInfo['ui.favicon'] && this.uiInfo['ui.favicon'].paramValue) {
document.body.className = 'blackTheme' const faviconUrl = '/system/ui/image/' + this.uiInfo['ui.favicon'].paramValue
} else if (this.uiInfo['ui.themeStr'].paramValue === 'light') { changeFavicon(faviconUrl)
document.body.className = '' }
}
} */
}, },
initCache() { initCache() {
this.clearLocalStorage.forEach(item => { this.clearLocalStorage.forEach(item => {