From c79c85543e00d8b271e7e8ba8f714f2e2876c27b Mon Sep 17 00:00:00 2001 From: puhui999 Date: Tue, 1 Apr 2025 18:11:11 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=8A=9F=E8=83=BD=E5=AE=8C=E5=96=84?= =?UTF-8?q?=E3=80=91=E5=95=86=E5=9F=8E:=20=E5=AE=A2=E6=9C=8D=20WebSocket?= =?UTF-8?q?=20=E6=B6=88=E6=81=AF=E7=BB=9F=E4=B8=80=20json=20=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/index.ts | 8 ++++---- src/views/mall/promotion/kefu/index.vue | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/utils/index.ts b/src/utils/index.ts index 502ae602..8fab64a5 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -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) } diff --git a/src/views/mall/promotion/kefu/index.vue b/src/views/mall/promotion/kefu/index.vue index 916c375f..64b8abaa 100644 --- a/src/views/mall/promotion/kefu/index.vue +++ b/src/views/mall/promotion/kefu/index.vue @@ -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) -- Gitee