feat: public settings 区分 public 和 open

This commit is contained in:
Jiangjie.Bai
2022-05-06 17:09:28 +08:00
committed by 老广
parent b81cbb3d16
commit 4a8305979e
3 changed files with 31 additions and 22 deletions

View File

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

View File

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

View File

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