File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
src/views/mall/promotion/kefu Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import { KeFuConversationRespVO } from '@/api/mall/promotion/kefu/conversation'
16
16
import { getRefreshToken } from ' @/utils/auth'
17
17
import { useWebSocket } from ' @vueuse/core'
18
18
import { useMallKefuStore } from ' @/store/modules/mall/kefu'
19
+ import { jsonParse } from ' @/utils'
19
20
20
21
defineOptions ({ name: ' KeFu' })
21
22
@@ -30,6 +31,7 @@ const server = ref(
30
31
) // WebSocket 服务地址
31
32
32
33
/** 发起 WebSocket 连接 */
34
+ // TODO puhui999: websocket 连接有点问题收不到消息 🤣
33
35
const { data, close, open } = useWebSocket (server .value , {
34
36
autoReconnect: true ,
35
37
heartbeat: true
@@ -45,9 +47,9 @@ watchEffect(() => {
45
47
if (data .value === ' pong' ) {
46
48
return
47
49
}
48
-
49
50
// 2.1 解析 type 消息类型
50
51
const jsonMessage = JSON .parse (data .value )
52
+ console .log (jsonMessage )
51
53
const type = jsonMessage .type
52
54
if (! type ) {
53
55
message .error (' 未知的消息类型:' + data .value )
@@ -65,7 +67,7 @@ watchEffect(() => {
65
67
// 2.3 消息类型:KEFU_MESSAGE_ADMIN_READ
66
68
if (type === WebSocketMessageTypeConstants .KEFU_MESSAGE_ADMIN_READ ) {
67
69
// 更新会话已读
68
- kefuStore .updateConversationStatus (JSON . parse (jsonMessage .content ))
70
+ kefuStore .updateConversationStatus (jsonParse (jsonMessage .content ))
69
71
}
70
72
} catch (error ) {
71
73
console .error (error )
You can’t perform that action at this time.
0 commit comments