store.js 969 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. 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. if (state.user?.authorityDept) {
  22. // store.dispatch('user/getCurrentUserAuthorityDept');
  23. }
  24. }
  25. export const createMutationObserve = ({ modules = [] }) => {
  26. return (mutation, state) => {
  27. if (
  28. modules?.length &&
  29. modules.find((i) => mutation.type.startWidth(i + '/'))
  30. ) {
  31. vue.$portalStore.commit(mutation.type, mutation.payload);
  32. }
  33. };
  34. };