This commit is contained in:
zk
2024-09-23 16:43:57 +08:00
parent ca4a9a8c28
commit 278e91c262
26 changed files with 376 additions and 45 deletions
+12 -2
View File
@@ -19,7 +19,12 @@ export const xianYunPath = VITE_GLOB_API_XIAN_YUN;
export const yinChuanPath = VITE_GLOB_API_YIN_CHUAN;
let t = token || getAuthCache(TOKEN_KEY);
export function useSocket(p = basicPath) {
/**
*
* @param p websocket地址
* @param hasTimestamp 是否需要时间戳
*/
export function useSocket(p = basicPath, hasTimestamp: boolean = true) {
const socket = ref();
let socketData = ref({});
let lockReconnect = ref(false); //避免ws重复连接
@@ -75,7 +80,12 @@ export function useSocket(p = basicPath) {
} else {
closeSocket();
// 实例化socket
socket.value = new WebSocket(path.value + Date.now(), [t]);
//判断是否需要时间戳
if (hasTimestamp) {
socket.value = new WebSocket(path.value + Date.now(), [t]);
} else {
socket.value = new WebSocket(path.value, [t]);
}
socket.value.onclose = function () {
reconnect(path.value);
+15
View File
@@ -53,3 +53,18 @@ export function visibleChartLabel(chartData) {
}
return data;
}
export function emptyChart() {
return {
title: {
text: '暂无数据',
x: 'center',
y: 'center',
textStyle: {
color: '#fff',
fontWeight: 'normal',
fontSize: 14,
},
},
};
}