store.js 989 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import store from '../src/store';
  2. import vue from 'vue';
  3. export default function (state) {
  4. // alert(122);
  5. if (!state) {
  6. return;
  7. }
  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. if (state.user?.authorities) {
  23. store.commit('user/setAuthorities', state.user.authorities);
  24. }
  25. }
  26. export const createMutationObserve = ({ modules = [] }) => {
  27. return (mutation, state) => {
  28. if (
  29. modules?.length &&
  30. modules.find((i) => mutation.type.startWidth(i + '/'))
  31. ) {
  32. vue.$portalStore.commit(mutation.type, mutation.payload);
  33. }
  34. };
  35. };