Browse Source

全局参数 2022年11月14日 sxm

master
[li_she] 3 years ago
parent
commit
37025a385b
  1. 10
      src/store/modules/user.js
  2. 101
      src/views/main.vue

10
src/store/modules/user.js

@ -7,8 +7,8 @@ export default {
languageDefault: '',
userDisplay: '',
userDev: false,
multiLanguage: JSON.parse(localStorage.getItem('configParams')).multiLanguage,
authControl: JSON.parse(localStorage.getItem('configParams')).authControl,
multiLanguage: '',
authControl: '',
},
mutations: {
updateId (state, id) {
@ -25,6 +25,12 @@ export default {
},
updateUserDisplay (state,userDisplay){
state.userDisplay = userDisplay
},
updateMultiLanguage (state,multiLanguage){
state.userDisplay = multiLanguage
},
updateAuthControl (state,authControl){
state.userDisplay = authControl
}
}
}

101
src/views/main.vue

@ -5,10 +5,10 @@
v-loading.fullscreen.lock="loading"
element-loading-text="拼命加载中">
<template v-if="!loading">
<main-navbar />
<main-sidebar />
<main-navbar/>
<main-sidebar/>
<div class="site-content__wrapper" :style="{ 'min-height': documentClientHeight + 'px' }">
<main-content v-if="!$store.state.common.contentIsNeedRefresh" />
<main-content v-if="!$store.state.common.contentIsNeedRefresh"/>
</div>
</template>
</div>
@ -19,11 +19,12 @@
import MainNavbar from './main-navbar'
import MainSidebar from './main-sidebar'
import MainContent from './main-content'
export default {
provide () {
provide() {
return {
//
refresh () {
refresh() {
this.$store.commit('common/updateContentIsNeedRefresh', true)
this.$nextTick(() => {
this.$store.commit('common/updateContentIsNeedRefresh', false)
@ -31,7 +32,7 @@
}
}
},
data () {
data() {
return {
loading: true
}
@ -43,50 +44,92 @@
},
computed: {
documentClientHeight: {
get () { return this.$store.state.common.documentClientHeight },
set (val) { this.$store.commit('common/updateDocumentClientHeight', val) }
get() {
return this.$store.state.common.documentClientHeight
},
set(val) {
this.$store.commit('common/updateDocumentClientHeight', val)
}
},
sidebarFold: {
get () { return this.$store.state.common.sidebarFold }
get() {
return this.$store.state.common.sidebarFold
}
},
userId: {
get () { return this.$store.state.user.id },
set (val) { this.$store.commit('user/updateId', val) }
get() {
return this.$store.state.user.id
},
set(val) {
this.$store.commit('user/updateId', val)
}
},
userName: {
get () { return this.$store.state.user.name },
set (val) { this.$store.commit('user/updateName', val) }
get() {
return this.$store.state.user.name
},
set(val) {
this.$store.commit('user/updateName', val)
}
},
site: {
get () { return this.$store.state.user.site },
set (val) { this.$store.commit('user/updateSite', val) }
get() {
return this.$store.state.user.site
},
set(val) {
this.$store.commit('user/updateSite', val)
}
},
languageDefault: {
get () { return this.$store.state.user.languageDefault },
set (val) { this.$store.commit('user/updateLanguageDefault', val) }
get() {
return this.$store.state.user.languageDefault
},
set(val) {
this.$store.commit('user/updateLanguageDefault', val)
}
},
userDisplay: {
get () { return this.$store.state.user.userDisplay },
set (val) { this.$store.commit('user/updateUserDisplay', val) }
get() {
return this.$store.state.user.userDisplay
},
set(val) {
this.$store.commit('user/updateUserDisplay', val)
}
},
multiLanguage: {
get() {
return this.$store.state.user.multiLanguage
},
set(val) {
this.$store.commit('user/updateMultiLanguage', val)
}
},
authControl: {
get() {
return this.$store.state.user.updateAuthControl
},
set(val) {
this.$store.commit('user/updateUserDisplay', val)
}
}
},
created () {
created() {
this.getUserInfo()
this.getConfigParams()
},
mounted () {
mounted() {
this.resetDocumentClientHeight()
},
methods: {
//
resetDocumentClientHeight () {
this.documentClientHeight = document.documentElement['clientHeight']-1
resetDocumentClientHeight() {
this.documentClientHeight = document.documentElement['clientHeight'] - 1
window.onresize = () => {
this.documentClientHeight = document.documentElement['clientHeight']-1
this.documentClientHeight = document.documentElement['clientHeight'] - 1
}
},
//
getUserInfo () {
getUserInfo() {
this.$http({
url: this.$http.adornUrl('/sys/user/info'),
method: 'get',
@ -104,10 +147,12 @@
})
},
//
getConfigParams(){
getConfigParams().then(({data}) =>{
if (data && data.code == 0){
getConfigParams() {
getConfigParams().then(({data}) => {
if (data && data.code == 0) {
localStorage.setItem('configParams', JSON.stringify(data.data))
this.multiLanguage = JSON.parse(localStorage.getItem('configParams')).multiLanguage
this.authControl = JSON.parse(localStorage.getItem('configParams')).authControl
}
})
}

Loading…
Cancel
Save