From c3aea146dbd212675912dd66dcfe3e272542ee77 Mon Sep 17 00:00:00 2001 From: yanghang Date: Wed, 9 Jul 2025 14:16:51 +0800 Subject: [PATCH] fix: bug --- .env.development | 4 ++-- src/api/socket.js | 3 +++ src/pages.json | 9 +++++++++ src/pages/course/study.vue | 7 ++++++- src/pages/index/dialog.vue | 9 +++++++++ src/pagesB.json | 9 +++++++++ src/store/socket.js | 7 ++++++- 7 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 src/pages/index/dialog.vue diff --git a/.env.development b/.env.development index 6c917b72..39399d34 100644 --- a/.env.development +++ b/.env.development @@ -5,9 +5,9 @@ ENV = 'development' # base api # 苗扬 -# VITE_APP_BASE_API_Url = 'http://25.64.16.133:9786' +VITE_APP_BASE_API_Url = 'http://25.64.16.133:9786' -VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7002' +# VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7001' # http://25.18.122.65:7001/download/dev-jax.apk # app入口 #VITE_APP_BASE_API_Url = 'http://25.18.122.65:7001' diff --git a/src/api/socket.js b/src/api/socket.js index 98392b08..51737370 100644 --- a/src/api/socket.js +++ b/src/api/socket.js @@ -20,6 +20,7 @@ export default class WebSocketUtil { this.heartbeatTimer = null; // 心跳计时器 this.heartbeatInterval = options.heartbeatInterval || 30000; // 心跳间隔(ms) this.heartbeatMsg = options.heartbeatMsg || 'ping'; // 心跳消息 + this.isClose = false; // 手动关闭 this.callbacks = { open: [], // 连接打开回调 message: [], // 消息接收回调 @@ -165,6 +166,7 @@ export default class WebSocketUtil { * @returns {WebSocketUtil} - 返回当前实例,支持链式调用 */ close(code = 1000, reason = '') { + this.isClose = true if (this.socketTask) { clearInterval(this.heartbeatTimer); // 清除心跳计时器 clearInterval(this.reconnectTimer); // 清除重连计时器 @@ -204,6 +206,7 @@ export default class WebSocketUtil { * 尝试重新连接WebSocket */ tryReconnect() { + if(this.isClose) return if (this.reconnectCount < this.maxReconnectCount) { clearInterval(this.reconnectTimer); this.reconnectTimer = setTimeout(() => { diff --git a/src/pages.json b/src/pages.json index 895584bc..d83f4f68 100644 --- a/src/pages.json +++ b/src/pages.json @@ -143,6 +143,15 @@ "titleNView": false } } + }, + { + "path": "pages/index/dialog", + "style": { + "navigationBarTitleText": "AI问答", + "app-plus": { + "titleNView": false + } + } } ], "tabBar": { diff --git a/src/pages/course/study.vue b/src/pages/course/study.vue index 9d8243db..bc7bb600 100644 --- a/src/pages/course/study.vue +++ b/src/pages/course/study.vue @@ -277,9 +277,13 @@ const nextStep = () => { const pgrphNum = ref(1) const showOrder = ref(0) +const isLastPgrph = ref(false) // 获取段落 const getGraphInfoUnStudy = () => { - + if(isLastPgrph.value){ + common.msg('您已学完全部知识点!') + return + } textChartApi({ processType: 'PRGH-STDY', requestBody: JSON.stringify({ @@ -304,6 +308,7 @@ const getGraphInfoUnStudy = () => { type: Number(_body.bodyTyp) || 0, id: _id } + isLastPgrph.value = _body.chatBody.haveNext !== 'Y' talkingList.value.push(lastTalkingInfo.value) pgrphNum.value = _body.chatBody.pgrphNum showOrder.value = _body.chatBody.showOrder diff --git a/src/pages/index/dialog.vue b/src/pages/index/dialog.vue new file mode 100644 index 00000000..df93e492 --- /dev/null +++ b/src/pages/index/dialog.vue @@ -0,0 +1,9 @@ + + + + + \ No newline at end of file diff --git a/src/pagesB.json b/src/pagesB.json index c578ab53..d95e22c3 100644 --- a/src/pagesB.json +++ b/src/pagesB.json @@ -17,6 +17,15 @@ "titleNView": false } } + }, + { + "path": "pages/index/dialog", + "style": { + "navigationBarTitleText": "AI问答", + "app-plus": { + "titleNView": false + } + } } ] } \ No newline at end of file diff --git a/src/store/socket.js b/src/store/socket.js index 2fe21721..1438823a 100644 --- a/src/store/socket.js +++ b/src/store/socket.js @@ -15,8 +15,13 @@ export const useSocketStore = defineStore('socketStore',{ }, actions:{ creatSocket(){ + if(this.SocketObj && this.SocketObj?.close && !this.SocketObj?.isClose) { + return + } + if(this.SocketObj?.isClose){ + this.SocketObj.isClose = false + } let _baseUrl = get_base_url().split('http').join('ws') - if(this.SocketObj && this.SocketObj?.close) return this.SocketObj = new SocketClass(_baseUrl + '/trastudy/trasoket/open?summary=' + getToken()); }, closeSocket() {