mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-05-25 23:20:19 +09:00
feat: #326
This commit is contained in:
parent
3369532af9
commit
c6156a8d8a
@ -323,6 +323,7 @@
|
|||||||
border: none;
|
border: none;
|
||||||
outline: none;
|
outline: none;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
&-search-input:focus {
|
&-search-input:focus {
|
||||||
|
@ -503,14 +503,27 @@ export function SearchSelector<T>(props: {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const { items, onClose } = props;
|
||||||
// 过滤列表项
|
// 过滤列表项
|
||||||
const filteredItems = props.items.filter(
|
const filteredItems = items.filter(
|
||||||
(item) =>
|
(item) =>
|
||||||
item.title.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
item.title.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
||||||
(item.subTitle &&
|
(item.subTitle &&
|
||||||
item.subTitle.toLowerCase().includes(searchQuery.toLowerCase())),
|
item.subTitle.toLowerCase().includes(searchQuery.toLowerCase())),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const handleKeyDown = (event: KeyboardEvent) => {
|
||||||
|
if (event.key === "Escape") {
|
||||||
|
onClose?.();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
document.addEventListener("keydown", handleKeyDown);
|
||||||
|
return () => {
|
||||||
|
document.removeEventListener("keydown", handleKeyDown);
|
||||||
|
};
|
||||||
|
}, [onClose]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles["selector"]} onClick={() => props.onClose?.()}>
|
<div className={styles["selector"]} onClick={() => props.onClose?.()}>
|
||||||
<div
|
<div
|
||||||
@ -522,6 +535,7 @@ export function SearchSelector<T>(props: {
|
|||||||
<div className={styles["selector-search"]}>
|
<div className={styles["selector-search"]}>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
|
autoFocus
|
||||||
className={styles["selector-search-input"]}
|
className={styles["selector-search-input"]}
|
||||||
placeholder="search model"
|
placeholder="search model"
|
||||||
value={searchQuery}
|
value={searchQuery}
|
||||||
|
Loading…
Reference in New Issue
Block a user