-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearchVideos.tsx
56 lines (51 loc) · 1.55 KB
/
searchVideos.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { useSearchVideos } from "./hooks";
import { CheckLogin, Video } from "./components";
import { formatNumber, removeEmHTMLTag } from "./utils";
import { useState } from "react";
import { List } from "@raycast/api";
export default function Command() {
const [idx, setIdx] = useState(1);
const [keyword, setKeyword] = useState("apple");
const [countSet, setCountSet] = useState(new Set<string | undefined>([]));
const { videoResults, isLoading } = useSearchVideos(idx, keyword);
return (
<CheckLogin>
<List
onSearchTextChange={(text) => {
setKeyword(text);
setIdx(1);
}}
isLoading={isLoading}
isShowingDetail={true}
onSelectionChange={(id) => {
setCountSet(countSet.add(id || ""));
if (countSet.size % 20 === 0) setIdx(idx + 1);
}}
>
{videoResults?.map((item) => {
return (
<Video
title={removeEmHTMLTag(item.title)}
cover={item.pic}
url={item.arcurl}
bvid={item.bvid}
cid={item.cid}
uploader={{
mid: item.mid,
name: item.author,
face: item.upic,
}}
duration={item.duration}
pubdate={item.pubdate}
stat={{
view: formatNumber(item.play),
danmaku: formatNumber(item.danmaku),
like: formatNumber(item.like),
}}
/>
)
})}
</List>
</CheckLogin>
);
}