Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
39106843
authored
Jan 22, 2025
by
puhui999
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【缺陷修复】mall: 修复客服中心页面接收到消息时,重复调用了多次获取会话接口的问题
parent
fef86bcc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
32 deletions
+37
-32
src/views/mall/promotion/kefu/index.vue
+37
-32
No files found.
src/views/mall/promotion/kefu/index.vue
View file @
39106843
...
@@ -37,40 +37,45 @@ const { data, close, open } = useWebSocket(server.value, {
...
@@ -37,40 +37,45 @@ const { data, close, open } = useWebSocket(server.value, {
})
})
/** 监听 WebSocket 数据 */
/** 监听 WebSocket 数据 */
watchEffect
(()
=>
{
watch
(
if
(
!
data
.
value
)
{
()
=>
data
.
value
,
return
(
newData
)
=>
{
}
if
(
!
newData
)
return
try
{
try
{
// 1. 收到心跳
// 1. 收到心跳
if
(
data
.
value
===
'pong'
)
{
if
(
newData
===
'pong'
)
return
return
}
// 2.1 解析 type 消息类型
// 2.1 解析 type 消息类型
const
jsonMessage
=
JSON
.
parse
(
newData
)
const
jsonMessage
=
JSON
.
parse
(
data
.
value
)
const
type
=
jsonMessage
.
type
const
type
=
jsonMessage
.
type
if
(
!
type
)
{
if
(
!
type
)
{
message
.
error
(
'未知的消息类型:'
+
newData
)
message
.
error
(
'未知的消息类型:'
+
data
.
value
)
return
return
}
}
// 2.2 消息类型:KEFU_MESSAGE_TYPE
// 2.2 消息类型:KEFU_MESSAGE_TYPE
if
(
type
===
WebSocketMessageTypeConstants
.
KEFU_MESSAGE_TYPE
)
{
if
(
type
===
WebSocketMessageTypeConstants
.
KEFU_MESSAGE_TYPE
)
{
const
message
=
JSON
.
parse
(
jsonMessage
.
content
)
const
message
=
JSON
.
parse
(
jsonMessage
.
content
)
// 刷新会话列表
// 刷新会话列表
kefuStore
.
updateConversation
(
message
.
conversationId
)
kefuStore
.
updateConversation
(
message
.
conversationId
)
// 刷新消息列表
// 刷新消息列表
keFuChatBoxRef
.
value
?.
refreshMessageList
(
message
)
keFuChatBoxRef
.
value
?.
refreshMessageList
(
message
)
return
return
}
}
// 2.3 消息类型:KEFU_MESSAGE_ADMIN_READ
if
(
type
===
WebSocketMessageTypeConstants
.
KEFU_MESSAGE_ADMIN_READ
)
{
// 2.3 消息类型:KEFU_MESSAGE_ADMIN_READ
// 更新会话已读
if
(
type
===
WebSocketMessageTypeConstants
.
KEFU_MESSAGE_ADMIN_READ
)
{
kefuStore
.
updateConversationStatus
(
jsonParse
(
jsonMessage
.
content
))
// 更新会话已读
kefuStore
.
updateConversationStatus
(
jsonParse
(
jsonMessage
.
content
))
}
}
catch
(
error
)
{
console
.
error
(
error
)
}
}
}
catch
(
error
)
{
},
console
.
error
(
error
)
{
immediate
:
false
// 不立即执行
}
}
}
)
)
// ======================= WebSocket end =======================
// ======================= WebSocket end =======================
/** 加载指定会话的消息列表 */
/** 加载指定会话的消息列表 */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment