update
This commit is contained in:
+12
-2
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user