an_xiao/police_uniapp/store/index.js

30 lines
897 B
JavaScript
Raw Normal View History

2024-07-25 16:03:08 +08:00
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