<template>
  <router-view />
</template>

<script lang="ts" setup>
import { dialog } from '@/utils/vant'
import { useLogin } from '@/business/login'
import eventBus from '@/services/bus'
import { useNavigation } from '@mobile/router/navigation'

const { userLogout } = useLogin()
const { backHome } = useNavigation()

// 接收用户登出通知
eventBus.$on('Logout', (msg) => {
  userLogout(() => {
    if (msg) {
      dialog({
        message: msg as string,
        confirmButtonText: '确定'
      }).then(() => {
        backHome()
      })
    } else {
      backHome()
    }
  })
})
</script>