This repository was archived by the owner on Jun 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 88
/
Copy pathmutations.js
99 lines (91 loc) · 2.32 KB
/
mutations.js
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import * as i18n from '@/i18n'
import moment from 'moment'
const mutations = {
closeHovers: state => {
state.show = null
state.showMessage = null
},
toggleShell: (state) => {
state.showShell = !state.showShell
},
showHover: (state, value) => {
if (typeof value !== 'object') {
state.show = value
return
}
state.show = value.prompt
state.showMessage = value.message
state.showConfirm = value.confirm
},
showError: (state, value) => {
state.show = 'error'
state.showMessage = value
},
showSuccess: (state, value) => {
state.show = 'success'
state.showMessage = value
},
setLoading: (state, value) => { state.loading = value },
setReload: (state, value) => { state.reload = value },
setUser: (state, value) => {
if (value === null) {
state.user = null
return
}
let locale = value.locale
if (locale === '') {
locale = i18n.detectLocale()
}
moment.locale(locale)
i18n.default.locale = locale
state.user = value
},
setJWT: (state, value) => (state.jwt = value),
multiple: (state, value) => (state.multiple = value),
addSelected: (state, value) => (state.selected.push(value)),
addPlugin: (state, value) => {
state.plugins.push(value)
},
removeSelected: (state, value) => {
let i = state.selected.indexOf(value)
if (i === -1) return
state.selected.splice(i, 1)
},
resetSelected: (state) => {
state.selected = []
},
updateUser: (state, value) => {
if (typeof value !== 'object') return
for (let field in value) {
if (field === 'locale') {
moment.locale(value[field])
i18n.default.locale = value[field]
}
state.user[field] = value[field]
}
},
updateBookmark: (state, value) => {
if (value.path == state.req.path) {
state.req.bookmarked = value.bookmarked
}
},
updateRequest: (state, value) => {
state.oldReq = state.req
state.req = value
},
updateContext: (state, value) => {
state.context = value
},
updateClipboard: (state, value) => {
state.clipboard.key = value.key
state.clipboard.items = value.items
},
resetClipboard: (state) => {
state.clipboard.key = ''
state.clipboard.items = []
},
setProgress: (state, value) => {
state.progress = value
}
}
export default mutations