<template>
  <vab-app />
</template>

<script>
  import { webSocketService } from '@/utils/websocket'
  import { useAclStore } from '@/store/modules/acl'
  import { baseURL } from '@/config'
  import { v4 as uuidv4 } from 'uuid' // 引入uuid库生成UUID
  export default {
    name: 'App',
    created() {
      //获取当前登录用户
      const aclStore = useAclStore()
    //const userId = aclStore.getUserAccount
    const urlList = baseURL.split(':')
    // 生成5位UUID随机数并拼接
    const fullUUID = uuidv4().replace(/-/g, '') // 生成UUID并去除连字符
    const shortUUID = fullUUID.substring(0, 12)  // 截取前5位
    const auth = `${shortUUID}`

    sessionStorage.setItem('auth', auth);
    try {
      console.log("urlList",urlList)

       webSocketService.connect(`ws:${  urlList[1]  }:16750/api/webSocketServer/${  auth}`)
       console.log("auth-app",auth)
    } catch (error) {
      console.error('Failed to parse user message:', error)
    }
  },
  beforeUnmount() {
    console.log("app 卸载")
    webSocketService.disconnect()
  },
}
</script>
