File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change 71
71
<script lang="ts" setup>
72
72
import { formatDate } from ' @/utils/formatTime'
73
73
import { useWebSocket } from ' @vueuse/core'
74
- import { getAccessToken } from ' @/utils/auth'
74
+ import { getRefreshToken } from ' @/utils/auth'
75
75
import * as UserApi from ' @/api/system/user'
76
76
77
77
defineOptions ({ name: ' InfraWebSocket' })
78
78
79
79
const message = useMessage () // 消息弹窗
80
80
81
81
const server = ref (
82
- (import .meta .env .VITE_BASE_URL + ' /infra/ws' ).replace (' http' , ' ws' ) + ' ?token=' + getAccessToken ()
82
+ (import .meta .env .VITE_BASE_URL + ' /infra/ws' ).replace (' http' , ' ws' ) +
83
+ ' ?token=' +
84
+ getRefreshToken () // 使用 getRefreshToken() 方法,而不使用 getAccessToken() 方法的原因:WebSocket 无法方便的刷新访问令牌
83
85
) // WebSocket 服务地址
84
86
const getIsOpen = computed (() => status .value === ' OPEN' ) // WebSocket 连接是否打开
85
87
const getTagColor = computed (() => (getIsOpen .value ? ' success' : ' red' )) // WebSocket 连接的展示颜色
Original file line number Diff line number Diff line change 25
25
import { KeFuConversationList , KeFuMessageList , MemberBrowsingHistory } from ' ./components'
26
26
import { WebSocketMessageTypeConstants } from ' ./components/tools/constants'
27
27
import { KeFuConversationRespVO } from ' @/api/mall/promotion/kefu/conversation'
28
- import { getAccessToken } from ' @/utils/auth'
28
+ import { getRefreshToken } from ' @/utils/auth'
29
29
import { useWebSocket } from ' @vueuse/core'
30
30
31
31
defineOptions ({ name: ' KeFu' })
@@ -34,7 +34,9 @@ const message = useMessage() // 消息弹窗
34
34
35
35
// ======================= WebSocket start =======================
36
36
const server = ref (
37
- (import .meta .env .VITE_BASE_URL + ' /infra/ws' ).replace (' http' , ' ws' ) + ' ?token=' + getAccessToken ()
37
+ (import .meta .env .VITE_BASE_URL + ' /infra/ws' ).replace (' http' , ' ws' ) +
38
+ ' ?token=' +
39
+ getRefreshToken () // 使用 getRefreshToken() 方法,而不使用 getAccessToken() 方法的原因:WebSocket 无法方便的刷新访问令牌
38
40
) // WebSocket 服务地址
39
41
40
42
/** 发起 WebSocket 连接 */
You can’t perform that action at this time.
0 commit comments