App.vue 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <template>
  2. <n-config-provider
  3. preflight-style-disabled
  4. inline-theme-disabled
  5. :theme-overrides="themeOverrides"
  6. :locale="zhCN"
  7. :date-locale="dateZhCN"
  8. >
  9. <n-notification-provider>
  10. <router-view />
  11. </n-notification-provider>
  12. </n-config-provider>
  13. </template>
  14. <script setup lang='ts'>
  15. import { provide, watch } from 'vue'
  16. import { zhCN, dateZhCN } from 'naive-ui'
  17. import { useRouter } from 'vue-router'
  18. import useStore from './store/index'
  19. import Theme from '@/assets/naive-theme'
  20. import MqttService from '@/services/mqtt.service'
  21. const mqtt = new MqttService()
  22. const store = useStore()
  23. const router = useRouter()
  24. const themeOverrides = Theme
  25. watch(() => store.mqtt_message, (val) => {
  26. console.log('顶级监听', val)
  27. if (val.type === 'connect') {
  28. router.push('/room')
  29. }
  30. // mqtt断开连接
  31. if (val.type === 'disconnect' || val.type === 'leave') {
  32. router.push('/')
  33. mqtt.disconnect()
  34. }
  35. })
  36. provide('MQTT', mqtt)
  37. </script>
  38. <style lang='scss'>
  39. * {
  40. box-sizing: border-box;
  41. user-select: none;
  42. -webkit-user-select: none;
  43. }
  44. video,
  45. #app,
  46. html,
  47. body {
  48. margin: 0;
  49. padding: 0;
  50. width: 100%;
  51. height: 100%;
  52. min-width: 1300px;
  53. min-height: 760px;
  54. overflow: hidden;
  55. border-radius: 10px;
  56. background: transparent;
  57. position: relative;
  58. border: none;
  59. &>div {
  60. width: 100%;
  61. height: 100%;
  62. }
  63. }
  64. </style>