From 67acd0bea63c5531272e7d96120cd35a01e31616 Mon Sep 17 00:00:00 2001 From: wuzuowei Date: Sat, 11 May 2024 20:17:15 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B7=B3=E8=BD=AC=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../microhost/components/rightInfo/index.tsx | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/platform-code/src/microhost/components/rightInfo/index.tsx b/platform-code/src/microhost/components/rightInfo/index.tsx index 4a79f9d..0b14cc8 100644 --- a/platform-code/src/microhost/components/rightInfo/index.tsx +++ b/platform-code/src/microhost/components/rightInfo/index.tsx @@ -14,6 +14,7 @@ import MicroApps from '@/microhost/system/apps' import { SystemData } from '@/microhost/models/system' import { string } from 'prop-types'; import { FrameMessage as message1 } from '@/library/union'; +import { WebSocketOption as SocketOption, WebSocketLoader as Socket } from "./ws" /** @@ -34,7 +35,41 @@ 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() + + return () => { + ws.current.dispose() + } + }, []); + + // const startSocket = () => { + // let option = new SocketOption() + + // option.ws = `ws://127.0.0.1:1233` + + // option.onOpen = () => { + + // } + + // option.onClose = () => { + + // } + + // option.onError = () => { + + // } + + // option.onMessage = (msgdata: any) => { + // setsocketData(JSON.parse(msgdata)) + // // console.log("on message", msgdata) + // } + // ws.current = new Socket(option) + // ws.current.start() + // } useEffect(() => { msglog(); }, []) @@ -69,7 +104,7 @@ const RightInfo = () => { const loginName = utils.loadCookie("loginName") //const loginName='chengzhigang'; requestaxios - .post("http://172.15.89.222:8081/WF/API/EmpWorksNums?UserNo=" + loginName) + .post("https://craft.dayesteel.com.cn:8081/WF/API/EmpWorksNums?UserNo=" + loginName) .then(({ data }) => { setmsgnum(data.replace("EmpWorksNums:", "")); // setTimeout(() => {