修改消息实时推送

master
wuzuowei 4 months ago
parent dd7b519f4a
commit 0b1fd5a543

@ -35,43 +35,43 @@ const RightInfo = () => {
const [searchList, setSearchList] = useState<any[]>([])
const [msgnum, setmsgnum] = useState<any>("");
//const [isHidden, setIsHidden] = useState(true); // 初始化状态变量为 false
// const ws = useRef<Socket>(new Socket(new SocketOption()))
// const [socketData, setsocketData] = useState<any>({})
// useEffect(() => {
// startSocket()
const ws = useRef<Socket>(new Socket(new SocketOption()))
const [socketData, setsocketData] = useState<any>({})
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}条待办`}
</span>
{/* </Popover> */}

Loading…
Cancel
Save