diff --git a/Yi.Bbs.Vue3/src/App.vue b/Yi.Bbs.Vue3/src/App.vue index 6018d44c..a894ce1a 100644 --- a/Yi.Bbs.Vue3/src/App.vue +++ b/Yi.Bbs.Vue3/src/App.vue @@ -28,7 +28,7 @@ onMounted(async () => { //如果登录了,再连接消息通知 bbsNoticeSignalR(); - noticeSignalR(); + noticeSignalR(); }); diff --git a/Yi.Bbs.Vue3/src/utils/signalR.js b/Yi.Bbs.Vue3/src/utils/signalR.js index 3c7eb6a3..808a182f 100644 --- a/Yi.Bbs.Vue3/src/utils/signalR.js +++ b/Yi.Bbs.Vue3/src/utils/signalR.js @@ -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; + } + } \ No newline at end of file diff --git a/Yi.Bbs.Vue3/src/views/home/Index.vue b/Yi.Bbs.Vue3/src/views/home/Index.vue index 9e2c34b0..77bf8245 100644 --- a/Yi.Bbs.Vue3/src/views/home/Index.vue +++ b/Yi.Bbs.Vue3/src/views/home/Index.vue @@ -43,7 +43,7 @@ margin: 10px auto;"> :isPublish="i.isDisableCreateDiscuss"/> -
+
@@ -106,7 +106,7 @@ margin: 10px auto;">
- + - +