提交
This commit is contained in:
23
src/store/index.js
Normal file
23
src/store/index.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
import cloneDeep from 'lodash/cloneDeep'
|
||||
import common from './modules/common'
|
||||
import user from './modules/user'
|
||||
|
||||
Vue.use(Vuex)
|
||||
|
||||
export default new Vuex.Store({
|
||||
modules: {
|
||||
common,
|
||||
user
|
||||
},
|
||||
mutations: {
|
||||
// 重置vuex本地储存状态
|
||||
resetStore (state) {
|
||||
Object.keys(state).forEach((key) => {
|
||||
state[key] = cloneDeep(window.SITE_CONFIG['storeState'][key])
|
||||
})
|
||||
}
|
||||
},
|
||||
strict: process.env.NODE_ENV !== 'production'
|
||||
})
|
||||
45
src/store/modules/common.js
Normal file
45
src/store/modules/common.js
Normal file
@@ -0,0 +1,45 @@
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
// 页面文档可视高度(随窗口改变大小)
|
||||
documentClientHeight: 0,
|
||||
// 导航条, 布局风格, defalut(默认) / inverse(反向)
|
||||
navbarLayoutType: 'default',
|
||||
// 侧边栏, 布局皮肤, light(浅色) / dark(黑色)
|
||||
sidebarLayoutSkin: 'dark',
|
||||
// 侧边栏, 折叠状态
|
||||
sidebarFold: false,
|
||||
// 侧边栏, 菜单
|
||||
menuList: [],
|
||||
menuActiveName: '',
|
||||
// 主入口标签页
|
||||
mainTabs: [],
|
||||
mainTabsActiveName: ''
|
||||
},
|
||||
mutations: {
|
||||
updateDocumentClientHeight (state, height) {
|
||||
state.documentClientHeight = height
|
||||
},
|
||||
updateNavbarLayoutType (state, type) {
|
||||
state.navbarLayoutType = type
|
||||
},
|
||||
updateSidebarLayoutSkin (state, skin) {
|
||||
state.sidebarLayoutSkin = skin
|
||||
},
|
||||
updateSidebarFold (state, fold) {
|
||||
state.sidebarFold = fold
|
||||
},
|
||||
updateMenuList (state, list) {
|
||||
state.menuList = list
|
||||
},
|
||||
updateMenuActiveName (state, name) {
|
||||
state.menuActiveName = name
|
||||
},
|
||||
updateMainTabs (state, tabs) {
|
||||
state.mainTabs = tabs
|
||||
},
|
||||
updateMainTabsActiveName (state, name) {
|
||||
state.mainTabsActiveName = name
|
||||
}
|
||||
}
|
||||
}
|
||||
15
src/store/modules/user.js
Normal file
15
src/store/modules/user.js
Normal file
@@ -0,0 +1,15 @@
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
id: 0,
|
||||
name: ''
|
||||
},
|
||||
mutations: {
|
||||
updateId (state, id) {
|
||||
state.id = id
|
||||
},
|
||||
updateName (state, name) {
|
||||
state.name = name
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user