store.js 954 B

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