husq
2023-09-27 2c2bc8614c8ea0ce386369eb4924da1e6aa052d1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<template>
  <a-config-provider :locale="zhCN">
 
    <a-layout class="width-100 flex-display" style="height: 100vh">
      <a-layout-header class="header" v-show="$route.meta.header!=false">
        <Topbar/>
      </a-layout-header>
      <a-layout-content>
        <router-view/>
      </a-layout-content>
 
    </a-layout>
  </a-config-provider>
 
</template>
 
<script lang="ts" setup>
import zhCN from 'ant-design-vue/es/locale/zh_CN'
import Topbar from '/@/components/common/topbar.vue'
import { onMounted, reactive, ref, UnwrapRef, watch } from 'vue'
import { getRoot } from '/@/root'
import { useRoute } from 'vue-router'
import { EBizCode, ELocalStorageKey, ERouterName } from '/@/types'
import { useConnectWebSocket } from '/@/hooks/use-connect-websocket'
import EventBus from '/@/event-bus'
 
interface FormState {
  user: string
  password: string
}
 
const route = useRoute()
const root = getRoot()
 
const messageHandler = async (payload: any) => {
  if (!payload) {
    return
  }
  switch (payload.biz_code) {
    case EBizCode.DeviceUpgrade: {
      EventBus.emit('deviceUpgrade', payload)
      break
    }
    case EBizCode.DeviceLogUploadProgress: {
      EventBus.emit('deviceLogUploadProgress', payload)
      break
    }
  }
}
// 监听ws 消息
useConnectWebSocket(messageHandler)
 
// onMounted(() => {
//   const token = localStorage.getItem(ELocalStorageKey.Token)
//   if (!token) {
//     root.$router.push(ERouterName.LOGIN)
//   }
// })
 
</script>
 
<style lang="scss" scoped>
@import '/@/styles/index.scss';
 
.fontBold {
  font-weight: 500;
  font-size: 18px;
}
 
.header {
  background-color: black;
  color: white;
  height: 60px;
  font-size: 15px;
  padding: 0 20px;
}
</style>