|
|
@@ -15,7 +15,7 @@ import { useNavigate, useLocation } from "react-router-dom";
|
|
|
// 本地组件和工具导入
|
|
|
import { IconButton } from "./button";
|
|
|
import { MaskAvatar } from "./mask";
|
|
|
-import styles from "./chat.module.scss";
|
|
|
+import styles from "./chatHomeOnly.module.scss";
|
|
|
|
|
|
// 图标资源导入
|
|
|
import LeftIcon from "../icons/left.svg";
|
|
|
@@ -801,7 +801,7 @@ export function DeleteImageButton( props : { deleteImage : () => void } ) {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
-function _Chat() {
|
|
|
+function _Chat(props?: { onMessageSent?: () => void }) {
|
|
|
type RenderMessage = ChatMessage & { preview? : boolean };
|
|
|
|
|
|
const chatStore = useChatStore();
|
|
|
@@ -852,13 +852,13 @@ function _Chat() {
|
|
|
} );
|
|
|
}, [] )
|
|
|
|
|
|
- const [ inputRows, setInputRows ] = useState( 2 );
|
|
|
+ const [ inputRows, setInputRows ] = useState( isMobileScreen ? 1 : 2 );
|
|
|
const measure = useDebouncedCallback(
|
|
|
() => {
|
|
|
const rows = inputRef.current ? autoGrowTextArea( inputRef.current ) : 1;
|
|
|
const inputRows = Math.min(
|
|
|
20,
|
|
|
- Math.max( 2 + Number( !isMobileScreen ), rows ),
|
|
|
+ Math.max( isMobileScreen ? 1 : (2 + Number( !isMobileScreen )), rows ),
|
|
|
);
|
|
|
setInputRows( inputRows );
|
|
|
},
|
|
|
@@ -920,8 +920,11 @@ function _Chat() {
|
|
|
localStorage.setItem( LAST_INPUT_KEY, userInput );
|
|
|
setUserInput( "" );
|
|
|
setPromptHints( [] );
|
|
|
- if ( !isMobileScreen ) inputRef.current?.focus();
|
|
|
+ // 取消输入框的选定状态
|
|
|
+ inputRef.current?.blur();
|
|
|
setAutoScroll( true );
|
|
|
+ // 通知父组件消息已发送
|
|
|
+ props?.onMessageSent?.();
|
|
|
};
|
|
|
|
|
|
const onPromptSelect = ( prompt : RenderPrompt ) => {
|
|
|
@@ -1463,6 +1466,8 @@ function _Chat() {
|
|
|
)
|
|
|
}
|
|
|
|
|
|
+ const location = useLocation();
|
|
|
+
|
|
|
return (
|
|
|
<div className={ styles.chat } key={ session.id }>
|
|
|
{
|
|
|
@@ -1777,7 +1782,7 @@ function _Chat() {
|
|
|
</Tooltip>}
|
|
|
{/*联网搜索按钮*/ }
|
|
|
<div style={ {
|
|
|
- padding: '0 12px',
|
|
|
+ padding: isMobileScreen ? '0 8px' : '0 12px',
|
|
|
height: 28,
|
|
|
borderRadius: 18,
|
|
|
fontSize: 12,
|
|
|
@@ -1802,9 +1807,11 @@ function _Chat() {
|
|
|
height: 16,
|
|
|
} }
|
|
|
/>
|
|
|
- <span style={ { fontSize: 11, marginLeft: 5, marginRight: 10 } }>
|
|
|
- 联网搜索
|
|
|
- </span>
|
|
|
+ {!isMobileScreen && (
|
|
|
+ <span style={ { fontSize: 11, marginLeft: 5, marginRight: 10 } }>
|
|
|
+ 联网搜索
|
|
|
+ </span>
|
|
|
+ )}
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
@@ -1895,7 +1902,9 @@ function _Chat() {
|
|
|
alignItems: 'center',
|
|
|
cursor: 'pointer',
|
|
|
} }
|
|
|
- onClick={ () => {
|
|
|
+ onClick={ ( e ) => {
|
|
|
+ e.preventDefault();
|
|
|
+ e.stopPropagation();
|
|
|
if ( couldStop ) {
|
|
|
stopAll();
|
|
|
} else {
|
|
|
@@ -1917,9 +1926,11 @@ function _Chat() {
|
|
|
</div>
|
|
|
</label>
|
|
|
|
|
|
- <div style={ { marginTop: 8, textAlign: 'center', color: '#888888', fontSize: 12 } }>
|
|
|
- 内容由AI生成,仅供参考
|
|
|
- </div>
|
|
|
+
|
|
|
+ <div style={ { marginTop: 8, textAlign: 'center', color: '#888888', fontSize: 12 } }>
|
|
|
+ 内容由AI生成,仅供参考
|
|
|
+ </div>
|
|
|
+
|
|
|
</div>
|
|
|
{
|
|
|
showExport && (
|
|
|
@@ -1939,7 +1950,7 @@ function _Chat() {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
-export function Chat() {
|
|
|
+export function Chat(props?: { onMessageSent?: () => void }) {
|
|
|
const globalStore = useGlobalStore();
|
|
|
const chatStore = useChatStore();
|
|
|
const sessionIndex = chatStore.currentSessionIndex;
|
|
|
@@ -1950,5 +1961,5 @@ export function Chat() {
|
|
|
chatStore.setWebSearch( false );
|
|
|
}, [] );
|
|
|
|
|
|
- return <_Chat key={ sessionIndex }></_Chat>;
|
|
|
+ return <_Chat key={ sessionIndex } onMessageSent={props?.onMessageSent}></_Chat>;
|
|
|
}
|