yangjie #33

Merged
yangqiang merged 22 commits from yangjie into master 2024-11-04 13:57:51 +08:00
1 changed files with 8 additions and 2 deletions
Showing only changes of commit 380222bcfd - Show all commits

10
main.js
View File

@ -720,7 +720,6 @@ const startSignalr = async (user) => {
}) })
.withAutomaticReconnect([0, 3000, 3000, 3000]) .withAutomaticReconnect([0, 3000, 3000, 3000])
.build(); .build();
connection.start();
mainWindow.webContents.send('changeLocalStorage', { mainWindow.webContents.send('changeLocalStorage', {
isSignalr: true, isSignalr: true,
reconnect: true, reconnect: true,
@ -736,12 +735,19 @@ const startSignalr = async (user) => {
reconnect: false, reconnect: false,
}); });
}); });
connection.start();
} }
const onStart = async () => { const onStart = async () => {
if (connection) { if (connection) {
if (connection.state === signalR.HubConnectionState.Disconnected) { if (connection.state === signalR.HubConnectionState.Disconnected) {
connection.start(); connection.start().then(() => {
mainWindow.webContents.send('changeLocalStorage', {
reconnect: true,
});
}).catch((err) => {
});
} }
if (connection.state !== signalR.HubConnectionState.Connected) { if (connection.state !== signalR.HubConnectionState.Connected) {
setTimeout(onStart, 3000); setTimeout(onStart, 3000);