update 优化代码格式

This commit is contained in:
疯狂的狮子Li 2024-11-08 00:33:23 +08:00
parent b19c2805e1
commit 4310e5e049
2 changed files with 5 additions and 5 deletions

View File

@ -8,7 +8,7 @@ export const initSSE = (url: any) => {
return; return;
} }
url = url + '?Authorization=Bearer ' + getToken() + '&clientid=' + import.meta.env.VITE_APP_CLIENT_ID url = url + '?Authorization=Bearer ' + getToken() + '&clientid=' + import.meta.env.VITE_APP_CLIENT_ID;
const { const {
data, data,
error error

View File

@ -7,7 +7,7 @@ export const initWebSocket = (url: any) => {
if (import.meta.env.VITE_APP_WEBSOCKET === 'false') { if (import.meta.env.VITE_APP_WEBSOCKET === 'false') {
return; return;
} }
url = url + '?Authorization=Bearer ' + getToken() + '&clientid=' + import.meta.env.VITE_APP_CLIENT_ID url = url + '?Authorization=Bearer ' + getToken() + '&clientid=' + import.meta.env.VITE_APP_CLIENT_ID;
useWebSocket(url, { useWebSocket(url, {
autoReconnect: { autoReconnect: {
// 重连最大次数 // 重连最大次数
@ -16,14 +16,14 @@ export const initWebSocket = (url: any) => {
delay: 1000, delay: 1000,
onFailed() { onFailed() {
console.log('websocket重连失败'); console.log('websocket重连失败');
}, }
}, },
heartbeat: { heartbeat: {
message: JSON.stringify({type: 'ping'}), message: JSON.stringify({ type: 'ping' }),
// 发送心跳的间隔 // 发送心跳的间隔
interval: 10000, interval: 10000,
// 接收到心跳response的超时时间 // 接收到心跳response的超时时间
pongTimeout: 2000, pongTimeout: 2000
}, },
onConnected() { onConnected() {
console.log('websocket已经连接'); console.log('websocket已经连接');