1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- import { initGlobalState } from 'qiankun';
- import { store } from '/@/store';
- import { router } from '/@/router';
- import { getToken } from '/@/utils/auth';
- let actions;
- export function getProps() {
- return {
- data: {
- publicPath: '/',
- token: getToken(),
- store: store,
- router,
- },
- };
- }
- export function initGlState(info: any = { token: '', userInfo: {}, isMounted: false,locationObj: null, locationId: '', pageObj: null, widthScale: 1, heightScale: 1}) {
- if (actions) return;
-
- actions = initGlobalState(info);
-
- actions.setGlobalState({
- token: getToken(),
- isMounted: false,
- pageObj: {},
- widthScale: 1,
- heightScale: 1
- });
-
- actions.onGlobalStateChange((newState, prev) => {
-
- console.info('newState', newState);
- console.info('prev', prev);
- for (const key in newState) {
- console.info('onGlobalStateChange', key);
- }
- });
- }
- export function getActions() {
- if (!actions) initGlState();
- return actions;
- }
|