From 4bcc6e434705461e241df5f5b675592db880ca11 Mon Sep 17 00:00:00 2001 From: CrescentLeaf Date: Thu, 25 Sep 2025 00:42:31 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=89=8B=E5=8B=95=E9=81=B8=E6=93=87?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/ui/chat/ChatFragment.tsx | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/client/ui/chat/ChatFragment.tsx b/client/ui/chat/ChatFragment.tsx index dfa281f..677a2b5 100644 --- a/client/ui/chat/ChatFragment.tsx +++ b/client/ui/chat/ChatFragment.tsx @@ -104,7 +104,7 @@ export default function ChatFragment({ target, showReturnButton, onReturnButtonC const { chat, msg } = (data as OnMessageData) if (target == chat) { setMessagesList(messagesList.concat([msg])) - if ((chatPanelRef.current!.scrollHeight - chatPanelRef.current!.scrollTop - chatPanelRef.current!.clientHeight) < 80) + if ((chatPanelRef.current!.scrollHeight - chatPanelRef.current!.scrollTop - chatPanelRef.current!.clientHeight) < 130) setTimeout(() => chatPanelRef.current!.scrollTo({ top: 10000000000, behavior: "smooth", @@ -159,6 +159,8 @@ export default function ChatFragment({ target, showReturnButton, onReturnButtonC setIsMessageSending(false) } + const attachFileInputRef = React.useRef(null) + function insertText(text: string) { const input = inputRef.current!.shadowRoot!.querySelector('[part=input]') as HTMLTextAreaElement inputRef.current!.value = input.value!.substring(0, input.selectionStart as number) + text + input.value!.substring(input.selectionEnd as number, input.value.length) @@ -177,6 +179,14 @@ export default function ChatFragment({ target, showReturnButton, onReturnButtonC else insertText(`![File=${name}](${name})`) } + useEventListener(attachFileInputRef, 'change', (_e) => { + const files = attachFileInputRef.current!.files as unknown as File[] + if (files?.length == 0) return + + for (const file of files) { + addFile(file.type, file.name, file) + } + }) return (
- { + attachFileInputRef.current!.click() }}> sendMessage()} loading={isMessageSending}> +
+ +