Browse Source

全局参数 2022年11月14日 sxm

master
[li_she] 3 years ago
parent
commit
37025a385b
  1. 10
      src/store/modules/user.js
  2. 71
      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
} }
} }
} }

71
src/views/main.vue

@ -19,6 +19,7 @@
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 {
@ -43,31 +44,73 @@
}, },
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() {
@ -108,6 +151,8 @@
getConfigParams().then(({data}) => { getConfigParams().then(({data}) => {
if (data && data.code == 0) { 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