mirror of
https://github.com/Wanxp/obsidian-douban.git
synced 2026-04-04 16:48:44 +08:00
fix mac os search error
This commit is contained in:
parent
a5747c2f45
commit
d0ed8cf1f3
@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "obsidian-douban-plugin",
|
||||
"name": "Douban",
|
||||
"version": "2.0.5",
|
||||
"version": "2.0.6",
|
||||
"minAppVersion": "0.12.0",
|
||||
"description": "This is a plugin that can import movies/books/musics/notes/games info data from Douban for Obsidian .",
|
||||
"author": "Wanxp",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "obsidian-douban-plugin",
|
||||
"version": "2.0.5",
|
||||
"version": "2.0.6",
|
||||
"description": "This is a plugin for Obsidian (https://obsidian.md) that can import data from Douban (https://www.douban.com/).",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
||||
@ -5,6 +5,7 @@ import HttpUtil from "../../../../utils/HttpUtil";
|
||||
import {log} from "../../../../utils/Logutil";
|
||||
import {i18nHelper} from "../../../../lang/helper";
|
||||
import {DoubanHttpUtil} from "../../../../utils/DoubanHttpUtil";
|
||||
import {Platform} from "obsidian";
|
||||
|
||||
export abstract class AbstractSearchPageFetcher implements SearchPageFetcherInterface {
|
||||
|
||||
@ -19,7 +20,7 @@ export abstract class AbstractSearchPageFetcher implements SearchPageFetcherInte
|
||||
}
|
||||
fetch(keyword: string, pageNum: number, pageSize: number): Promise<string> {
|
||||
const start:number = (pageNum - 1) * pageSize;
|
||||
const url:string = this.getUrl(keyword, start, pageSize);
|
||||
const url:string = this.getSearchUrl(keyword, start, pageSize);
|
||||
if (!url) {
|
||||
return Promise.resolve("");
|
||||
}
|
||||
@ -28,8 +29,18 @@ export abstract class AbstractSearchPageFetcher implements SearchPageFetcherInte
|
||||
throw log.error(i18nHelper.getMessage('130101').replace('{0}', e.toString()), e);
|
||||
}); }
|
||||
|
||||
getSearchUrl(keyword: string, start: number, pageSize: number):string {
|
||||
keyword = keyword.trim();
|
||||
if (keyword.length == 0) {
|
||||
return "";
|
||||
}
|
||||
if (Platform.isMacOS) {
|
||||
keyword = HttpUtil.encodeUrl(keyword);
|
||||
}
|
||||
return this.getUrl(keyword, start, pageSize)
|
||||
}
|
||||
|
||||
abstract getUrl(keyword: string, start: number, pageSize: number):string;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -99,5 +99,14 @@ export default class HttpUtil {
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将字符进行url编码
|
||||
* @param keyword
|
||||
*/
|
||||
static encodeUrl(keyword: string) {
|
||||
if (!keyword) {
|
||||
return '';
|
||||
}
|
||||
return encodeURIComponent(keyword);
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,6 +50,6 @@
|
||||
"2.0.2": "0.12.0",
|
||||
"2.0.3": "0.12.0",
|
||||
"2.0.4": "0.12.0",
|
||||
"2.0.5": "0.12.0"
|
||||
|
||||
"2.0.5": "0.12.0",
|
||||
"2.0.6": "0.12.0"
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user