ball_admin/src/App.tsx

44 lines
1.0 KiB
TypeScript

import { Outlet } from "react-router";
import MapUtl from "./components/map/mapUtil";
import { useEffect } from "react";
// import SocketService from "./util/socket";
// const socketService = SocketService.getInstance();
const onMessage = (e: any) => {
let data = JSON.parse(e);
if (data.type === "accpt") {
let body = JSON.parse(data.content.body);
MapUtl.addMaker({
lng: 103.55,
lat: 30.342,
title: body?.user_name,
users: body,
});
} else if (data.type === "move") {
let maker: any = null;
let body = JSON.parse(data.content.body);
MapUtl.makerList?.forEach((e) => {
if (e.userIdentity === body?.user_identity) {
maker = e.marker;
}
});
maker?.setPosition([body.long, body.lat]);
}
};
// socketService.on("message", onMessage);
const App = () => {
useEffect(() => {
return () => {
console.log("uninstall");
// socketService.off("message", onMessage);
};
}, []);
return (
<>
<Outlet />
</>
);
};
export default App;