From 7ebf23ddd8a0d5536167313c4cf37af1552a5057 Mon Sep 17 00:00:00 2001 From: nanxun Date: Thu, 29 Jan 2026 23:43:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=89=8D=E7=AB=AF=EF=BC=9A=E4=BF=AE=E5=A4=8Dws?= =?UTF-8?q?s=E8=BF=9E=E6=8E=A5=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/web/.env | 2 +- frontend/web/src/stores/signalr.js | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/frontend/web/.env b/frontend/web/.env index 33374ce..c7dcb08 100644 --- a/frontend/web/.env +++ b/frontend/web/.env @@ -1,4 +1,4 @@ #VITE_API_BASE_URL = http://localhost:5202/api #VITE_SIGNALR_BASE_URL = http://localhost:5202/chat VITE_API_BASE_URL = https://im.test.nxsir.cn/api -VITE_SIGNALR_BASE_URL = https://im.test.nxsir.cn/chat \ No newline at end of file +VITE_SIGNALR_BASE_URL = https://im.test.nxsir.cn/chat/ \ No newline at end of file diff --git a/frontend/web/src/stores/signalr.js b/frontend/web/src/stores/signalr.js index a5a2288..8570905 100644 --- a/frontend/web/src/stores/signalr.js +++ b/frontend/web/src/stores/signalr.js @@ -18,9 +18,11 @@ export const useSignalRStore = defineStore('signalr', { async initSignalR() { const message = useMessage() const authStore = useAuthStore() - const url = import.meta.env.VITE_SIGNALR_BASE_URL || 'http://localhost:5202/chat'; + const url = import.meta.env.VITE_SIGNALR_BASE_URL || 'http://localhost:5202/chat/'; this.connection = new signalR.HubConnectionBuilder() - .withUrl(url, { + .withUrl(url, + { + accessTokenFactory: async () => { if (authStore.isTokenExpired) { const res = await authService.refresh(authStore.refreshToken) @@ -61,8 +63,8 @@ export const useSignalRStore = defineStore('signalr', { }, /** * 通过signalr发送消息 - * @param {*} msg - * @returns + * @param {*} msg + * @returns */ async sendMsg(msg) { const message = useMessage() @@ -97,4 +99,4 @@ export const useSignalRStore = defineStore('signalr', { await this.connection.invoke("ClearUnreadCount", conversationId) } } -}) \ No newline at end of file +})