App.vue 787 B

123456789101112131415161718192021222324252627282930313233343536
  1. <template>
  2. <!-- 一级路由 -->
  3. <router-view />
  4. </template>
  5. <!--<script lang="ts">
  6. export default {
  7. name: 'App',
  8. }
  9. </script>-->
  10. <script lang="ts" setup>
  11. import { useRouter } from 'vue-router'
  12. import { ElMessageBox } from 'element-plus'
  13. import { useLogin } from '@/business/login'
  14. import eventBus from '@/services/bus'
  15. const { userLogout } = useLogin()
  16. const router = useRouter()
  17. // 接收用户登出通知
  18. eventBus.$on('LogoutNotify', (msg) => {
  19. userLogout(() => {
  20. if (msg) {
  21. ElMessageBox.alert(msg as string, '下线通知')
  22. }
  23. router.replace({ name: 'login' })
  24. })
  25. })
  26. // 接收风控通知
  27. eventBus.$on('RiskToWebNtf', (msg) => {
  28. const notify = msg as { title: string, content: string }
  29. ElMessageBox.alert(notify.content, notify.title)
  30. })
  31. </script>