store.js 1.2 KB

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