import { AimOutlined, CompressOutlined, ExpandOutlined, MinusOutlined, PlusOutlined, QuestionCircleFilled, } from "@ant-design/icons"; import { Button, ConfigProvider, Divider, Slider, Tooltip } from "antd"; import React, { useEffect, useMemo, useRef, useState } from "react"; import { useFullscreen } from "ahooks"; import { useModel } from "umi"; import { MiniMap } from "@antv/x6-plugin-minimap"; import insertCss from "insert-css"; import { TopicType } from "@/enum"; insertCss(` .navigation-view { position: absolute; bottom: 32px; right: 32px; width: 330px; height: 210px; background-color: #fff; border: 1px solid #e9edf2; border-radius: 8px 8px 0 0; overflow: hidden; z-index: 1; box-shadow: 0 4px 10px 1px rgba(0, 0, 0, .1); }`); export default function Footer() { const [isFullscreen, { toggleFullscreen }] = useFullscreen(document.body); const navigationViewRef = useRef(null); const [showNavigation, setShowNavigation] = useState(false); const [scale, setScale] = useState(100); const { selectedCell, graph } = useModel("mindMapModel"); useEffect(() => { if (!graph || !navigationViewRef.current) return; graph.use( new MiniMap({ container: navigationViewRef.current, width: 330, height: 210, padding: 10, }) ); }, [graph, navigationViewRef.current]); graph?.on("scale", (args) => { setScale(args.sx * 100); }); const countInfo = useMemo(() => { return { selectedNodeCount: selectedCell.filter((cell) => cell.isNode()).length, selectedNodeTextCount: selectedCell.reduce( (a, b) => a + b.data?.label?.length || 0, 0 ), nodeCount: graph?.getNodes().length || 0, textCount: graph?.getNodes().reduce((a, b) => a + b.data?.label?.length || 0, 0) || 0, }; }, [selectedCell, graph]); const handleZoom = (value: number) => { graph?.zoomTo(value / 100); }; const handleZoomFit = () => { graph?.zoomTo(1); }; const handleOnChange = (value: number) => { setScale(value); handleZoom(value); }; const handleFocusCenter = () => { const center = graph ?.getCells() .find((cell) => cell.data?.type === TopicType.main); center && graph?.centerCell(center); }; return (
字数: {countInfo.selectedNodeCount ? `${countInfo.selectedNodeTextCount}/` : ""} {countInfo.textCount}
主题数: {countInfo.selectedNodeCount ? `${countInfo.selectedNodeCount}/` : ""} {countInfo.nodeCount}
); }