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
Unverified
Commit
951ce1cf
authored
Jan 23, 2025
by
芋道源码
Committed by
Gitee
Jan 23, 2025
Browse files
Options
Browse Files
Download
Plain Diff
!675 fix: mall kefu
Merge pull request !675 from puhui999/devlop
parents
fef86bcc
c50f59d1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
33 deletions
+39
-33
src/views/mall/promotion/kefu/components/KeFuMessageList.vue
+2
-1
src/views/mall/promotion/kefu/index.vue
+37
-32
No files found.
src/views/mall/promotion/kefu/components/KeFuMessageList.vue
View file @
951ce1cf
...
...
@@ -279,8 +279,9 @@ const handleSendMessage = async (event: any) => {
return
}
// 1. 校验消息是否为空
if
(
isEmpty
(
unref
(
message
.
value
)))
{
if
(
isEmpty
(
unref
(
message
.
value
)
?.
trim
()
))
{
messageTool
.
notifyWarning
(
'请输入消息后再发送哦!'
)
message
.
value
=
''
return
}
// 2. 组织发送消息
...
...
src/views/mall/promotion/kefu/index.vue
View file @
951ce1cf
...
...
@@ -37,40 +37,45 @@ const { data, close, open } = useWebSocket(server.value, {
})
/** 监听 WebSocket 数据 */
watchEffect
(()
=>
{
if
(
!
data
.
value
)
{
return
}
try
{
// 1. 收到心跳
if
(
data
.
value
===
'pong'
)
{
return
}
// 2.1 解析 type 消息类型
const
jsonMessage
=
JSON
.
parse
(
data
.
value
)
const
type
=
jsonMessage
.
type
if
(
!
type
)
{
message
.
error
(
'未知的消息类型:'
+
data
.
value
)
return
}
// 2.2 消息类型:KEFU_MESSAGE_TYPE
if
(
type
===
WebSocketMessageTypeConstants
.
KEFU_MESSAGE_TYPE
)
{
const
message
=
JSON
.
parse
(
jsonMessage
.
content
)
// 刷新会话列表
kefuStore
.
updateConversation
(
message
.
conversationId
)
// 刷新消息列表
keFuChatBoxRef
.
value
?.
refreshMessageList
(
message
)
return
}
// 2.3 消息类型:KEFU_MESSAGE_ADMIN_READ
if
(
type
===
WebSocketMessageTypeConstants
.
KEFU_MESSAGE_ADMIN_READ
)
{
// 更新会话已读
kefuStore
.
updateConversationStatus
(
jsonParse
(
jsonMessage
.
content
))
watch
(
()
=>
data
.
value
,
(
newData
)
=>
{
if
(
!
newData
)
return
try
{
// 1. 收到心跳
if
(
newData
===
'pong'
)
return
// 2.1 解析 type 消息类型
const
jsonMessage
=
JSON
.
parse
(
newData
)
const
type
=
jsonMessage
.
type
if
(
!
type
)
{
message
.
error
(
'未知的消息类型:'
+
newData
)
return
}
// 2.2 消息类型:KEFU_MESSAGE_TYPE
if
(
type
===
WebSocketMessageTypeConstants
.
KEFU_MESSAGE_TYPE
)
{
const
message
=
JSON
.
parse
(
jsonMessage
.
content
)
// 刷新会话列表
kefuStore
.
updateConversation
(
message
.
conversationId
)
// 刷新消息列表
keFuChatBoxRef
.
value
?.
refreshMessageList
(
message
)
return
}
// 2.3 消息类型:KEFU_MESSAGE_ADMIN_READ
if
(
type
===
WebSocketMessageTypeConstants
.
KEFU_MESSAGE_ADMIN_READ
)
{
// 更新会话已读
kefuStore
.
updateConversationStatus
(
jsonParse
(
jsonMessage
.
content
))
}
}
catch
(
error
)
{
console
.
error
(
error
)
}
}
catch
(
error
)
{
console
.
error
(
error
)
},
{
immediate
:
false
// 不立即执行
}
}
)
)
// ======================= 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