main #56
@ -1,4 +1,4 @@
|
|||||||
#VITE_API_BASE_URL = http://localhost:5202/api
|
#VITE_API_BASE_URL = http://localhost:5202/api
|
||||||
#VITE_SIGNALR_BASE_URL = http://localhost:5202/chat
|
#VITE_SIGNALR_BASE_URL = http://localhost:5202/chat
|
||||||
VITE_API_BASE_URL = https://im.test.nxsir.cn/api
|
VITE_API_BASE_URL = https://im.test.nxsir.cn/api
|
||||||
VITE_SIGNALR_BASE_URL = https://im.test.nxsir.cn/chat
|
VITE_SIGNALR_BASE_URL = https://im.test.nxsir.cn/chat/
|
||||||
@ -18,9 +18,11 @@ export const useSignalRStore = defineStore('signalr', {
|
|||||||
async initSignalR() {
|
async initSignalR() {
|
||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
const authStore = useAuthStore()
|
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()
|
this.connection = new signalR.HubConnectionBuilder()
|
||||||
.withUrl(url, {
|
.withUrl(url,
|
||||||
|
{
|
||||||
|
|
||||||
accessTokenFactory: async () => {
|
accessTokenFactory: async () => {
|
||||||
if (authStore.isTokenExpired) {
|
if (authStore.isTokenExpired) {
|
||||||
const res = await authService.refresh(authStore.refreshToken)
|
const res = await authService.refresh(authStore.refreshToken)
|
||||||
@ -61,8 +63,8 @@ export const useSignalRStore = defineStore('signalr', {
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* 通过signalr发送消息
|
* 通过signalr发送消息
|
||||||
* @param {*} msg
|
* @param {*} msg
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
async sendMsg(msg) {
|
async sendMsg(msg) {
|
||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
@ -97,4 +99,4 @@ export const useSignalRStore = defineStore('signalr', {
|
|||||||
await this.connection.invoke("ClearUnreadCount", conversationId)
|
await this.connection.invoke("ClearUnreadCount", conversationId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user