fix: 命名优化

This commit is contained in:
Cherry 2023-03-16 20:58:44 +08:00
parent 7e541c415e
commit ce562f59f8

View File

@ -2,7 +2,7 @@
* @Author: Cherry 2858937488@qq.com * @Author: Cherry 2858937488@qq.com
* @Date: 2023-03-14 10:40:55 * @Date: 2023-03-14 10:40:55
* @LastEditors: Cherry 2858937488@qq.com * @LastEditors: Cherry 2858937488@qq.com
* @LastEditTime: 2023-03-16 13:47:40 * @LastEditTime: 2023-03-16 20:57:15
* @FilePath: \vue3-admin\vue3-element-admin\src\views\mydemo\WebSocketDemo.vue * @FilePath: \vue3-admin\vue3-element-admin\src\views\mydemo\WebSocketDemo.vue
* @Description: websocket * @Description: websocket
--> -->
@ -112,6 +112,7 @@ const startConnection = () => {
}; };
const disconnected = () => { const disconnected = () => {
disabled.value = false;
isConnected.value = false; isConnected.value = false;
destroySocket(); destroySocket();
}; };
@ -137,11 +138,11 @@ const sendMsg = () => {
const createSocket = () => { const createSocket = () => {
console.log('创建长连接', !socket.value); console.log('创建长连接', !socket.value);
const usewebSocketStore = webSocketStore(); const useWebSocketStore = webSocketStore();
const useUserStore = userStore(); const useUserStore = userStore();
const id = usewebSocketStore.getSocketID() || `${useUserStore.userId}-${new Date().getTime() / 1000}`; const id = useWebSocketStore.getSocketID() || `${useUserStore.userId}-${new Date().getTime() / 1000}`;
if (!usewebSocketStore.getSocketID()) { if (!useWebSocketStore.getSocketID()) {
usewebSocketStore.setSocketID(id); useWebSocketStore.setSocketID(id);
} }
socket.value = new Socket({ socket.value = new Socket({
url: linkUrl.value + '/' + id, url: linkUrl.value + '/' + id,