<!--
 * @Author: hisense.wuhongjian
 * @Date: 2022-05-06 11:12:00
 * @LastEditors: hisense.liangjunhua
 * @LastEditTime: 2022-07-21 16:00:17
 * @Description: 告诉大家这是什么
-->
<template>
  <div id="vue-admin-beautiful">
    <a-config-provider :locale="locale">
      <router-view />
    </a-config-provider>
  </div>
</template>
<script setup>
  import zhCN from 'ant-design-vue/es/locale/zh_CN'
  import Cookies from 'js-cookie'
  import { onBeforeUnmount } from 'vue'
  import mybus from '@/myplugins/mybus'

  // export default {
  //   name: 'App',
  //   data() {
  //     return {
  //       ,
  //     }
  //   },
  // }
  const locale = zhCN
  const token = Cookies.get('ucsToken')
  console.log('token=================>', token)
  var ws = new WebSocket(
    `ws://${window.SITE_CONFIG['websocketURL']}/websocket?token=${token}`
  )
  // ws.send()给服务器发送信息
  // 服务器每次返回信息都会执行一次onmessage方法
  ws.onmessage = function (e) {
    console.log('服务器返回的信息: ' + e.data)
    mybus.emit('getMynotice')
  }
  onBeforeUnmount(() => {
    // 4.卸载前, 关闭链接
    ws.close()
  })
</script>
<style lang="less">
  @import '~@/vab/styles/vab.less';
  #vue-admin-beautiful {
    max-width: 1920px;
    // max-height: 1080px;
    margin: auto;
    height: 100%;
    position: relative;
    background-color: #fff;
  }
</style>
