daimp-front/main/src/micro/actions.js
2025-02-28 06:28:54 +00:00

26 lines
523 B
JavaScript

import { initGlobalState } from 'qiankun';
import { reactive } from 'vue';
export const initialState = reactive({
token: null,
user: {},
roles: [],
menus: [],
auths: [],
});
const actions = initGlobalState(initialState);
actions.onGlobalStateChange((newState, prev) => {
console.log('main change', newState, prev);
for (const key in newState) {
initialState[key] = newState[key];
}
});
actions.getGlobalState = (key) => {
return key ? initialState[key] : initialState;
};
export default actions;