commit | author | age
|
9bcb19
|
1 |
import Vue from 'vue' |
I |
2 |
import { |
|
3 |
SIDEBAR_TYPE, |
|
4 |
DEFAULT_THEME, |
|
5 |
DEFAULT_LAYOUT_MODE, |
|
6 |
DEFAULT_COLOR, |
|
7 |
DEFAULT_COLOR_WEAK, |
|
8 |
DEFAULT_FIXED_HEADER, |
|
9 |
DEFAULT_FIXED_SIDEMENU, |
|
10 |
DEFAULT_FIXED_HEADER_HIDDEN, |
|
11 |
DEFAULT_CONTENT_WIDTH_TYPE, |
|
12 |
DEFAULT_MULTI_TAB |
|
13 |
} from '@/store/mutation-types' |
|
14 |
|
|
15 |
const app = { |
|
16 |
state: { |
|
17 |
sidebar: true, |
|
18 |
device: 'desktop', |
|
19 |
theme: '', |
|
20 |
layout: '', |
|
21 |
contentWidth: '', |
|
22 |
fixedHeader: false, |
|
23 |
fixSiderbar: false, |
|
24 |
autoHideHeader: false, |
|
25 |
color: null, |
|
26 |
weak: false, |
|
27 |
multiTab: true, |
|
28 |
hasError: false |
|
29 |
}, |
|
30 |
mutations: { |
|
31 |
SET_SIDEBAR_TYPE: (state, type) => { |
|
32 |
state.sidebar = type |
|
33 |
Vue.ls.set(SIDEBAR_TYPE, type) |
|
34 |
}, |
|
35 |
CLOSE_SIDEBAR: (state) => { |
|
36 |
Vue.ls.set(SIDEBAR_TYPE, true) |
|
37 |
state.sidebar = false |
|
38 |
}, |
|
39 |
TOGGLE_DEVICE: (state, device) => { |
|
40 |
state.device = device |
|
41 |
}, |
|
42 |
TOGGLE_THEME: (state, theme) => { |
|
43 |
// setStore('_DEFAULT_THEME', theme) |
|
44 |
Vue.ls.set(DEFAULT_THEME, theme) |
|
45 |
state.theme = theme |
|
46 |
}, |
|
47 |
TOGGLE_LAYOUT_MODE: (state, layout) => { |
|
48 |
Vue.ls.set(DEFAULT_LAYOUT_MODE, layout) |
|
49 |
state.layout = layout |
|
50 |
}, |
|
51 |
TOGGLE_FIXED_HEADER: (state, fixed) => { |
|
52 |
Vue.ls.set(DEFAULT_FIXED_HEADER, fixed) |
|
53 |
state.fixedHeader = fixed |
|
54 |
}, |
|
55 |
TOGGLE_FIXED_SIDERBAR: (state, fixed) => { |
|
56 |
Vue.ls.set(DEFAULT_FIXED_SIDEMENU, fixed) |
|
57 |
state.fixSiderbar = fixed |
|
58 |
}, |
|
59 |
TOGGLE_FIXED_HEADER_HIDDEN: (state, show) => { |
|
60 |
Vue.ls.set(DEFAULT_FIXED_HEADER_HIDDEN, show) |
|
61 |
state.autoHideHeader = show |
|
62 |
}, |
|
63 |
TOGGLE_CONTENT_WIDTH: (state, type) => { |
|
64 |
Vue.ls.set(DEFAULT_CONTENT_WIDTH_TYPE, type) |
|
65 |
state.contentWidth = type |
|
66 |
}, |
|
67 |
TOGGLE_COLOR: (state, color) => { |
|
68 |
Vue.ls.set(DEFAULT_COLOR, color) |
|
69 |
state.color = color |
|
70 |
}, |
|
71 |
TOGGLE_WEAK: (state, flag) => { |
|
72 |
Vue.ls.set(DEFAULT_COLOR_WEAK, flag) |
|
73 |
state.weak = flag |
|
74 |
}, |
|
75 |
TOGGLE_MULTI_TAB: (state, bool) => { |
|
76 |
Vue.ls.set(DEFAULT_MULTI_TAB, bool) |
|
77 |
state.multiTab = bool |
|
78 |
}, |
|
79 |
SET_HAS_ERROR: (state, bool) => { |
|
80 |
state.hasError = bool |
|
81 |
} |
|
82 |
}, |
|
83 |
actions: { |
|
84 |
setSidebar ({ commit }, type) { |
|
85 |
commit('SET_SIDEBAR_TYPE', type) |
|
86 |
}, |
|
87 |
CloseSidebar ({ commit }) { |
|
88 |
commit('CLOSE_SIDEBAR') |
|
89 |
}, |
|
90 |
ToggleDevice ({ commit }, device) { |
|
91 |
commit('TOGGLE_DEVICE', device) |
|
92 |
}, |
|
93 |
ToggleTheme ({ commit }, theme) { |
|
94 |
commit('TOGGLE_THEME', theme) |
|
95 |
}, |
|
96 |
ToggleLayoutMode ({ commit }, mode) { |
|
97 |
commit('TOGGLE_LAYOUT_MODE', mode) |
|
98 |
}, |
|
99 |
ToggleFixedHeader ({ commit }, fixedHeader) { |
|
100 |
if (!fixedHeader) { |
|
101 |
commit('TOGGLE_FIXED_HEADER_HIDDEN', false) |
|
102 |
} |
|
103 |
commit('TOGGLE_FIXED_HEADER', fixedHeader) |
|
104 |
}, |
|
105 |
ToggleFixSiderbar ({ commit }, fixSiderbar) { |
|
106 |
commit('TOGGLE_FIXED_SIDERBAR', fixSiderbar) |
|
107 |
}, |
|
108 |
ToggleFixedHeaderHidden ({ commit }, show) { |
|
109 |
commit('TOGGLE_FIXED_HEADER_HIDDEN', show) |
|
110 |
}, |
|
111 |
ToggleContentWidth ({ commit }, type) { |
|
112 |
commit('TOGGLE_CONTENT_WIDTH', type) |
|
113 |
}, |
|
114 |
ToggleColor ({ commit }, color) { |
|
115 |
commit('TOGGLE_COLOR', color) |
|
116 |
}, |
|
117 |
ToggleWeak ({ commit }, weakFlag) { |
|
118 |
commit('TOGGLE_WEAK', weakFlag) |
|
119 |
}, |
|
120 |
ToggleMultiTab ({ commit }, bool) { |
|
121 |
commit('TOGGLE_MULTI_TAB', bool) |
|
122 |
}, |
|
123 |
SetHasError ({ commit }, bool) { |
|
124 |
commit('SET_HAS_ERROR', bool) |
|
125 |
} |
|
126 |
} |
|
127 |
} |
|
128 |
|
|
129 |
export default app |