Commit 6ecae01f authored by Chunchi Che's avatar Chunchi Che

support search

parent 6d3d6113
Pipeline #23646 passed with stages
in 14 minutes and 37 seconds
...@@ -47,6 +47,7 @@ export const WatchContent: React.FC = () => { ...@@ -47,6 +47,7 @@ export const WatchContent: React.FC = () => {
const [rooms, setRooms] = useState<Room[]>([]); const [rooms, setRooms] = useState<Room[]>([]);
const { message } = App.useApp(); const { message } = App.useApp();
const { watchID } = useSnapshot(watchStore); const { watchID } = useSnapshot(watchStore);
const [query, setQuery] = useState("");
// 暂时只支持竞技匹配的观战,TODO:后面需要加上娱乐匹配的支持 // 暂时只支持竞技匹配的观战,TODO:后面需要加上娱乐匹配的支持
const url = new URL(athleticWatchUrl); const url = new URL(athleticWatchUrl);
url.searchParams.set("filter", "started"); url.searchParams.set("filter", "started");
...@@ -103,16 +104,24 @@ export const WatchContent: React.FC = () => { ...@@ -103,16 +104,24 @@ export const WatchContent: React.FC = () => {
<div className={styles.search}> <div className={styles.search}>
<Input <Input
className={styles.input} className={styles.input}
placeholder="搜索房间" placeholder="通过玩家用户名搜索房间"
bordered={false} bordered={false}
suffix={<Button type="text" icon={<SearchOutlined />} />} suffix={<Button type="text" icon={<SearchOutlined />} />}
value={query}
onChange={(e) => setQuery(e.target.value)}
/> />
</div> </div>
<ScrollableArea maxHeight="50vh"> <ScrollableArea maxHeight="50vh">
{readyState === ReadyState.CONNECTING || rooms.length === 0 ? ( {readyState === ReadyState.CONNECTING || rooms.length === 0 ? (
<Empty /> <Empty />
) : ( ) : (
rooms.map((room) => ( rooms
.filter(
(room) =>
room.users?.at(0)?.username.includes(query) ||
room.users?.at(1)?.username.includes(query),
)
.map((room) => (
<div key={room.id}> <div key={room.id}>
<div <div
className={classNames(styles.item, { className={classNames(styles.item, {
......
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