Skip to content

Commit eefda56

Browse files
committed
chore: add note
1 parent a69d1fa commit eefda56

4 files changed

Lines changed: 12 additions & 6 deletions

File tree

src/App.css

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@
3535
color: var(--text1);
3636
outline: none;
3737
width: 100%;
38-
margin: 20px 0;
38+
margin-top: 20px;
39+
}
40+
41+
#comment-search-root dialog .note {
42+
color: var(--text3);
43+
margin: 10px 0;
3944
}
4045

4146
#comment-search-root dialog .comment-tree {

src/App.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useRef, useState } from 'react'
22
import Highlighter from 'react-highlight-words'
3-
import { fetchComments } from './api'
3+
import { PAGE_LIMIT, fetchComments } from './api'
44
import { Reply } from './types/reply'
55
import { extractVideoId, formatDateTime } from './utils'
66

@@ -51,6 +51,7 @@ export default function App() {
5151
}
5252
}}
5353
/>
54+
<div className='note'>Note: 由于性能和 Rate Limit 的原因,目前仅会加载 {PAGE_LIMIT} 页评论,即 {PAGE_LIMIT} * 49 条评论,及其至多 3 条子评论。</div>
5455
<div className='comment-tree'>
5556
<CommentTree comments={comments} />
5657
</div>

src/api.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { CommentDetailsResponse, CommentSort, CommentType } from './types/api'
22
import { Reply } from './types/reply'
3+
import { debug } from './utils'
34

45
// for performance and rate limit, we only fetch the first 20 pages
5-
const PAGE_LIMIT = 20
6+
export const PAGE_LIMIT = 20
67
const replies: Reply[] = []
78

89
export async function fetchComments(videoId: string) {
@@ -22,6 +23,7 @@ export async function fetchComments(videoId: string) {
2223
ps: pageSize.toString(),
2324
})
2425

26+
debug(`fetch comments: page ${page}`)
2527
const response = await fetch(
2628
`https://api.bilibili.com/x/v2/reply?${params}`
2729
)

src/utils.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ export function assertEl<T extends Element>(el: T | null) {
88
}
99

1010
export function debug(message: any) {
11-
if (import.meta.env.DEV) {
12-
console.log(`[${name}] ${message}`)
13-
}
11+
console.log(`[${name}] ${message}`)
1412
}
1513

1614
export function extractVideoId(url: string) {

0 commit comments

Comments
 (0)