// 监听门户发送过来的用户信息消息，
import { useCoreStore } from '@/stores'
import { BridgeCore, FRAME_REFRESH, FRAME_USER_INFO_TYPE } from '@cacp/bridge-core'

// 对cookie和userInfo进行监听
export function addEventListener(bridge: BridgeCore) {
  const coreStore = useCoreStore()
  bridge.registerHandler(FRAME_REFRESH, () => {
    coreStore.clear()
    window.location.reload()
  })

  bridge.registerHandler(FRAME_USER_INFO_TYPE, (data: any) => {
    console.log(`我接收到了从框架发送到框架的信息:`, data);
  })
}
