mirror of
https://github.com/jumpserver/lina.git
synced 2025-08-31 14:38:02 +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({
|
||||
url: '/api/v1/settings/public/',
|
||||
url: url,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
@@ -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 => {
|
||||
|
@@ -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 })
|
||||
|
Reference in New Issue
Block a user