Navigator.tsx 618 B

12345678910111213141516171819202122232425262728
  1. import React, { useEffect } from "react";
  2. import { useModel } from "umi";
  3. import { MiniMap } from "@antv/x6-plugin-minimap";
  4. export default function Navigator() {
  5. const { graph } = useModel("erModel");
  6. const mapRef = React.useRef<HTMLDivElement>(null);
  7. useEffect(() => {
  8. console.log("graph", graph);
  9. if (graph && mapRef.current) {
  10. graph.use(
  11. new MiniMap({
  12. container: mapRef.current,
  13. width: 330,
  14. height: 210,
  15. padding: 10,
  16. })
  17. );
  18. }
  19. }, [graph, mapRef.current]);
  20. return (
  21. <div>
  22. <div ref={mapRef}></div>
  23. </div>
  24. );
  25. }