File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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 {
Original file line number Diff line number Diff line change 11import { useRef , useState } from 'react'
22import Highlighter from 'react-highlight-words'
3- import { fetchComments } from './api'
3+ import { PAGE_LIMIT , fetchComments } from './api'
44import { Reply } from './types/reply'
55import { 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 >
Original file line number Diff line number Diff line change 11import { CommentDetailsResponse , CommentSort , CommentType } from './types/api'
22import { 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
67const replies : Reply [ ] = [ ]
78
89export 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 )
Original file line number Diff line number Diff line change @@ -8,9 +8,7 @@ export function assertEl<T extends Element>(el: T | null) {
88}
99
1010export function debug ( message : any ) {
11- if ( import . meta. env . DEV ) {
12- console . log ( `[${ name } ] ${ message } ` )
13- }
11+ console . log ( `[${ name } ] ${ message } ` )
1412}
1513
1614export function extractVideoId ( url : string ) {
You can’t perform that action at this time.
0 commit comments