From c92ac374ba95c0146dc71cd87d078e5d668b00f9 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Mon, 22 Aug 2022 23:25:27 -0400 Subject: [PATCH] =?UTF-8?q?fix(=E7=B3=BB=E7=BB=9F=E7=AE=A1=E7=90=86-?= =?UTF-8?q?=E5=A4=96=E8=A7=82=E9=85=8D=E7=BD=AE):=20uiinfo=E8=BF=87?= =?UTF-8?q?=E5=A4=A7=E5=AF=BC=E8=87=B4=E5=AD=98=E5=82=A8=E5=9C=A8=E5=89=8D?= =?UTF-8?q?=E7=AB=AFcookie=E5=A4=B1=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/layout/components/Topbar.vue | 5 ++++- frontend/src/permission.js | 2 +- frontend/src/utils/auth.js | 4 ++-- frontend/src/views/login/index.vue | 9 ++++++--- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/frontend/src/layout/components/Topbar.vue b/frontend/src/layout/components/Topbar.vue index caa4875664..f580b1a2c3 100644 --- a/frontend/src/layout/components/Topbar.vue +++ b/frontend/src/layout/components/Topbar.vue @@ -334,8 +334,11 @@ export default { } }, loadUiInfo() { - this.$store.dispatch('user/getUI').then(() => { + this.$store.dispatch('user/getUI').then((res) => { this.uiInfo = getSysUI() + if (!this.uiInfo || Object.keys(this.uiInfo).length === 0) { + this.uiInfo = res + } if (this.uiInfo['ui.logo'] && this.uiInfo['ui.logo'].paramValue) { this.logoUrl = '/system/ui/image/' + this.uiInfo['ui.logo'].paramValue } diff --git a/frontend/src/permission.js b/frontend/src/permission.js index 92430d23ef..8b983c5449 100644 --- a/frontend/src/permission.js +++ b/frontend/src/permission.js @@ -46,7 +46,7 @@ const routeBefore = (callBack) => { }) } else { document.title = getPageTitle() - if (uiInfo['ui.favicon'] && uiInfo['ui.favicon'].paramValue) { + if (!!uiInfo && uiInfo['ui.favicon'] && uiInfo['ui.favicon'].paramValue) { const faviconUrl = '/system/ui/image/' + uiInfo['ui.favicon'].paramValue changeFavicon(faviconUrl) } diff --git a/frontend/src/utils/auth.js b/frontend/src/utils/auth.js index b5d3ed9f7f..680a502d86 100644 --- a/frontend/src/utils/auth.js +++ b/frontend/src/utils/auth.js @@ -1,6 +1,6 @@ import Cookies from 'js-cookie' import Config from '@/settings' - +import store from '@/store' const TokenKey = Config.TokenKey const IdTokenKey = Config.IdTokenKey @@ -48,7 +48,7 @@ export function setSysUI(uiInfo) { export function getSysUI() { const json = Cookies.get('sysUiInfo') - return json ? JSON.parse(json) : null + return json ? JSON.parse(json) : store.getters.uiInfo } export function getTimeOut() { diff --git a/frontend/src/views/login/index.vue b/frontend/src/views/login/index.vue index f86ab4e39a..d606534438 100644 --- a/frontend/src/views/login/index.vue +++ b/frontend/src/views/login/index.vue @@ -164,9 +164,9 @@ export default { }, created() { - this.$store.dispatch('user/getUI').then(() => { + this.$store.dispatch('user/getUI').then((res) => { this.axiosFinished = true - this.showLoginImage() + this.showLoginImage(res) }).catch(err => { console.error(err) }) @@ -191,8 +191,11 @@ export default { Cookies.remove('OidcError') Cookies.remove('IdToken') }, - showLoginImage() { + showLoginImage(uiInfo) { this.uiInfo = getSysUI() + if (!this.uiInfo || Object.keys(this.uiInfo).length === 0) { + this.uiInfo = uiInfo + } if (this.uiInfo['ui.loginImage'] && this.uiInfo['ui.loginImage'].paramValue) { this.loginImageUrl = '/system/ui/image/' + this.uiInfo['ui.loginImage'].paramValue }