style: 更新主题2.2
This commit is contained in:
@@ -4,41 +4,41 @@ import useAuths from "@/hooks/useAuths";
|
||||
|
||||
const { getToken } = useAuths();
|
||||
export default {
|
||||
SR: {},
|
||||
start(url,callFunc) {
|
||||
const connection = new signalR.HubConnectionBuilder()
|
||||
.withUrl(`${import.meta.env.VITE_APP_BASE_WS}/` + url, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${getToken()}`,
|
||||
},
|
||||
accessTokenFactory: () => {
|
||||
// 返回授权 token
|
||||
return `${getToken()}`;
|
||||
},
|
||||
})
|
||||
SR: {},
|
||||
start(url, callFunc) {
|
||||
const connection = new signalR.HubConnectionBuilder()
|
||||
.withUrl(`${import.meta.env.VITE_APP_BASE_WS}/` + url, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${getToken()}`,
|
||||
},
|
||||
accessTokenFactory: () => {
|
||||
// 返回授权 token
|
||||
return `${getToken()}`;
|
||||
},
|
||||
})
|
||||
|
||||
.withAutomaticReconnect(new ForeverRetryPolicy()) //自动重新连接
|
||||
.configureLogging(signalR.LogLevel.Error)
|
||||
.build();
|
||||
this.SR = connection;
|
||||
// 断线重连
|
||||
connection.onclose(() => {
|
||||
console.log("hub断开");
|
||||
});
|
||||
.withAutomaticReconnect(new ForeverRetryPolicy()) //自动重新连接
|
||||
.configureLogging(signalR.LogLevel.Error)
|
||||
.build();
|
||||
this.SR = connection;
|
||||
// 断线重连
|
||||
connection.onclose(() => {
|
||||
console.log("hub断开");
|
||||
});
|
||||
|
||||
connection.onreconnected(() => {
|
||||
console.log("hub重新连接成功");
|
||||
});
|
||||
callFunc(connection);
|
||||
// 启动
|
||||
connection.onreconnected(() => {
|
||||
console.log("hub重新连接成功");
|
||||
});
|
||||
callFunc(connection);
|
||||
// 启动
|
||||
|
||||
this.SR.start();
|
||||
},
|
||||
this.SR.start();
|
||||
},
|
||||
|
||||
};
|
||||
class ForeverRetryPolicy {
|
||||
nextRetryDelayInMilliseconds(retryContext) {
|
||||
return 1000*3;
|
||||
}
|
||||
|
||||
nextRetryDelayInMilliseconds(retryContext) {
|
||||
return 1000 * 60;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user