You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
913 B
38 lines
913 B
import Vue from 'vue'
|
|
import Vuex from 'vuex'
|
|
|
|
Vue.use(Vuex)
|
|
|
|
const store = new Vuex.Store({
|
|
state: {
|
|
theme: localStorage.theme || 'dark',
|
|
// 获取应用配置
|
|
appConfig: (() => {
|
|
if (localStorage.appConfig) {
|
|
return JSON.parse(localStorage.appConfig)
|
|
} else {
|
|
return {}
|
|
}
|
|
})()
|
|
},
|
|
mutations: {
|
|
SET_THEME(state, data) {
|
|
state.theme = data
|
|
localStorage.setItem('theme', data)
|
|
},
|
|
SET_APPCONFIG(state, data) {
|
|
state.appConfig = data
|
|
localStorage.setItem('appConfig', JSON.stringify(data))
|
|
}
|
|
},
|
|
actions: {
|
|
setTheme({ commit }, data) {
|
|
commit('SET_THEME', data)
|
|
},
|
|
setAppConfig({ commit }, data) {
|
|
commit('SET_APPCONFIG', data)
|
|
}
|
|
},
|
|
})
|
|
|
|
export default store
|
|
|