mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-19 08:50:57 +00:00
[feature](webapp) upgrade chat version
This commit is contained in:
@@ -1,24 +1,44 @@
|
||||
import { Input } from 'antd';
|
||||
import styles from './style.module.less';
|
||||
import { useState } from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import ChatItem from '../components/ChatItem';
|
||||
import { queryContext, searchRecommend } from '../service';
|
||||
|
||||
const { Search } = Input;
|
||||
|
||||
const Chat = () => {
|
||||
const [data, setData] = useState<any>();
|
||||
const [inputMsg, setInputMsg] = useState('');
|
||||
const [msg, setMsg] = useState('');
|
||||
const [followQuestions, setFollowQuestions] = useState<string[]>([]);
|
||||
const [triggerResize, setTriggerResize] = useState(false);
|
||||
|
||||
const onWindowResize = () => {
|
||||
setTriggerResize(true);
|
||||
setTimeout(() => {
|
||||
setTriggerResize(false);
|
||||
}, 0);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
window.addEventListener('resize', onWindowResize);
|
||||
return () => {
|
||||
window.removeEventListener('resize', onWindowResize);
|
||||
};
|
||||
}, []);
|
||||
|
||||
const onInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const { value } = e.target;
|
||||
setInputMsg(value);
|
||||
searchRecommend(value);
|
||||
};
|
||||
|
||||
const onSearch = () => {
|
||||
setMsg(inputMsg);
|
||||
queryContext(inputMsg);
|
||||
};
|
||||
|
||||
const onMsgDataLoaded = (msgData: any) => {
|
||||
setData(msgData);
|
||||
setFollowQuestions(['测试1234测试', '测试1234测试', '测试1234测试']);
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -32,7 +52,15 @@ const Chat = () => {
|
||||
/>
|
||||
</div>
|
||||
<div className={styles.chatItem}>
|
||||
<ChatItem msg={msg} suggestionEnable isLastMessage />
|
||||
<ChatItem
|
||||
msg={msg}
|
||||
msgData={data}
|
||||
onMsgDataLoaded={onMsgDataLoaded}
|
||||
followQuestions={followQuestions}
|
||||
isLastMessage
|
||||
isMobileMode
|
||||
triggerResize={triggerResize}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
row-gap: 20px;
|
||||
padding: 30px;
|
||||
padding: 20px;
|
||||
background:
|
||||
linear-gradient(180deg,rgba(23,74,228,0) 29.44%,rgba(23,74,228,.06)),linear-gradient(90deg,#f3f3f7,#f3f3f7 20%,#ebf0f9 60%,#f3f3f7 80%,#f3f3f7);
|
||||
height: 100vh;
|
||||
|
||||
Reference in New Issue
Block a user