mirror of
https://github.com/jumpserver/lina.git
synced 2025-09-03 07:54:45 +00:00
feat: public settings 区分 public 和 open
This commit is contained in:
@@ -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({
|
return request({
|
||||||
url: '/api/v1/settings/public/',
|
url: url,
|
||||||
method: 'get'
|
method: 'get'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@@ -32,24 +32,25 @@ const actions = {
|
|||||||
commit('CHANGE_SETTING', data)
|
commit('CHANGE_SETTING', data)
|
||||||
},
|
},
|
||||||
// get user Profile
|
// get user Profile
|
||||||
getPublicSettings({ commit, state }) {
|
getPublicSettings({ commit, state }, isOpen) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
getPublicSettings().then(response => {
|
getPublicSettings(isOpen).then(response => {
|
||||||
const data = response.data || {}
|
const data = response || {}
|
||||||
const faviconURL = data['LOGO_URLS']?.favicon
|
if (isOpen) {
|
||||||
let link = document.querySelector("link[rel*='icon']")
|
const faviconURL = data['LOGO_URLS']?.favicon
|
||||||
if (!link) {
|
let link = document.querySelector("link[rel*='icon']")
|
||||||
link = document.createElement('link')
|
if (!link) {
|
||||||
link.type = 'image/x-icon'
|
link = document.createElement('link')
|
||||||
link.rel = 'shortcut icon'
|
link.type = 'image/x-icon'
|
||||||
document.getElementsByTagName('head')[0].appendChild(link)
|
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)
|
commit('SET_PUBLIC_SETTINGS', data)
|
||||||
resolve(response)
|
resolve(response)
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
|
@@ -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
|
// 获取Public settings
|
||||||
const publicSettings = store.getters.publicSettings
|
const publicSettings = store.getters.publicSettings
|
||||||
if (!publicSettings) {
|
if (!publicSettings || !isOpen) {
|
||||||
await store.dispatch('settings/getPublicSettings')
|
await store.dispatch('settings/getPublicSettings', isOpen)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,8 +142,10 @@ export async function startup({ to, from, next }) {
|
|||||||
await store.dispatch('app/init')
|
await store.dispatch('app/init')
|
||||||
|
|
||||||
// set page title
|
// 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 checkLogin({ to, from, next })
|
||||||
|
await getPublicSetting({ to, from, next }, false)
|
||||||
await changeCurrentViewIfNeed({ to, from, next })
|
await changeCurrentViewIfNeed({ to, from, next })
|
||||||
await changeCurrentOrgIfNeed({ to, from, next })
|
await changeCurrentOrgIfNeed({ to, from, next })
|
||||||
await generatePageRoutes({ to, from, next })
|
await generatePageRoutes({ to, from, next })
|
||||||
|
Reference in New Issue
Block a user