import { ArrowLeftOutlined, ArrowRightOutlined } from "@ant-design/icons" import { Button } from "antd" import { useNavigate, fillRoutePath, RoutePath, usePathData } from "router" import { saveAs } from 'utils' import style from './style.module.scss' import { useSelector, boardStatus, useDispatch, insertBoard, updateBoard, currentBoard, BoardTypeDesc, BoardType } from "store" import type { RefObject } from "react" import type { Board } from "./board" type HeaderProps = { board: RefObject type: BoardType } const Header = ({ board, type }: HeaderProps) => { const path = usePathData() const status = useSelector(boardStatus) const current = useSelector(currentBoard) const dispatch = useDispatch() const navigate = useNavigate() const exportPng = async () => { if (board.current) { const blob = await board.current.export() saveAs(blob, '现场图.png') } } const save = async () => { if (current.id === -1) { const data = await dispatch(insertBoard({ type, data: current })).unwrap() navigate( fillRoutePath(RoutePath.drawFile, { ...path as any, id: data.id.toString() }), { replace: true } ) } else { dispatch(updateBoard({ id: current.id, data: current })) } } return ( <>
navigate(-1)}> 返回

创建{ BoardTypeDesc[type] }

dispatch({ type: 'board/backoff' })} /> dispatch({ type: 'board/forward' })} />
) } export default Header