mirror of
https://github.com/Wanxp/obsidian-douban.git
synced 2026-04-04 08:38:41 +08:00
25 lines
915 B
TypeScript
25 lines
915 B
TypeScript
import {SupportType} from "../../../../constant/Constsant";
|
|
import {SearchResultPageParserInterface} from "./SearchResultPageParserInterface";
|
|
import {SearchPage} from "../../model/SearchPage";
|
|
import SearchParserHandlerV2 from "../SearchParserV2";
|
|
|
|
export class AllFirstPageSearchResultPageParser implements SearchResultPageParserInterface {
|
|
support(type:SupportType, pageNum:number):boolean {
|
|
return pageNum == 1 && type == SupportType.ALL;
|
|
}
|
|
parse(source:string, type:SupportType, pageNum:number, pageSize:number):SearchPage {
|
|
const {subjects} = JSON.parse(source);
|
|
if (!subjects) {
|
|
return SearchPage.empty(type);
|
|
}
|
|
const {items} = subjects;
|
|
if (!items ||items.length == 0) {
|
|
return SearchPage.empty(type);
|
|
}
|
|
const doubanSearchResultSubjects = SearchParserHandlerV2.itemMapToSearchResult(items);
|
|
return new SearchPage(2000, pageNum, pageSize, type, doubanSearchResultSubjects);
|
|
}
|
|
|
|
|
|
}
|