Merge pull request #2820 from dataease/pr@dev@feat_favicon_setting

feat(系统): 动态获取系统图标favicon
This commit is contained in:
fit2cloud-chenyw 2022-08-10 14:09:09 +08:00 committed by GitHub
commit ae434c0847
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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'
},
display: {
favicon: 'Favicon',
logo: 'Head system logo',
loginLogo: 'Login page header logo',
loginImage: 'Picture on the right side of the login page',

View File

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

View File

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

View File

@ -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
})
},

View File

@ -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)
}
}

View File

@ -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 => {