diff --git a/src/api/settings.js b/src/api/settings.js index 2c2b6ffad..e3bee757e 100644 --- a/src/api/settings.js +++ b/src/api/settings.js @@ -68,9 +68,15 @@ export function importLdapUser(data) { }) } -export function getPublicSettings() { +export function getPublicSettings(isOpen) { + let url + if (isOpen) { + url = '/api/v1/settings/public/open/' + } else { + url = '/api/v1/settings/public/' + } return request({ - url: '/api/v1/settings/public/', + url: url, method: 'get' }) } diff --git a/src/store/modules/settings.js b/src/store/modules/settings.js index 115ccec21..b9d1a41bd 100644 --- a/src/store/modules/settings.js +++ b/src/store/modules/settings.js @@ -32,24 +32,25 @@ const actions = { commit('CHANGE_SETTING', data) }, // get user Profile - getPublicSettings({ commit, state }) { + getPublicSettings({ commit, state }, isOpen) { return new Promise((resolve, reject) => { - getPublicSettings().then(response => { - const data = response.data || {} - const faviconURL = data['LOGO_URLS']?.favicon - let link = document.querySelector("link[rel*='icon']") - if (!link) { - link = document.createElement('link') - link.type = 'image/x-icon' - link.rel = 'shortcut icon' - document.getElementsByTagName('head')[0].appendChild(link) + getPublicSettings(isOpen).then(response => { + const data = response || {} + if (isOpen) { + const faviconURL = data['LOGO_URLS']?.favicon + let link = document.querySelector("link[rel*='icon']") + if (!link) { + link = document.createElement('link') + link.type = 'image/x-icon' + link.rel = 'shortcut icon' + document.getElementsByTagName('head')[0].appendChild(link) + } + if (faviconURL) { + link.href = faviconURL + } + // 动态修改Title + document.title = data['LOGIN_TITLE'] } - if (faviconURL) { - link.href = faviconURL - } - - // 动态修改Title - document.title = data['LOGIN_TITLE'] commit('SET_PUBLIC_SETTINGS', data) resolve(response) }).catch(error => { diff --git a/src/utils/startup.js b/src/utils/startup.js index d9481a1dd..043062e49 100644 --- a/src/utils/startup.js +++ b/src/utils/startup.js @@ -42,11 +42,11 @@ async function checkLogin({ to, from, next }) { } } -async function getPublicSetting({ to, from, next }) { +async function getPublicSetting({ to, from, next }, isOpen) { // 获取Public settings const publicSettings = store.getters.publicSettings - if (!publicSettings) { - await store.dispatch('settings/getPublicSettings') + if (!publicSettings || !isOpen) { + await store.dispatch('settings/getPublicSettings', isOpen) } } @@ -142,8 +142,10 @@ export async function startup({ to, from, next }) { await store.dispatch('app/init') // set page title - await getPublicSetting({ to, from, next }) + // await getOpenPublicSetting({ to, from, next }) + await getPublicSetting({ to, from, next }, true) await checkLogin({ to, from, next }) + await getPublicSetting({ to, from, next }, false) await changeCurrentViewIfNeed({ to, from, next }) await changeCurrentOrgIfNeed({ to, from, next }) await generatePageRoutes({ to, from, next })