App.vue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <template>
  2. <router-view />
  3. </template>
  4. <script lang="ts" setup>
  5. import { useNavigation } from '@mobile/router/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 { backHome } = useNavigation()
  11. // 接收用户登出通知
  12. eventBus.$on('LogoutNotify', (msg) => {
  13. // ---待优化---
  14. // 登出后应该回退到首页,如果回退后非首页,会导致路由拦截而跳转到登录页面,此时因为 tabIndex = 0 的问题,登录页被 replace 成首页,导致路由还能继续后退
  15. // 临时解决方案是先退回首页后再进行登出操作
  16. backHome()
  17. setTimeout(() => {
  18. userLogout()
  19. if (msg) {
  20. dialog({
  21. message: msg as string,
  22. confirmButtonText: '确定'
  23. })
  24. }
  25. }, 0)
  26. })
  27. // 接收风控通知
  28. eventBus.$on('RiskToWebNtf', (msg) => {
  29. const notify = msg as { title: string, content: string }
  30. dialog({
  31. title: notify.title,
  32. message: notify.content,
  33. confirmButtonText: '确定'
  34. })
  35. })
  36. </script>