列表不会带动搜索框转

This commit is contained in:
CrescentLeaf
2025-11-23 12:34:18 +08:00
parent 2cf9a20910
commit f13623f4fc
2 changed files with 90 additions and 75 deletions

View File

@@ -7,6 +7,7 @@ import data from "../../Data.ts"
import { checkApiSuccessOrSncakbar, snackbar } from "../snackbar.ts" import { checkApiSuccessOrSncakbar, snackbar } from "../snackbar.ts"
import Chat from "../../api/client_data/Chat.ts" import Chat from "../../api/client_data/Chat.ts"
import EventBus from "../../EventBus.ts" import EventBus from "../../EventBus.ts"
import isMobileUI from "../isMobileUI.ts";
interface Args extends React.HTMLAttributes<HTMLElement> { interface Args extends React.HTMLAttributes<HTMLElement> {
display: boolean display: boolean
@@ -14,6 +15,7 @@ interface Args extends React.HTMLAttributes<HTMLElement> {
addContactDialogRef: React.MutableRefObject<Dialog> addContactDialogRef: React.MutableRefObject<Dialog>
createGroupDialogRef: React.MutableRefObject<Dialog> createGroupDialogRef: React.MutableRefObject<Dialog>
setSharedFavouriteChats: React.Dispatch<React.SetStateAction<Chat[]>> setSharedFavouriteChats: React.Dispatch<React.SetStateAction<Chat[]>>
currentChatId: string
} }
export default function ContactsList({ export default function ContactsList({
@@ -22,6 +24,7 @@ export default function ContactsList({
addContactDialogRef, addContactDialogRef,
createGroupDialogRef, createGroupDialogRef,
setSharedFavouriteChats, setSharedFavouriteChats,
currentChatId,
...props ...props
}: Args) { }: Args) {
const searchRef = React.useRef<HTMLElement>(null) const searchRef = React.useRef<HTMLElement>(null)
@@ -63,20 +66,21 @@ export default function ContactsList({
height: '100%', height: '100%',
width: '100%', width: '100%',
}} {...props}> }} {...props}>
<div style={{
position: 'sticky',
top: '0',
backgroundColor: 'rgb(var(--mdui-color-background))',
zIndex: '10',
}}>
<mdui-text-field icon="search" type="search" clearable ref={searchRef} variant="outlined" placeholder="搜索..." style={{ <mdui-text-field icon="search" type="search" clearable ref={searchRef} variant="outlined" placeholder="搜索..." style={{
marginTop: '5px', marginTop: '5px',
}}></mdui-text-field> }}></mdui-text-field>
<mdui-list-item rounded style={{ <mdui-list-item rounded style={{
width: '100%',
marginTop: '13px', marginTop: '13px',
}} icon="person_add" onClick={() => addContactDialogRef.current!.open = true}></mdui-list-item> width: '100%',
}} icon="person_add" onClick={() => addContactDialogRef.current!.open = true}></mdui-list-item>
<mdui-list-item rounded style={{ <mdui-list-item rounded style={{
width: '100%', width: '100%',
}} icon="group_add" onClick={() => createGroupDialogRef.current!.open = true}></mdui-list-item>
<mdui-list-item rounded style={{
width: '100%',
marginTop: '13px',
}} icon="refresh" onClick={() => EventBus.emit('ContactsList.updateContacts')}></mdui-list-item> }} icon="refresh" onClick={() => EventBus.emit('ContactsList.updateContacts')}></mdui-list-item>
<mdui-list-item rounded style={{ <mdui-list-item rounded style={{
width: '100%', width: '100%',
@@ -92,6 +96,8 @@ export default function ContactsList({
}} icon="delete" onClick={() => dialog({ }} icon="delete" onClick={() => dialog({
headline: "删除所选", headline: "删除所选",
description: "确定要删除所选的收藏对话吗? 这并不会删除您的聊天记录, 也不会丢失对话成员身份", description: "确定要删除所选的收藏对话吗? 这并不会删除您的聊天记录, 也不会丢失对话成员身份",
closeOnEsc: true,
closeOnOverlayClick: true,
actions: [ actions: [
{ {
text: "取消", text: "取消",
@@ -137,6 +143,7 @@ export default function ContactsList({
<div style={{ <div style={{
height: "15px", height: "15px",
}}></div> }}></div>
</div>
{ {
contactsList.filter((chat) => contactsList.filter((chat) =>
@@ -145,7 +152,7 @@ export default function ContactsList({
chat.id.includes(searchText) chat.id.includes(searchText)
).map((v) => ).map((v) =>
<ContactsListItem <ContactsListItem
active={checkedList[v.id] == true} active={isMultiSelecting ? checkedList[v.id] == true : (isMobileUI() ? false : currentChatId == v.id)}
onClick={() => { onClick={() => {
if (isMultiSelecting) if (isMultiSelecting)
setCheckedList({ setCheckedList({

View File

@@ -44,7 +44,11 @@ export default function RecentsList({
} }
updateRecents() updateRecents()
EventBus.on('RecentsList.updateRecents', () => updateRecents()) EventBus.on('RecentsList.updateRecents', () => updateRecents())
setTimeout(() => updateRecents(), 15 * 1000) const id = setInterval(() => updateRecents(), 15 * 1000)
return () => {
EventBus.off('RecentsList.updateRecents')
clearInterval(id)
}
}) })
return <mdui-list style={{ return <mdui-list style={{
@@ -58,6 +62,10 @@ export default function RecentsList({
<mdui-text-field icon="search" type="search" clearable ref={searchRef} variant="outlined" placeholder="搜索..." style={{ <mdui-text-field icon="search" type="search" clearable ref={searchRef} variant="outlined" placeholder="搜索..." style={{
marginTop: '5px', marginTop: '5px',
marginBottom: '13px', marginBottom: '13px',
position: 'sticky',
top: '0',
backgroundColor: 'rgb(var(--mdui-color-background))',
zIndex: '10',
}}></mdui-text-field> }}></mdui-text-field>
{ {
recentsList.filter((chat) => recentsList.filter((chat) =>