main-web/src/core/actions.ts

20 lines
564 B
TypeScript
Raw Normal View History

2024-08-20 12:11:33 +00:00
import { initGlobalState } from 'qiankun'
import type { MicroAppStateActions } from 'qiankun'
import store from '@/store'
const initialState = {
name: 'main-web',
onmessage: (data: any) => console.log(data),
userData: null,
permissions: null
}
const actions: MicroAppStateActions = initGlobalState(initialState)
2024-08-21 01:17:14 +00:00
actions.onGlobalStateChange(state => {
2024-08-20 12:11:33 +00:00
// state: 变更后的状态; prev 变更前的状态
// console.log('from:', state.name, 'current:', state, 'pre:', prev)
store.commit('SET_ONMESSAGE', state.onmessage)
})
export default actions