add basic

This commit is contained in:
shaohaojiecoder
2020-02-07 22:05:52 +08:00
parent 680a547df4
commit ba142266fb
19 changed files with 487 additions and 122 deletions

View File

@@ -0,0 +1,16 @@
import { mapState } from 'vuex'
const mixin = {
computed: {
...mapState({
currentLang: state => state.i18n.lang
})
},
methods: {
setLang (lang) {
this.$store.dispatch('SetLang', lang)
}
}
}
export { mixin }

View File

@@ -3,6 +3,7 @@ import Vuex from 'vuex'
import app from './modules/app'
import user from './modules/user'
import i18n from './modules/i18n'
import permission from './modules/permission'
import getters from './getters'
@@ -12,7 +13,8 @@ export default new Vuex.Store({
modules: {
app,
user,
permission
permission,
i18n
},
state: {

View File

@@ -0,0 +1,24 @@
import { loadLanguageAsync } from '@/locales'
const i18n = {
state: {
lang: 'en-US'
},
mutations: {
SET_LANG: (state, lang) => {
state.lang = lang
}
},
actions: {
// 设置界面语言
SetLang ({ commit }, lang) {
return new Promise(resolve => {
commit('SET_LANG', lang)
loadLanguageAsync(lang)
resolve()
})
}
}
}
export default i18n