| 1234567891011121314151617181920212223242526272829303132333435 |
- import store from '../src/store';
- /**
- * 同步门户下发的主题与用户信息(与 EOM qiankun_config/store.js 一致)
- */
- export default function initParentStore(state) {
- if (!state) {
- return;
- }
- // 主题(门户可能传 store 或 store.state)
- const theme = state.theme || state.state?.theme;
- if (theme) {
- for (const key in theme) {
- store.commit('theme/SET', { key, value: theme[key] });
- }
- if (theme.color != null) {
- store.dispatch('theme/setColor', theme.color);
- }
- if (theme.weakMode != null) {
- store.dispatch('theme/setWeakMode', theme.weakMode);
- }
- if (theme.styleResponsive != null) {
- store.dispatch('theme/setStyleResponsive', theme.styleResponsive);
- }
- }
- const user = state.user || state.state?.user;
- if (user?.info) {
- store.commit('user/setUserInfo', user.info);
- }
- if (user?.authorities) {
- store.commit('user/setAuthorities', user.authorities);
- }
- }
|