style: 更新主题2.2

This commit is contained in:
chenchun
2025-08-05 18:23:33 +08:00
parent f47d8c8ce3
commit 63e7d3d5f5
3 changed files with 75 additions and 41 deletions

View File

@@ -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;
}
}