-
Notifications
You must be signed in to change notification settings - Fork 269
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
499 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<div className="flex flex-row-reverse items-center"> | ||
<AttachImageButton /> | ||
{[...images].reverse().map((imageProp, index) => ( | ||
<div key={index} className="attach-image-container relative mr-[-28px] z-10 cursor-pointer"> | ||
<XMarkIcon | ||
className="attach-image-delete absolute top-0 right-0 w-5 h-5 p-0.5 m-0.5 rounded-sm hidden" | ||
onClick={() => { | ||
// 因为前面将 images revert 了,所以这里需要计算真正的 index | ||
deleteImage(images.length - 1 - index); | ||
}} | ||
/> | ||
<Image {...imageProp} className="h-16 w-14 object-cover rounded border-[0.5px] border-gray" alt="图片" /> | ||
</div> | ||
))} | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
64e893b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
chatgpt-next – ./
chatgpt-next-xcatliu.vercel.app
chatgpt-next-git-main-xcatliu.vercel.app