index.js 815 B

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