فهرست منبع

Merge branch 'dev' of http://192.168.1.41:3000/outaozhen/cldV2react into dev

outaozhen 4 سال پیش
والد
کامیت
e6d2730418
3فایلهای تغییر یافته به همراه19 افزوده شده و 16 حذف شده
  1. 4 2
      src/pages/Product/Cloud/index.jsx
  2. 0 1
      src/pages/Product/Lock/LockStore/index.jsx
  3. 15 13
      src/utils/ws.ts

+ 4 - 2
src/pages/Product/Cloud/index.jsx

@@ -78,7 +78,8 @@ const Cloud = () => {
       render: (text, record) => (
         <span
           onClick={() => showDrawerRoadpricing(record.ssoId)}
-          className="text-primary cursor-pointer hover:text-[#967bbd]">
+          className="text-primary cursor-pointer hover:text-[#967bbd]"
+        >
           {text}
         </span>
       )
@@ -185,7 +186,8 @@ const Cloud = () => {
                       )
                   )}
                 </div>
-              }>
+              }
+            >
               {record.all_online_times}
             </Tooltip>
           )

+ 0 - 1
src/pages/Product/Lock/LockStore/index.jsx

@@ -259,7 +259,6 @@ const LockStore = ({ prodList = [], dispatch, shouldUpdate }) => {
     {
       title: '销售时间',
       dataIndex: 'sellTime',
-      valueType: 'date',
       key: 'sellTime',
       width: 90
     },

+ 15 - 13
src/utils/ws.ts

@@ -20,7 +20,9 @@ export enum CmdType {
   /** @name 在线员工列表 */
   OnlineBook = 12,
   /** @name 员工工作状态 */
-  WorkStatus = 14
+  WorkStatus = 14,
+  /** @name 强制退出 */
+  OutLine = 15
 }
 
 interface Options {
@@ -103,7 +105,7 @@ class Ws {
 
       // 监听窗口关闭事件,当窗口关闭时,主动去关闭websocket连接,防止连接还没断开就关闭窗口,server端会抛异常。
       window.addEventListener('beforeunload', () => {
-        this.wsIns?.close()
+        this.disconnect()
       })
     } catch (error) {
       if (isDevMode()) {
@@ -120,11 +122,12 @@ class Ws {
     }
   }
 
-  /** 断线重连 */
+  /** 断开连接 */
   public disconnect() {
     if (this.wsIns?.readyState === ReadyState.Open) {
       this.isLock = true
-      this.wsIns.close()
+      // this.wsIns.close()
+      this.sendMessage({ cmd: CmdType.OutLine, userid: this.uid })
     }
   }
 
@@ -146,17 +149,16 @@ class Ws {
   // 重连
   private reconnect(): void {
     if (
-      this.isLock ||
-      (this.opts?.reconnectLimit && this.reconnectLimit > this.opts?.reconnectLimit)
+      !this.isLock &&
+      !(this.opts?.reconnectLimit && this.reconnectLimit > this.opts?.reconnectLimit)
     ) {
-      return
+      this.reconnectLimit += 1
+      this.timer && clearTimeout(this.timer)
+      this.timer = setTimeout(() => {
+        this.connectWs()
+        this.isLock = false
+      }, 4000)
     }
-    this.reconnectLimit += 1
-    this.timer && clearTimeout(this.timer)
-    this.timer = setTimeout(() => {
-      this.connectWs()
-      this.isLock = false
-    }, 4000)
   }
 }
 export function onMessage(msg: MessageType) {