App.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <template>
  2. <router-view />
  3. </template>
  4. <script lang="ts" setup>
  5. import { useNavigation } from '@mobile/router/navigation'
  6. import { dialog, notify } 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, type) => {
  29. const res = msg as { title: string, content: string }
  30. if (type === 1) {
  31. notify(res.content, 'warning')
  32. } else {
  33. dialog({
  34. title: res.title,
  35. message: res.content,
  36. confirmButtonText: '确定'
  37. })
  38. }
  39. })
  40. </script>