【功能完善】商城: 客服 WebSocket 消息统一 json 化
This commit is contained in:
parent
824b0328f1
commit
c79c85543e
@ -118,7 +118,7 @@ export function toAnyString() {
|
||||
|
||||
/**
|
||||
* 根据支持的文件类型生成 accept 属性值
|
||||
*
|
||||
*
|
||||
* @param supportedFileTypes 支持的文件类型数组,如 ['PDF', 'DOC', 'DOCX']
|
||||
* @returns 用于文件上传组件 accept 属性的字符串
|
||||
*/
|
||||
@ -503,8 +503,8 @@ export function jsonParse(str: string) {
|
||||
try {
|
||||
return JSON.parse(str)
|
||||
} catch (e) {
|
||||
console.error(`str[${str}] 不是一个 JSON 字符串`)
|
||||
return ''
|
||||
console.warn(`str[${str}] 不是一个 JSON 字符串`)
|
||||
return str
|
||||
}
|
||||
}
|
||||
|
||||
@ -516,7 +516,7 @@ export function jsonParse(str: string) {
|
||||
* @param end
|
||||
*/
|
||||
|
||||
export const sliceName = (name: string,start: number, end : number) => {
|
||||
export const sliceName = (name: string, start: number, end: number) => {
|
||||
if (name.length > end) {
|
||||
return name.slice(start, end)
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ import { KeFuConversationRespVO } from '@/api/mall/promotion/kefu/conversation'
|
||||
import { getRefreshToken } from '@/utils/auth'
|
||||
import { useWebSocket } from '@vueuse/core'
|
||||
import { useMallKefuStore } from '@/store/modules/mall/kefu'
|
||||
import { jsonParse } from '@/utils'
|
||||
|
||||
defineOptions({ name: 'KeFu' })
|
||||
|
||||
@ -66,7 +65,8 @@ watch(
|
||||
// 2.3 消息类型:KEFU_MESSAGE_ADMIN_READ
|
||||
if (type === WebSocketMessageTypeConstants.KEFU_MESSAGE_ADMIN_READ) {
|
||||
// 更新会话已读
|
||||
kefuStore.updateConversationStatus(jsonParse(jsonMessage.content))
|
||||
const message = JSON.parse(jsonMessage.content)
|
||||
kefuStore.updateConversationStatus(message.conversationId)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
|
Loading…
Reference in New Issue
Block a user