123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- 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,
- isMounted: false,
- },
- };
- }
- 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,
- url: {},
- });
-
- 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;
- }
|