setting.js
2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import db from '@/utils/localstorage'
import { getLanguage } from '@/lang/index'
export default {
namespaced: true,
state: {
settingBar: {
opened: false
},
sidebar: {
opened: db.get('SIDEBAR_STATUS', true),
withoutAnimation: false
},
device: 'desktop',
language: getLanguage(),
sidebarLogo: db.get('SIDEBAR_LOGO', true),
multipage: db.get('MULTIPAGE', true),
fixSiderbar: db.get('FIX_SIDERBAR', true),
fixHeader: db.get('FIX_HEADER', true),
colorList: [
'rgb(245, 34, 45)',
'rgb(250, 84, 28)',
'rgb(250, 173, 20)',
'rgb(66, 185, 131)',
'rgb(82, 196, 26)',
'rgb(24, 144, 255)',
'rgb(47, 84, 235)',
'rgb(114, 46, 209)'
],
color: db.get('COLOR', 'rgb(24, 144, 255)'),
theme: '#1890FF'
},
mutations: {
toggleSidebar: state => {
state.sidebar.opened = !state.sidebar.opened
state.sidebar.withoutAnimation = false
if (state.sidebar.opened) {
db.save('SIDEBAR_STATUS', 1)
} else {
db.save('SIDEBAR_STATUS', 0)
}
},
closeSidebar: (state, withoutAnimation) => {
db.save('SIDEBAR_STATUS', 0)
state.sidebar.opened = false
state.sidebar.withoutAnimation = withoutAnimation
},
openSettingBar(state, val) {
state.settingBar.opened = val
},
setMultipage(state, multipage) {
db.save('MULTIPAGE', multipage)
state.multipage = multipage
},
fixSiderbar(state, val) {
db.save('FIX_SIDERBAR', val)
state.fixSiderbar = val
},
fixHeader(state, val) {
db.save('FIX_HEADER', val)
state.fixHeader = val
},
setSettingBar(state, val) {
state.settingBar.opened = val
},
setColor(state, color) {
db.save('COLOR', color)
state.color = color
},
setLanguage: (state, language) => {
db.save('LANGUAGE', language)
state.language = language
},
toggleDevice: (state, device) => {
state.device = device
},
setSidebarLogo(state, val) {
db.save('SIDEBAR_LOGO', val)
state.sidebarLogo = val
},
setTheme(state, val) {
state.theme = val
}
}
}