diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 633c045..d5e0279 100644 --- a/src/store/modules/user.js +++ b/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 } } } diff --git a/src/views/main.vue b/src/views/main.vue index 5247626..6afc483 100644 --- a/src/views/main.vue +++ b/src/views/main.vue @@ -5,10 +5,10 @@ v-loading.fullscreen.lock="loading" element-loading-text="拼命加载中"> @@ -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 } }) }