Commit 03b9d08f authored by 崔佳豪's avatar 崔佳豪

fix: 重复初始化应用共享状态导致状态错乱问题

parent 79238d23
// 主应用 和 子应用数据传递
import { initGlobalState } from 'qiankun';
export const initialState = {
globalConfig: {},
};
const actions = initGlobalState(initialState);
// action.setGlobalState({key: value}) 更新状态
// actions.onGlobalStateChange((newState, prevStaet) => {}) 监听状态
export default actions;
......@@ -3,7 +3,6 @@ import 'kit_logger';
import _ from 'lodash';
import {
addGlobalUncaughtErrorHandler,
initGlobalState,
registerMicroApps,
runAfterFirstMounted,
setDefaultMountApp,
......@@ -17,6 +16,7 @@ import { actionCreators } from './containers/App/store';
import { FILTER_FOLER_REG } from './utils/constants';
import loader from './render';
import store from './stores';
import actions from './actions';
// eslint-disable-next-line no-undef
const Logger = logger('micro');
......@@ -119,16 +119,9 @@ export const initMicroApps = () => {
},
);
const globalStore = store.getState().toJS();
const { setGlobalState } = initGlobalState({
// eslint-disable-next-line no-undef
globalConfig: window.globalConfig,
//createStoreage.get('globalConfig'),
global: globalStore.global
});
const globalConfig = window.globalConfig;
// globalConfig.homepage = globalConfig.homepage && /civweb4/.test(globalConfig.homepage) ? config.homepage.replace(/civweb4\//, ''): globalConfig.homepage;
console.log(globalConfig);
setGlobalState({
actions.setGlobalState({
// eslint-disable-next-line no-undef
globalConfig: globalConfig,
//createStoreage.get('globalConfig'),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment