diff --git a/platform-code/src/microhost/components/rightInfo/index.tsx b/platform-code/src/microhost/components/rightInfo/index.tsx index 17ff111..76b5d9d 100644 --- a/platform-code/src/microhost/components/rightInfo/index.tsx +++ b/platform-code/src/microhost/components/rightInfo/index.tsx @@ -35,43 +35,43 @@ const RightInfo = () => { const [searchList, setSearchList] = useState([]) const [msgnum, setmsgnum] = useState(""); //const [isHidden, setIsHidden] = useState(true); // 初始化状态变量为 false - // const ws = useRef(new Socket(new SocketOption())) - // const [socketData, setsocketData] = useState({}) - // useEffect(() => { - // startSocket() + const ws = useRef(new Socket(new SocketOption())) + const [socketData, setsocketData] = useState({}) + useEffect(() => { + startSocket() - // return () => { - // ws.current.dispose() - // } - // }, []); + return () => { + ws.current.dispose() + } + }, []); - // const startSocket = () => { - // let option = new SocketOption() + const startSocket = () => { + let option = new SocketOption() - // option.ws = `ws://127.0.0.1:1233` + option.ws = `wss://craft.dayesteel.com.cn:1555` - // option.onOpen = () => { + option.onOpen = () => { - // } + } - // option.onClose = () => { + option.onClose = () => { - // } + } - // option.onError = () => { + option.onError = () => { - // } + } - // option.onMessage = (msgdata: any) => { - // setsocketData(JSON.parse(msgdata)) - // // console.log("on message", msgdata) - // } + option.onMessage = (msgdata: any) => { + setsocketData(JSON.parse(msgdata)) + console.log("on message", msgdata) + } - // ws.current = new Socket(option) - // ws.current.start() - // } + ws.current = new Socket(option) + ws.current.start() + } useEffect(() => { - msglog(); + // msglog(); }, []) useLayoutEffect(() => { @@ -351,7 +351,7 @@ const RightInfo = () => { gomsglog() // Cookies.set('InputListData', JSON.stringify(record)); }} - id='MSGNUM' style={{ fontSize: '16PX', color: 'rgb(225 70 70)' }}>{`您有${msgnum}条待办`} + id='MSGNUM' style={{ fontSize: '16PX', color: 'rgb(225 70 70)' }}>{`您有${socketData.EmpWorksNums ? socketData.EmpWorksNums : 0}条待办`} {/* */}