store.js
1.39 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
import Vue from 'vue';
import Vuex from 'vuex';
import actions from './actions';
import getters from './getters';
Vue.use(Vuex);
const state = {
slideShow: false,
animateIn: 'slideInRight',
animateOut: 'slideOutLeft',
animateMode: '',
swipeShow:false
};
const mutations = {
showSlideFn: (state, payload) => {
state.slideShow = true;
console.log(payload);
},
closeSlideFn: (state, payload) => {
state.slideShow = false;
console.log(payload);
},
changeAnimate: (state, payload) => {
if (payload.mode === 'normal') {
state.animateIn = 'slideInRight';
state.animateOut = 'slideOutLeft';
state.animateMode = '';
} else if (payload.mode === 'reverse') {
state.animateIn = 'slideInLeft';
state.animateOut = 'slideOutRight';
state.animateMode = '';
} else if (payload.mode === 'change') {
state.animateIn = payload.animateIn;
state.animateOut = payload.animateOut;
state.animateMode = payload.animateMode;
}
},
showSwipeFn:(state,payload)=>{
state.swipeShow=true;
},
closeSwipeFn:(state,payload)=>{
state.swipeShow=false;
},
};
// 整合初始状态和变更函数,我们就得到了我们所需的 store
// 至此,这个 store 就可以连接到我们的应用中
export default new Vuex.Store({
state,
mutations,
actions,
getters
});