30 lines
897 B
JavaScript
30 lines
897 B
JavaScript
import Vue from 'vue'
|
||
import Vuex from 'vuex'
|
||
|
||
//引入vuex持久化存储插件
|
||
import persistedstate from 'vuex-persistedstate'
|
||
|
||
Vue.use(Vuex);
|
||
import users from "./modules/user"
|
||
import openid from './openids/openid.js'
|
||
import daily from './daily/daily'
|
||
const store = new Vuex.Store({
|
||
modules: {
|
||
users,
|
||
openid,
|
||
daily
|
||
},
|
||
plugins: [
|
||
// 需要缓存的,可以在paths里面写
|
||
persistedstate({
|
||
key: 'app_config_data', // 状态保存到本地的 key
|
||
paths: ["users.userInformation","users.schoolInformation","openid.openid","daily.userdailyinspection"], // 要持久化的状态,在state里面取,如果有嵌套,可以 a.b.c
|
||
storage: {
|
||
getItem: key => uni.getStorageSync(key),
|
||
setItem: (key, value) => uni.setStorageSync(key, value),
|
||
removeItem: key => uni.removeStorageSync(key)
|
||
}
|
||
})
|
||
]
|
||
})
|
||
export default store |