文件搜索优化

This commit is contained in:
yj 2024-08-20 14:48:49 +08:00
parent c568567b94
commit d020a62464
1 changed files with 7 additions and 18 deletions

View File

@ -41,7 +41,7 @@ const SharedFilesModel = forwardRef((props: any, ref: any) => {
let userInfo = JSON.parse(storage.getItem('user') as string) let userInfo = JSON.parse(storage.getItem('user') as string)
setUser(userInfo) setUser(userInfo)
getRoomFile() getRoomFile()
}, [fileList.pageIndex]); }, [fileList.pageIndex, fileList.keyword]);
// 获取共享文件列表 // 获取共享文件列表
const getRoomFile = async (): Promise<void> => { const getRoomFile = async (): Promise<void> => {
await GetRoomFile({ await GetRoomFile({
@ -95,30 +95,19 @@ const SharedFilesModel = forwardRef((props: any, ref: any) => {
style={{ width: '200px' }} style={{ width: '200px' }}
prefix={<SearchOutlined style={{ color: 'white' }} />} prefix={<SearchOutlined style={{ color: 'white' }} />}
onChange={(e) => { onChange={(e) => {
setFileList({
...fileList,
keyword: e.target.value
})
}}
onPressEnter={() => {
if (fileList.pageIndex === 1) { if (fileList.pageIndex === 1) {
getRoomFile() setFileList({
} else { ...fileList,
setFileList({ keyword: e.target.value,
...fileList, })
pageIndex: 1
})
}
}}
onBlur={() => {
if (fileList.pageIndex === 1) {
getRoomFile()
} else { } else {
setFileList({ setFileList({
...fileList, ...fileList,
keyword: e.target.value,
pageIndex: 1 pageIndex: 1
}) })
} }
}} }}
/> />
<ReloadOutlined title='刷新' onClick={() => { <ReloadOutlined title='刷新' onClick={() => {