mirror of
https://github.com/Megghy/vtsuru.live.git
synced 2025-12-06 18:36:55 +08:00
fix: 修复hub连接
This commit is contained in:
@@ -208,11 +208,15 @@ export const useWebFetcher = defineStore('WebFetcher', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let isConnectingSignalR = false;
|
||||||
/**
|
/**
|
||||||
* 连接 SignalR 服务器
|
* 连接 SignalR 服务器
|
||||||
*/
|
*/
|
||||||
async function connectSignalR(): Promise<boolean> {
|
async function connectSignalR(): Promise<boolean> {
|
||||||
return await navigator.locks.request('webFetcherStartLock', async () => {
|
if (isConnectingSignalR) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
isConnectingSignalR = true;
|
||||||
if (signalRClient.value && signalRClient.value.state !== signalR.HubConnectionState.Disconnected) {
|
if (signalRClient.value && signalRClient.value.state !== signalR.HubConnectionState.Disconnected) {
|
||||||
console.log(prefix.value + "SignalR 已连接或正在连接");
|
console.log(prefix.value + "SignalR 已连接或正在连接");
|
||||||
return true;
|
return true;
|
||||||
@@ -297,8 +301,9 @@ export const useWebFetcher = defineStore('WebFetcher', () => {
|
|||||||
signalRClient.value = undefined;
|
signalRClient.value = undefined;
|
||||||
// state.value = 'disconnected'; // 保持 connecting 或由 Start 控制
|
// state.value = 'disconnected'; // 保持 connecting 或由 Start 控制
|
||||||
return false;
|
return false;
|
||||||
|
} finally {
|
||||||
|
isConnectingSignalR = false;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
async function sendSelfInfo(client: signalR.HubConnection) {
|
async function sendSelfInfo(client: signalR.HubConnection) {
|
||||||
return client.invoke('SetSelfInfo',
|
return client.invoke('SetSelfInfo',
|
||||||
|
|||||||
Reference in New Issue
Block a user