[update]完善页面图标和添加动态图标功能

This commit is contained in:
OrangeM21
2020-05-26 18:20:24 +08:00
parent 2ba3ed54d1
commit 4806634e3e
5 changed files with 33 additions and 4 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@@ -52,3 +52,9 @@ export function getPublicSettings() {
method: 'get'
})
}
export function getLogo() {
return request({
url: '/api/v1/xpack/interface/setting',
method: 'get'
})
}

View File

@@ -6,7 +6,8 @@
<h1 v-else class="sidebar-title">{{ title }}</h1>
</router-link>
<router-link v-else key="expand" class="sidebar-logo-link" to="/">
<img v-if="logoText" :src="logoText" class="sidebar-logo-text">
<img v-if="customSettings.logo_index != '/static/img/logo_text.png' " :src="customSettings.logo_index" class="sidebar-logo">
<img v-else-if="logoText" :src="logoText" class="sidebar-logo-text">
<!-- <h1 class="sidebar-title">{{ title }}</h1>-->
</router-link>
</transition>
@@ -14,6 +15,7 @@
</template>
<script>
import { mapGetters } from 'vuex'
export default {
name: 'SidebarLogo',
props: {
@@ -26,8 +28,17 @@ export default {
return {
title: 'JumpServer',
logoText: require('@/assets/img/logo-text.png'),
logo: require('@/assets/img/logo.png')
logo: require('@/assets/img/logo.png'),
xpackData: {}
}
},
computed: {
...mapGetters([
'customSettings'
])
},
created() {
console.log(this.customSettings.logo_index)
}
}
</script>

View File

@@ -9,6 +9,7 @@ const getters = {
visitedViews: state => state.tagsView.visitedViews,
cachedViews: state => state.tagsView.cachedViews,
publicSettings: state => state.settings.publicSettings,
customSettings: state => state.settings.customSettings,
getCurrentOrgRoles: state => state.users.profile.current_org_roles
}
export default getters

View File

@@ -1,5 +1,5 @@
import defaultSettings from '@/settings'
import { getPublicSettings } from '@/api/settings'
import { getPublicSettings, getLogo } from '@/api/settings'
const { showSettings, fixedHeader, sidebarLogo, tagsView } = defaultSettings
@@ -8,7 +8,8 @@ const state = {
fixedHeader: fixedHeader,
sidebarLogo: sidebarLogo,
tagsView: tagsView,
publicSettings: null
publicSettings: null,
customSettings: null
}
const mutations = {
@@ -19,6 +20,9 @@ const mutations = {
},
SET_PUBLIC_SETTINGS: (state, settings) => {
state.publicSettings = settings
},
SET_CUSTOM_SETTINGS: (state, settings) => {
state.customSettings = settings
}
}
@@ -31,6 +35,13 @@ const actions = {
return new Promise((resolve, reject) => {
getPublicSettings().then(response => {
commit('SET_PUBLIC_SETTINGS', response.data)
if (response.data.XPACK_ENABLED) {
if (response.data.XPACK_LICENSE_IS_VALID) {
getLogo().then((res) => {
commit('SET_CUSTOM_SETTINGS', res)
})
}
}
resolve(response)
}).catch(error => {
reject(error)