diff --git a/app/components/AttachImage.tsx b/app/components/AttachImage.tsx new file mode 100644 index 00000000..4be9ed05 --- /dev/null +++ b/app/components/AttachImage.tsx @@ -0,0 +1,32 @@ +'use client'; + +import { XMarkIcon } from '@heroicons/react/24/outline'; +import Image from 'next/image'; +import type { FC } from 'react'; +import { useContext } from 'react'; + +import { ChatContext } from '@/context/ChatContext'; + +import { AttachImageButton } from './buttons/AttachImageButton'; + +export const AttachImage: FC = () => { + const { images, deleteImage } = useContext(ChatContext)!; + + return ( +
+ + {[...images].reverse().map((imageProp, index) => ( +
+ { + // 因为前面将 images revert 了,所以这里需要计算真正的 index + deleteImage(images.length - 1 - index); + }} + /> + 图片 +
+ ))} +
+ ); +}; diff --git a/app/components/History.tsx b/app/components/History.tsx index d88b39da..d646ad48 100644 --- a/app/components/History.tsx +++ b/app/components/History.tsx @@ -11,7 +11,7 @@ import { SettingsContext } from '@/context/SettingsContext'; import { FULL_SPACE } from '@/utils/constants'; import { exportJSON } from '@/utils/export'; import { last } from '@/utils/last'; -import { getContent } from '@/utils/message'; +import { getContentText } from '@/utils/message'; import { DeleteHistoryButton } from './buttons/DeleteHistoryButton'; @@ -65,13 +65,13 @@ export const HistoryItemComp: FC<{ historyIndex: 'current' | number; isActive: b })} onClick={() => historyIndex !== 'current' && loadHistory(historyIndex)} > -

{getContent(historyItem.messages[0])}

+

{getContentText(historyItem.messages[0])}

- {historyItem.messages.length > 1 ? getContent(last(historyItem.messages)) : FULL_SPACE} + {historyItem.messages.length > 1 ? getContentText(last(historyItem.messages)) : FULL_SPACE}

{isActive && } diff --git a/app/components/Menu.tsx b/app/components/Menu.tsx index 803eed93..262231d9 100644 --- a/app/components/Menu.tsx +++ b/app/components/Menu.tsx @@ -107,7 +107,7 @@ const MenuTabs = () => { return (