2025-07-18 16:38:18 +08:00
|
|
|
<template>
|
|
|
|
|
<vab-app />
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2025-07-23 11:39:35 +08:00
|
|
|
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()
|
2025-07-18 16:38:18 +08:00
|
|
|
//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)
|
2025-07-23 11:39:35 +08:00
|
|
|
|
|
|
|
|
webSocketService.connect(`ws:${ urlList[1] }:16750/api/webSocketServer/${ auth}`)
|
2025-07-18 16:38:18 +08:00
|
|
|
console.log("auth-app",auth)
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Failed to parse user message:', error)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
beforeUnmount() {
|
|
|
|
|
console.log("app 卸载")
|
|
|
|
|
webSocketService.disconnect()
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
</script>
|