mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-13 13:07:32 +00:00
first commit
This commit is contained in:
41
webapp/packages/chat-sdk/src/demo/Chat.tsx
Normal file
41
webapp/packages/chat-sdk/src/demo/Chat.tsx
Normal file
@@ -0,0 +1,41 @@
|
||||
import { Input } from 'antd';
|
||||
import styles from './style.module.less';
|
||||
import { useState } from 'react';
|
||||
import ChatItem from '../components/ChatItem';
|
||||
import { queryContext, searchRecommend } from '../service';
|
||||
|
||||
const { Search } = Input;
|
||||
|
||||
const Chat = () => {
|
||||
const [inputMsg, setInputMsg] = useState('');
|
||||
const [msg, setMsg] = useState('');
|
||||
|
||||
const onInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const { value } = e.target;
|
||||
setInputMsg(value);
|
||||
searchRecommend(value);
|
||||
};
|
||||
|
||||
const onSearch = () => {
|
||||
setMsg(inputMsg);
|
||||
queryContext(inputMsg);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={styles.page}>
|
||||
<div className={styles.inputMsg}>
|
||||
<Search
|
||||
placeholder="请输入问题"
|
||||
value={inputMsg}
|
||||
onChange={onInputChange}
|
||||
onSearch={onSearch}
|
||||
/>
|
||||
</div>
|
||||
<div className={styles.chatItem}>
|
||||
<ChatItem msg={msg} suggestionEnable isLastMessage />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Chat;
|
||||
Reference in New Issue
Block a user