store.js 871 B

1234567891011121314151617181920212223242526272829303132
  1. import store from '../src/store';
  2. import vue from 'vue';
  3. export default function (state) {
  4. if (!state) {
  5. return;
  6. }
  7. console.log(state);
  8. // 主题
  9. if (state.theme) {
  10. for (const key in state.theme) {
  11. store.commit('theme/SET', { key, value: state.theme[key] });
  12. }
  13. store.dispatch('theme/setColor', state.theme.color);
  14. store.dispatch('theme/setWeakMode', state.theme.weakMode);
  15. store.dispatch('theme/setStyleResponsive', state.theme.styleResponsive);
  16. }
  17. // 用户信息
  18. if (state.user?.info) {
  19. store.commit('user/setUserInfo', state.user.info);
  20. }
  21. }
  22. export const createMutationObserve = ({ modules = [] }) => {
  23. return (mutation, state) => {
  24. if (
  25. modules?.length &&
  26. modules.find((i) => mutation.type.startWidth(i + '/'))
  27. ) {
  28. vue.$portalStore.commit(mutation.type, mutation.payload);
  29. }
  30. };
  31. };