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 服务器
|
||||
*/
|
||||
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) {
|
||||
console.log(prefix.value + "SignalR 已连接或正在连接");
|
||||
return true;
|
||||
@@ -297,8 +301,9 @@ export const useWebFetcher = defineStore('WebFetcher', () => {
|
||||
signalRClient.value = undefined;
|
||||
// state.value = 'disconnected'; // 保持 connecting 或由 Start 控制
|
||||
return false;
|
||||
} finally {
|
||||
isConnectingSignalR = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
async function sendSelfInfo(client: signalR.HubConnection) {
|
||||
return client.invoke('SetSelfInfo',
|
||||
|
||||
Reference in New Issue
Block a user