daimp-front/main/src/micro/actions.js

26 lines
523 B
JavaScript
Raw Normal View History

import { initGlobalState } from 'qiankun';
import { reactive } from 'vue';
2025-02-17 06:43:55 +00:00
export const initialState = reactive({
2025-02-13 07:06:39 +00:00
token: null,
2025-02-17 06:43:55 +00:00
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;