import React, { useRef } from 'react'; import { useChatBox } from '@/components/ChatBox'; import { ChatItemType } from '@/types/chat'; import { Menu, MenuButton, MenuList, MenuItem, Box } from '@chakra-ui/react'; import MyIcon from '@/components/Icon'; import { useRouter } from 'next/router'; const ToolMenu = ({ history }: { history: ChatItemType[] }) => { const { onExportChat } = useChatBox(); const router = useRouter(); const menuList = useRef([ { icon: 'chat', label: '新对话', onClick: () => { router.push({ query: { appId: router.query?.appId } }); } }, { icon: 'apiLight', label: 'HTML导出', onClick: () => onExportChat({ type: 'html', history }) }, { icon: 'markdown', label: 'Markdown导出', onClick: () => onExportChat({ type: 'md', history }) }, { icon: 'pdf', label: 'PDF导出', onClick: () => onExportChat({ type: 'pdf', history }) } ]); return history.length > 0 ? (
) : null; }; export default ToolMenu;