App.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <template>
  2. <loading v-if="show" />
  3. <n-config-provider
  4. preflight-style-disabled
  5. inline-theme-disabled
  6. :theme-overrides="themeOverrides"
  7. :locale="zhCN"
  8. :date-locale="dateZhCN"
  9. >
  10. <n-notification-provider>
  11. <router-view />
  12. <global-notif />
  13. </n-notification-provider>
  14. </n-config-provider>
  15. </template>
  16. <script setup lang='ts'>
  17. import {
  18. computed, onMounted, provide, watch
  19. } from 'vue'
  20. import { zhCN, dateZhCN } from 'naive-ui'
  21. import { useRouter } from 'vue-router'
  22. import Theme from '@/assets/naive-theme'
  23. import loading from '@/components/loading.vue'
  24. import MqttService from '@/services/mqtt.service'
  25. import GlobalNotif from '@/components/notifaiction.vue'
  26. import useStore from '@/store/index'
  27. import LogiService from '@/services/logi.service'
  28. const mqtt = new MqttService()
  29. const logi = new LogiService()
  30. const store = useStore()
  31. const router = useRouter()
  32. const themeOverrides = Theme
  33. const show = computed(() => store.loading)
  34. watch(() => store.mqtt_message, (val) => {
  35. if (val.type === 'MqttConnect') {
  36. store.setLoading(true)
  37. router.push('/room')
  38. }
  39. if (val.type === 'WebRtcConnected') {
  40. store.setLoading(false)
  41. store.setRtcConnected(true)
  42. }
  43. // mqtt ERROR
  44. if (store.errorDic[val.type]) {
  45. store.setLoading(false)
  46. store.setRtcConnected(false)
  47. mqtt.disconnect()
  48. router.push('/')
  49. }
  50. })
  51. onMounted(() => logi.init())
  52. provide('MQTT', mqtt)
  53. </script>
  54. <style lang='scss'>
  55. * {
  56. box-sizing: border-box;
  57. user-select: none;
  58. -webkit-user-select: none;
  59. }
  60. video,
  61. #app,
  62. html,
  63. body {
  64. margin: 0;
  65. padding: 0;
  66. width: 100%;
  67. height: 100%;
  68. min-width: 1200px;
  69. min-height: 760px;
  70. overflow: hidden;
  71. border-radius: 8px;
  72. background: transparent;
  73. position: relative;
  74. border: none;
  75. &>div {
  76. width: 100%;
  77. height: 100%;
  78. }
  79. }
  80. </style>