index.js 833 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { createStore } from 'vuex'
  2. import app from "./modules/app"
  3. import user from "./modules/user"
  4. import dict from "./modules/dict"
  5. import follow from "./modules/follow"
  6. import call from "./modules/call.js"
  7. import getters from "./getters";
  8. import createPersistedState from 'vuex-persistedstate'
  9. import {
  10. localStorage
  11. } from 'mp-storage'
  12. const store = createStore({
  13. modules: {
  14. app,
  15. user,
  16. dict,
  17. follow,
  18. call
  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