import React, { useEffect } from "react"; import { useModel } from "umi"; import { MiniMap } from "@antv/x6-plugin-minimap"; import { useSessionStorageState } from "ahooks"; export default function Navigator() { const { graph } = useModel("erModel"); const mapRef = React.useRef(null); const [show, setShow] = useSessionStorageState('show-navigator', { defaultValue: true, listenStorageChange: true, }); useEffect(() => { if (graph && mapRef.current) { console.log('mini map'); graph.use( new MiniMap({ container: mapRef.current, width: mapRef.current.offsetWidth || 300, height: mapRef.current.offsetHeight || 200, padding: 10, maxScale: 2, minScale: 0.2 }) ); } }, [graph, mapRef.current]); return (
setShow(!show)}> 导航
); }