Unverified Commit 570c3e78 authored by Yeuoly's avatar Yeuoly

Merge remote-tracking branch 'origin/main' into feat/enterprise

parents fe2f3a0a b1e0db49
...@@ -9,6 +9,7 @@ import { ...@@ -9,6 +9,7 @@ import {
} from 'react' } from 'react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { useThrottleEffect } from 'ahooks' import { useThrottleEffect } from 'ahooks'
import { debounce } from 'lodash-es'
import type { import type {
ChatConfig, ChatConfig,
ChatItem, ChatItem,
...@@ -81,16 +82,24 @@ const Chat: FC<ChatProps> = ({ ...@@ -81,16 +82,24 @@ const Chat: FC<ChatProps> = ({
chatContainerRef.current.scrollTop = chatContainerRef.current.scrollHeight chatContainerRef.current.scrollTop = chatContainerRef.current.scrollHeight
} }
useThrottleEffect(() => { const handleWindowResize = () => {
handleScrolltoBottom()
if (chatContainerRef.current && chatFooterRef.current) if (chatContainerRef.current && chatFooterRef.current)
chatFooterRef.current.style.width = `${chatContainerRef.current.clientWidth}px` chatFooterRef.current.style.width = `${chatContainerRef.current.clientWidth}px`
if (chatContainerInnerRef.current && chatFooterInnerRef.current) if (chatContainerInnerRef.current && chatFooterInnerRef.current)
chatFooterInnerRef.current.style.width = `${chatContainerInnerRef.current.clientWidth}px` chatFooterInnerRef.current.style.width = `${chatContainerInnerRef.current.clientWidth}px`
}
useThrottleEffect(() => {
handleScrolltoBottom()
handleWindowResize()
}, [chatList], { wait: 500 }) }, [chatList], { wait: 500 })
useEffect(() => {
window.addEventListener('resize', debounce(handleWindowResize))
return () => window.removeEventListener('resize', handleWindowResize)
}, [])
useEffect(() => { useEffect(() => {
if (chatFooterRef.current && chatContainerRef.current) { if (chatFooterRef.current && chatContainerRef.current) {
const resizeObserver = new ResizeObserver((entries) => { const resizeObserver = new ResizeObserver((entries) => {
......
...@@ -71,8 +71,8 @@ Chat applications support session persistence, allowing previous chat history to ...@@ -71,8 +71,8 @@ Chat applications support session persistence, allowing previous chat history to
- `upload_file_id` (string) Uploaded file ID, which must be obtained by uploading through the File Upload API in advance (when the transfer method is `local_file`) - `upload_file_id` (string) Uploaded file ID, which must be obtained by uploading through the File Upload API in advance (when the transfer method is `local_file`)
</Property> </Property>
<Property name='auto_generate_name' type='bool' key='auto_generate_name'> <Property name='auto_generate_name' type='bool' key='auto_generate_name'>
Auto-generate title, default is `false`. Auto-generate title, default is `true`.
Can achieve async title generation by calling the conversation rename API and setting `auto_generate` to true. If set to `false`, can achieve async title generation by calling the conversation rename API and setting `auto_generate` to `true`.
</Property> </Property>
</Properties> </Properties>
......
...@@ -71,7 +71,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' ...@@ -71,7 +71,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'
- `upload_file_id` 上传文件 ID。(仅当传递方式为 `local_file `时)。 - `upload_file_id` 上传文件 ID。(仅当传递方式为 `local_file `时)。
</Property> </Property>
<Property name='auto_generate_name' type='bool' key='auto_generate_name'> <Property name='auto_generate_name' type='bool' key='auto_generate_name'>
(选填)自动生成标题,默认 `false`。 可通过调用会话重命名接口并设置 `auto_generate` 为 `true` 实现异步生成标题。 (选填)自动生成标题,默认 `true`。 若设置为 `false`,则可通过调用会话重命名接口并设置 `auto_generate` 为 `true` 实现异步生成标题。
</Property> </Property>
</Properties> </Properties>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment