Browse Source

Merge branch 'master' of http://192.168.1.41:3000/lanjianrong/cldV2_console

outaozhen 3 years ago
parent
commit
15d15207ef

+ 6 - 6
config/routes.ts

@@ -80,13 +80,13 @@
         name: 'contact',
         component: './business/Contact',
         access: 'authRouteFilter'
-      },
-      {
-        path: '/business/notice',
-        name: 'notice',
-        component: './business/Notification',
-        access: 'authRouteFilter'
       }
+      // {
+      //   path: '/business/notice',
+      //   name: 'notice',
+      //   component: './business/Notification',
+      //   access: 'authRouteFilter'
+      // }
     ]
   }
 ]

+ 11 - 3
src/hooks/core/useWebSocketFn.ts

@@ -1,6 +1,6 @@
 /* eslint-disable react-hooks/rules-of-hooks */
 import { useWebSocket } from 'ahooks'
-import { useEffect } from 'react'
+import { useEffect, useState } from 'react'
 import { useModel } from 'umi'
 
 export enum cmdType {
@@ -20,10 +20,17 @@ export default function useWebSocketFn() {
 
   const { currentUser } = initialState
 
+  const [copyCount, setCopyCount] = useState('')
   const { disconnect, connect, webSocketIns } = useWebSocket(
     `ws://cld2qa.com/summon/v1/chat/link?username=${currentUser.username}&id=${currentUser.staffId}`,
     {
       manual: true,
+      onMessage: msg => {
+        const data = JSON.parse(msg.data)
+        if (data.cmd === 1) {
+          setCopyCount(data.CopyCount)
+        }
+      },
       reconnectLimit: 0,
       reconnectInterval: 2000
     }
@@ -36,13 +43,14 @@ export default function useWebSocketFn() {
       connect()
     }
     return () => {
-      window.removeEventListener('beforeunload', () => {})
       disconnect()
     }
   }, [])
 
   function sendMsg(cmd: cmdType, options: any) {
-    webSocketIns?.send(JSON.stringify({ cmd, userid: currentUser.staffId, ...options }))
+    webSocketIns?.send(
+      JSON.stringify({ cmd, userid: `${currentUser.staffId}_${copyCount}`, ...options })
+    )
   }
   return { webSocketIns, sendMsg }
 }

+ 2 - 2
src/pages/Business/Notification/components/RighEditor.tsx

@@ -9,9 +9,9 @@ const mdParser = new MarkdownIt()
 const RighEditor = ({ value, onChange }) => {
   const [cValue, setValue] = useState(value)
   // 完成!
-  function handleEditorChange({ text }) {
+  function handleEditorChange({ text, html }) {
     setValue(text)
-    onChange(text)
+    onChange(JSON.stringify(html))
   }
   return (
     <MdEditor