diff --git a/web/app/components/app/chat/index.tsx b/web/app/components/app/chat/index.tsx index 3cfcc42773..c8cdab3e78 100644 --- a/web/app/components/app/chat/index.tsx +++ b/web/app/components/app/chat/index.tsx @@ -8,6 +8,8 @@ import { UserCircleIcon } from '@heroicons/react/24/solid' import { useTranslation } from 'react-i18next' import { randomString } from '../../app-sidebar/basic' import s from './style.module.css' +import LoadingAnim from './loading-anim' +import CopyBtn from './copy-btn' import Tooltip from '@/app/components/base/tooltip' import { ToastContext } from '@/app/components/base/toast' import AutoHeightTextarea from '@/app/components/base/auto-height-textarea' @@ -15,9 +17,8 @@ import Button from '@/app/components/base/button' import type { Annotation, MessageRating } from '@/models/log' import AppContext from '@/context/app-context' import { Markdown } from '@/app/components/base/markdown' -import LoadingAnim from './loading-anim' import { formatNumber } from '@/utils/format' -import CopyBtn from './copy-btn' +import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints' const stopIcon = ( @@ -285,8 +286,8 @@ const Answer: FC = ({ item, feedbackDisabled = false, isHideFeedba
- {isResponsing && -
+ {isResponsing + &&
} @@ -301,13 +302,15 @@ const Answer: FC = ({ item, feedbackDisabled = false, isHideFeedba
{t('appDebug.openingStatement.title')}
)} - {(isResponsing && !content) ? ( -
- -
- ) : ( - - )} + {(isResponsing && !content) + ? ( +
+ +
+ ) + : ( + + )} {!showEdit ? (annotation?.content && <> @@ -384,13 +387,15 @@ const Question: FC = ({ id, content, more, useCurrentUserAvatar
{more && }
- {useCurrentUserAvatar ? ( -
- {userName?.[0].toLocaleUpperCase()} -
- ) : ( -
- )} + {useCurrentUserAvatar + ? ( +
+ {userName?.[0].toLocaleUpperCase()} +
+ ) + : ( +
+ )}
) } @@ -411,7 +416,7 @@ const Chat: FC = ({ controlClearQuery, controlFocus, isShowSuggestion, - suggestionList + suggestionList, }) => { const { t } = useTranslation() const { notify } = useContext(ToastContext) @@ -436,27 +441,24 @@ const Chat: FC = ({ } useEffect(() => { - if (controlClearQuery) { + if (controlClearQuery) setQuery('') - } }, [controlClearQuery]) const handleSend = () => { if (!valid() || (checkCanSend && !checkCanSend())) return onSend(query) - if (!isResponsing) { + if (!isResponsing) setQuery('') - } } const handleKeyUp = (e: any) => { if (e.code === 'Enter') { e.preventDefault() // prevent send message when using input method enter - if (!e.shiftKey && !isUseInputMethod.current) { + if (!e.shiftKey && !isUseInputMethod.current) handleSend() - } } } @@ -468,6 +470,10 @@ const Chat: FC = ({ } } + const media = useBreakpoints() + const isMobile = media === MediaType.mobile + const sendBtn =
+ return (
{/* Chat List */} @@ -506,7 +512,7 @@ const Chat: FC = ({
{TryToAskIcon} @@ -514,7 +520,7 @@ const Chat: FC = ({
@@ -544,17 +550,21 @@ const Chat: FC = ({ />
{query.trim().length}
- -
{t('common.operation.send')} Enter
-
{t('common.operation.lineBreak')} Shift Enter
-
- } - > -
- + {isMobile + ? sendBtn + : ( + +
{t('common.operation.send')} Enter
+
{t('common.operation.lineBreak')} Shift Enter
+
+ } + > + {sendBtn} + + )}
diff --git a/web/app/components/app/chat/style.module.css b/web/app/components/app/chat/style.module.css index 7f48069fb7..9dc5342789 100644 --- a/web/app/components/app/chat/style.module.css +++ b/web/app/components/app/chat/style.module.css @@ -102,6 +102,10 @@ background: url(./icons/send.svg) center center no-repeat; } +.sendBtnActive { + background-image: url(./icons/send-active.svg); +} + .sendBtn:hover { background-image: url(./icons/send-active.svg); background-color: #EBF5FF;