store.js 1.1 KB

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