index.js 860 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import Vue from 'vue'
  2. import Vuex from 'vuex'
  3. import app from "./modules/app"
  4. import user from "./modules/user"
  5. import dict from "./modules/dict"
  6. import follow from "./modules/follow"
  7. import call from "./modules/call.js"
  8. import getters from "./getters";
  9. import createPersistedState from 'vuex-persistedstate'
  10. import {
  11. localStorage
  12. } from 'mp-storage'
  13. Vue.use(Vuex)
  14. const store = new Vuex.Store({
  15. modules: {
  16. app,
  17. user,
  18. dict,
  19. follow,
  20. call
  21. },
  22. getters,
  23. state: {
  24. hasLogin: false,
  25. },
  26. mutations: {},
  27. actions: {
  28. },
  29. plugins: [
  30. createPersistedState({
  31. storage: localStorage,
  32. paths: ['user'],
  33. reducer: function(state) {
  34. return {
  35. user: {
  36. // 只保存 user 中除了 netConfig 以外的其他属性
  37. ...state.user,
  38. netConfig: undefined // 显式排除 netConfig
  39. }
  40. }
  41. }
  42. })
  43. ],
  44. })
  45. export default store