ER.tsx 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import React, { useEffect } from "react";
  2. import { useModel } from "umi";
  3. import Navigator from "@/pages/er/components/Navigator";
  4. import {
  5. EnvironmentOutlined,
  6. FullscreenExitOutlined,
  7. UnorderedListOutlined,
  8. } from "@ant-design/icons";
  9. export default function ER(props: {
  10. showNavigator: boolean;
  11. isFullScreen: boolean;
  12. onExitFullscreen: () => void;
  13. onChangeShowNavigator: (show: boolean) => void;
  14. }) {
  15. const contianerRef = React.useRef<HTMLDivElement>(null);
  16. const { graph, project, initGraph } = useModel("erModel");
  17. useEffect(() => {
  18. initGraph(
  19. contianerRef.current!,
  20. contianerRef.current?.clientWidth!,
  21. contianerRef.current?.clientHeight!
  22. );
  23. }, []);
  24. return (
  25. <div className="w-full h-full relative">
  26. <div className="w-full h-full" ref={contianerRef} />
  27. {props.showNavigator && <Navigator />}
  28. {props.isFullScreen && (
  29. <div className="absolute top-32px right-32px z-2">
  30. <div className="left bg-#fff shadow-md p-x-4px p-y-4px flex items-center gap-8px">
  31. <div
  32. className="
  33. rounded-4px
  34. cus-btn
  35. w-32px
  36. h-32px
  37. bg-#eee
  38. flex-none
  39. text-center
  40. leading-32px
  41. cursor-pointer
  42. hover:bg-#ddd"
  43. >
  44. <UnorderedListOutlined />
  45. </div>
  46. <div
  47. className="
  48. rounded-4px
  49. cus-btn
  50. w-32px
  51. h-32px
  52. bg-#eee
  53. flex-none
  54. text-center
  55. leading-32px
  56. cursor-pointer
  57. hover:bg-#ddd"
  58. >
  59. <EnvironmentOutlined
  60. onClick={() => {
  61. props.onChangeShowNavigator(!props.showNavigator);
  62. }}
  63. />
  64. </div>
  65. <div
  66. className="
  67. rounded-4px
  68. cus-btn
  69. w-32px
  70. h-32px
  71. bg-#eee
  72. flex-none
  73. text-center
  74. leading-32px
  75. cursor-pointer
  76. hover:bg-#ddd"
  77. onClick={() => props.onExitFullscreen()}
  78. >
  79. <FullscreenExitOutlined />
  80. </div>
  81. </div>
  82. </div>
  83. )}
  84. </div>
  85. );
  86. }