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: '', languageDefault: '',
userDisplay: '', userDisplay: '',
userDev: false, userDev: false,
multiLanguage: JSON.parse(localStorage.getItem('configParams')).multiLanguage,
authControl: JSON.parse(localStorage.getItem('configParams')).authControl,
multiLanguage: '',
authControl: '',
}, },
mutations: { mutations: {
updateId (state, id) { updateId (state, id) {
@ -25,6 +25,12 @@ export default {
}, },
updateUserDisplay (state,userDisplay){ updateUserDisplay (state,userDisplay){
state.userDisplay = 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" v-loading.fullscreen.lock="loading"
element-loading-text="拼命加载中"> element-loading-text="拼命加载中">
<template v-if="!loading"> <template v-if="!loading">
<main-navbar />
<main-sidebar />
<main-navbar/>
<main-sidebar/>
<div class="site-content__wrapper" :style="{ 'min-height': documentClientHeight + 'px' }"> <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> </div>
</template> </template>
</div> </div>
@ -19,11 +19,12 @@
import MainNavbar from './main-navbar' import MainNavbar from './main-navbar'
import MainSidebar from './main-sidebar' import MainSidebar from './main-sidebar'
import MainContent from './main-content' import MainContent from './main-content'
export default { export default {
provide () {
provide() {
return { return {
// //
refresh () {
refresh() {
this.$store.commit('common/updateContentIsNeedRefresh', true) this.$store.commit('common/updateContentIsNeedRefresh', true)
this.$nextTick(() => { this.$nextTick(() => {
this.$store.commit('common/updateContentIsNeedRefresh', false) this.$store.commit('common/updateContentIsNeedRefresh', false)
@ -31,7 +32,7 @@
} }
} }
}, },
data () {
data() {
return { return {
loading: true loading: true
} }
@ -43,50 +44,92 @@
}, },
computed: { computed: {
documentClientHeight: { 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: { sidebarFold: {
get () { return this.$store.state.common.sidebarFold }
get() {
return this.$store.state.common.sidebarFold
}
}, },
userId: { 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: { 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: { 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: { 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: { 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.getUserInfo()
this.getConfigParams() this.getConfigParams()
}, },
mounted () {
mounted() {
this.resetDocumentClientHeight() this.resetDocumentClientHeight()
}, },
methods: { methods: {
// //
resetDocumentClientHeight () {
this.documentClientHeight = document.documentElement['clientHeight']-1
resetDocumentClientHeight() {
this.documentClientHeight = document.documentElement['clientHeight'] - 1
window.onresize = () => { window.onresize = () => {
this.documentClientHeight = document.documentElement['clientHeight']-1
this.documentClientHeight = document.documentElement['clientHeight'] - 1
} }
}, },
// //
getUserInfo () {
getUserInfo() {
this.$http({ this.$http({
url: this.$http.adornUrl('/sys/user/info'), url: this.$http.adornUrl('/sys/user/info'),
method: 'get', 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)) 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