an_xiao/police_uniapp/store/index.js

30 lines
897 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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