mirror of
https://github.com/veops/cmdb.git
synced 2025-08-09 02:18:43 +08:00
add basic
This commit is contained in:
16
cmdb-ui/src/store/i18n-mixin.js
Normal file
16
cmdb-ui/src/store/i18n-mixin.js
Normal 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 }
|
@@ -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: {
|
||||
|
||||
|
24
cmdb-ui/src/store/modules/i18n.js
Normal file
24
cmdb-ui/src/store/modules/i18n.js
Normal 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
|
Reference in New Issue
Block a user