From 6cb40e0242acb27efc5a4db469353a2942d6114d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B0=E5=B2=A9?= Date: Fri, 12 Dec 2025 21:08:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4nvue=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 2 +- src/App.vue | 201 ++++++++++++++----------- src/pages/sparring/js/ProtocolCodec.ts | 1 - src/pages/sparring/js/useWebSocket.js | 8 +- src/pages/sparring/talk.vue | 2 +- src/pages/test/testChat.nvue | 38 ----- 6 files changed, 119 insertions(+), 133 deletions(-) delete mode 100644 src/pages/test/testChat.nvue diff --git a/.env.development b/.env.development index e3343c6f..27b8fd64 100644 --- a/.env.development +++ b/.env.development @@ -6,7 +6,7 @@ ENV = 'development' # VITE_APP_BASE_API_Url = 'https://aits.jlbank.com.cn:7001' -VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7003' +VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7002' # VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7002' diff --git a/src/App.vue b/src/App.vue index 5b1d72d2..df02f786 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,6 +1,6 @@ + \ No newline at end of file diff --git a/src/pages/sparring/js/ProtocolCodec.ts b/src/pages/sparring/js/ProtocolCodec.ts index 02da520c..c114cd05 100644 --- a/src/pages/sparring/js/ProtocolCodec.ts +++ b/src/pages/sparring/js/ProtocolCodec.ts @@ -169,7 +169,6 @@ export class ProtocolCodec { // STRING 序列化:必须传入字符串(非 PING 消息已校验非空) serializedBody = textEncoder.encode(body as string); break; - case SerializationType.JSON: // 断言:body 是 string 或 object if (typeof body === 'string') { diff --git a/src/pages/sparring/js/useWebSocket.js b/src/pages/sparring/js/useWebSocket.js index ebfbae19..0b7cd92d 100644 --- a/src/pages/sparring/js/useWebSocket.js +++ b/src/pages/sparring/js/useWebSocket.js @@ -22,8 +22,8 @@ const DEFAULT_AUTH_PARAMS = { user_id: '1001', // 默认用户ID(可从缓存/全局状态取) token: '', // 优先从缓存获取,避免硬编码 name: '测试用户', - device_id: uni.getSystemInfoSync().deviceId || '', // 设备ID(补充) - timestamp: Date.now() // 时间戳(防篡改) + // device_id: uni.getSystemInfoSync().deviceId || '', // 设备ID(补充) + // timestamp: Date.now() // 时间戳(防篡改) }; // const wsUrl = 'ws://127.0.0.1:8000/ws/audio' const url = '/trapractice/voiceCallSocket/voiceCall' @@ -44,6 +44,7 @@ export default function useWebSocket(aaas = null, options = {}) { ...DEFAULT_AUTH_PARAMS, ...authParams, }; + ws.value = uni.connectSocket({ url: wsUrl, fail: () => { @@ -54,15 +55,12 @@ export default function useWebSocket(aaas = null, options = {}) { } }); ws.value.onOpen((res) => { - console.log('onOpen', finalAuthParams); ws.value.send({ data: ProtocolCodec.pack(MessageType.IDENTITY, finalAuthParams) }); }); ws.value.onError((err) => onError(err)) - - ws.value.onClose((err) => { console.log('onClose', err); onClose(err) diff --git a/src/pages/sparring/talk.vue b/src/pages/sparring/talk.vue index 37d5078b..de5c933a 100644 --- a/src/pages/sparring/talk.vue +++ b/src/pages/sparring/talk.vue @@ -259,7 +259,7 @@ 'traInterTyp': dataInfo.traInterTyp, 'traId': dataInfo.traId, 'chaId': dataInfo.chaId, - 'preview': true, + 'preview': true }, onStartRecord: onStartRecord, playPcmCallback: (res) => talkSpeakerRef.value.playPCM(res), diff --git a/src/pages/test/testChat.nvue b/src/pages/test/testChat.nvue deleted file mode 100644 index 336c20c6..00000000 --- a/src/pages/test/testChat.nvue +++ /dev/null @@ -1,38 +0,0 @@ - - - -