-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstore.js
86 lines (85 loc) · 1.9 KB
/
store.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
import Vue from 'vue'
import Vuex from 'vuex'
import {
getStorageSync,
ChangeAndStorageState
} from '@/commonFun.js'
import {
config
} from '@/config.js';
import allColor from '@/theme-color.js'
import schedule from '@/pages/schedule/schedule_store.js'
import grade from '@/pages/grade/grade_store.js';
import file from '@/pages/file/file_store.js';
Vue.use(Vuex)
let store = new Vuex.Store({
modules: {
schedule,
grade,
file
},
state: {
//gray red orange blue cyan pink
//第二个参数为默认颜色
themeColor: allColor.otherTheme.theme ? 'otherTheme' : getStorageSync('themeColor', config.defaultColor),
// themeColor: getStorageSync('themeColor','gray'),
isShake: getStorageSync('isShake', true),
account: getStorageSync('account', {
ID: '',
password: ''
}, true),
education: getStorageSync('education', {
ID: '',
password: ''
}, true),
allColor: allColor,
},
mutations: {
changeStateofGlobal: ChangeAndStorageState,
changeOtherTheme(state, par) {
state.allColor.otherTheme = par;
state.themeColor = 'otherTheme';
uni.setStorageSync('otherTheme', JSON.stringify(par));
},
},
getters: {
color(state) {
return state.allColor[state.themeColor];
},
}
})
const computed = {
computed: {
$colorList() {
return store.getters.color;
// this.$colorList = {
// theme:'',
// dark:'',
// white:'',
// side:''
// }
},
$themeColor() {
return store.state.themeColor;
},
$themeFont() {
return `color:${store.getters.color.theme};`
},
$themeBackground() {
return `background-color:${store.getters.color.theme};`
},
$isShake() {
return store.state.isShake;
},
$account() {
return store.state.account;
},
$education() {
return store.state.education;
},
}
}
Vue.mixin(computed);
export const commit =store.commit;
export const state = store.state
export default store;