Browse Source

chore: 优化onGlobalStateChange

master
wangxiang 2 years ago
parent
commit
2c0db9a054
  1. 7
      src/qiankun/state.ts

7
src/qiankun/state.ts

@ -11,6 +11,7 @@ import { router } from '/@/router'; @@ -11,6 +11,7 @@ import { router } from '/@/router';
import { getAccessToken } from '/@/utils/auth';
import { useMicroAppStore } from '/@/store/modules/microApp';
import { GlStateEnum } from '/@/enums/microAppEnum';
import { isEmpty } from '/@/utils/is';
/** 子应用的数据 */
export function getSubDefineProps() {
@ -35,8 +36,8 @@ export function initGlState(state?: Recordable): MicroAppStateActions { @@ -35,8 +36,8 @@ export function initGlState(state?: Recordable): MicroAppStateActions {
const actions = initGlobalState(state);
actions.onGlobalStateChange((newState, prev) => {
const { [GlStateEnum.FORM_DESIGN_EMIT_KEY]: formDesignEmit, [GlStateEnum.WORKFLOW_DESIGN_EMIT_KEY]: workflowDesignEmit } = newState;
formDesignEmit && microAppStore.setFormDesignApp(formDesignEmit);
workflowDesignEmit && microAppStore.setWorkflowDesignApp(workflowDesignEmit);
}, true);
!isEmpty(formDesignEmit) && microAppStore.setFormDesignApp(formDesignEmit);
!isEmpty(workflowDesignEmit) && microAppStore.setWorkflowDesignApp(workflowDesignEmit);
});
return actions;
}

Loading…
Cancel
Save