From f7edf172455c9c84b8160444a1943995572d6596 Mon Sep 17 00:00:00 2001 From: pengm <674192343@qq.com> Date: Thu, 5 Feb 2026 09:56:17 +0800 Subject: [PATCH] 1.app心跳包 定时去检查当前WebSocket连接状态,如果是打开状态,则先发送消息;如果websoket关闭了,则重新建立连接 --- src/components/Common/PersonCenter/PersonCenterAddFace.js | 1 - src/components/Common/ProblemFeedback/ProblemFeedback.js | 2 +- src/models/app.js | 19 +++++++++++++------ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/components/Common/PersonCenter/PersonCenterAddFace.js b/src/components/Common/PersonCenter/PersonCenterAddFace.js index f291b34..712540f 100644 --- a/src/components/Common/PersonCenter/PersonCenterAddFace.js +++ b/src/components/Common/PersonCenter/PersonCenterAddFace.js @@ -10,7 +10,6 @@ const PersonCenterAddFace = Form.create({ mapPropsToFields(props) {}, })(props => { const { onCancel, handleModalClose, addFaceVisible } = props; - console.log('sssaddFaceVisibles', addFaceVisible); const GetFace = commonFunc.showMessage(props.app.commonConst, "GetFace"); /* 在线用户 */ return (
diff --git a/src/components/Common/ProblemFeedback/ProblemFeedback.js b/src/components/Common/ProblemFeedback/ProblemFeedback.js index 7982167..83dc124 100644 --- a/src/components/Common/ProblemFeedback/ProblemFeedback.js +++ b/src/components/Common/ProblemFeedback/ProblemFeedback.js @@ -250,7 +250,7 @@ const ProblemFeedback = props => { socketRef.current === null ) { if (useDefaultWs.current) { - console.log("=====检测到是小羚羊项目管理系统,不打开新的websocket。"); + // console.log("=====检测到是小羚羊项目管理系统,不打开新的websocket。"); } else { const { app } = props; const { userinfo } = app; diff --git a/src/models/app.js b/src/models/app.js index ea60358..a1676e5 100644 --- a/src/models/app.js +++ b/src/models/app.js @@ -604,10 +604,17 @@ export default { // 3s内没返回消息,则重新创建ws,重新发送 clearTimeout(window.wsTimer); window.wsTimer = setTimeout(() => { - console.log('================超时未收到WebSocket消息,重新创建ws并发送信息======================'); - window.wsHistoryArgs = args; - ws.onmessageTmp && (window.onmessageTmp = ws.onmessageTmp); - dispatch({ type: 'app/createWebSocket', payload: { reStart: true, dispatch } }); + // 检查当前WebSocket连接状态 + if (ws && ws.readyState === WebSocket.OPEN) { + console.log('================WebSocket连接正常但超时未收到消息,重新发送信息======================'); + // 先尝试重新发送消息,而不是直接创建新连接 + ws.originalSend.apply(ws, args); + } else { + console.log('================超时未收到WebSocket消息,重新创建ws并发送信息======================'); + window.wsHistoryArgs = args; + ws.onmessageTmp && (window.onmessageTmp = ws.onmessageTmp); + dispatch({ type: 'app/createWebSocket', payload: { reStart: true, dispatch } }); + } }, 3000); } ws.originalSend.apply(ws, args); @@ -650,8 +657,8 @@ export default { const msgPopupData = utils.isNotEmptyArr(msgObj.popup) ? msgObj.popup : []; const msgHeadData = utils.isNotEmptyObject(msgObj.data) ? msgObj.data : []; // 检查是否在 CommonBill 相关页面 - const isCommonBillPage = location.pathname.indexOf("/indexPage/commonBill") > -1 || - location.pathname.indexOf("/indexPage/commonCheckBill") > -1 || + const isCommonBillPage = location.pathname.indexOf("/indexPage/commonBill") > -1 || + location.pathname.indexOf("/indexPage/commonCheckBill") > -1 || location.pathname.indexOf("/indexPage/commonBillDeliver") > -1 || location.pathname.indexOf("/indexPage/commonNewBill") > -1 || location.pathname.indexOf("/indexPage/commonSubBill") > -1 || -- libgit2 0.22.2