App.vue 653 B

1234567891011121314151617181920212223242526272829303132
  1. <template>
  2. <router-view />
  3. </template>
  4. <script lang="ts" setup>
  5. import { useNavigation } from '@/hooks/navigation'
  6. import { dialog } from '@/utils/vant'
  7. import { useLogin } from '@/business/login'
  8. import eventBus from '@/services/bus'
  9. const { userLogout } = useLogin()
  10. const { backHomePage } = useNavigation()
  11. const quit = (showLogin = false) => {
  12. backHomePage({ tabName: 'home', showLogin })
  13. }
  14. // 接收用户登出通知
  15. eventBus.$on('LogoutNotify', (msg) => {
  16. userLogout(() => {
  17. if (msg) {
  18. dialog({
  19. message: msg as string,
  20. }).then(() => {
  21. quit(true)
  22. })
  23. } else {
  24. quit()
  25. }
  26. })
  27. })
  28. </script>