mirror of
https://github.com/Wanxp/obsidian-douban.git
synced 2026-04-04 08:38:41 +08:00
1. 增加游戏同步功能 2. 修复自定义参数配置问题 3. 增加搜索默认类型 4. 增加全部搜索为空时的提示
This commit is contained in:
parent
a7b81bd189
commit
c09f96d3b8
@ -101,15 +101,34 @@ export enum TemplateKey {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export enum SupportType {
|
export enum SupportType {
|
||||||
ALL = "all",
|
all = "all",
|
||||||
MOVIE = 'movie',
|
movie = 'movie',
|
||||||
BOOK = 'book',
|
book = 'book',
|
||||||
MUSIC = 'music',
|
music = 'music',
|
||||||
NOTE = 'note',
|
note = 'note',
|
||||||
GAME = 'game',
|
game = 'game',
|
||||||
TELEPLAY = 'teleplay',
|
teleplay = 'teleplay',
|
||||||
THEATER = 'theater',
|
theater = 'theater',
|
||||||
}
|
}
|
||||||
|
export const SupportTypeMap:object = {
|
||||||
|
"all": SupportType.all,
|
||||||
|
"movie": SupportType.movie,
|
||||||
|
"book": SupportType.book,
|
||||||
|
"music": SupportType.music,
|
||||||
|
"note": SupportType.note,
|
||||||
|
"game": SupportType.game,
|
||||||
|
"teleplay": SupportType.teleplay,
|
||||||
|
"theater": SupportType.theater,
|
||||||
|
"ALL": SupportType.all,
|
||||||
|
"MOVIE": SupportType.movie,
|
||||||
|
"BOOK": SupportType.book,
|
||||||
|
"MUSIC": SupportType.music,
|
||||||
|
"NOTE": SupportType.note,
|
||||||
|
"GAME": SupportType.game,
|
||||||
|
"TELEPLAY": SupportType.teleplay,
|
||||||
|
"THEATER": SupportType.theater,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export enum PropertyName {
|
export enum PropertyName {
|
||||||
//base
|
//base
|
||||||
@ -183,12 +202,12 @@ export enum PropertyName {
|
|||||||
*/
|
*/
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
export const SearchTypeRecords: { [key in SupportType]: string } = {
|
export const SearchTypeRecords: { [key in SupportType]: string } = {
|
||||||
[SupportType.ALL]: i18nHelper.getMessage('ALL'),
|
[SupportType.all]: i18nHelper.getMessage('ALL'),
|
||||||
[SupportType.MOVIE]: i18nHelper.getMessage('MOVIE_AND_TELEPLAY'),
|
[SupportType.movie]: i18nHelper.getMessage('MOVIE_AND_TELEPLAY'),
|
||||||
[SupportType.BOOK]: i18nHelper.getMessage('BOOK'),
|
[SupportType.book]: i18nHelper.getMessage('BOOK'),
|
||||||
[SupportType.MUSIC]: i18nHelper.getMessage('MUSIC'),
|
[SupportType.music]: i18nHelper.getMessage('MUSIC'),
|
||||||
[SupportType.NOTE]: i18nHelper.getMessage('NOTE'),
|
[SupportType.note]: i18nHelper.getMessage('NOTE'),
|
||||||
[SupportType.GAME]: i18nHelper.getMessage('GAME'),
|
[SupportType.game]: i18nHelper.getMessage('GAME'),
|
||||||
// [SupportType.THEATER]: i18nHelper.getMessage('THEATER'),
|
// [SupportType.THEATER]: i18nHelper.getMessage('THEATER'),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,7 +252,7 @@ export const SyncTypeRecords: { [key in SyncType | string]: string } = {
|
|||||||
// [SyncType.broadcast]: i18nHelper.getMessage('504104'),
|
// [SyncType.broadcast]: i18nHelper.getMessage('504104'),
|
||||||
// [SyncType.note]: i18nHelper.getMessage('504105'),
|
// [SyncType.note]: i18nHelper.getMessage('504105'),
|
||||||
[SyncType.music]: i18nHelper.getMessage('504106'),
|
[SyncType.music]: i18nHelper.getMessage('504106'),
|
||||||
// [SyncType.game]: i18nHelper.getMessage('504108'),
|
[SyncType.game]: i18nHelper.getMessage('504108'),
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -376,13 +395,13 @@ sec-ch-ua-platform: "Windows"
|
|||||||
export const ONLINE_SETTING_DEFAULT: DoubanPluginOnlineSettings = {
|
export const ONLINE_SETTING_DEFAULT: DoubanPluginOnlineSettings = {
|
||||||
properties: [
|
properties: [
|
||||||
{
|
{
|
||||||
type: SupportType.BOOK,
|
type: SupportType.book,
|
||||||
name: PropertyName.comment,
|
name: PropertyName.comment,
|
||||||
selectors: ['#interest_sect_level > div > span:nth-child(7)'
|
selectors: ['#interest_sect_level > div > span:nth-child(7)'
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: SupportType.MOVIE,
|
type: SupportType.movie,
|
||||||
name: PropertyName.comment,
|
name: PropertyName.comment,
|
||||||
selectors: ['#interest_sect_level > div > span:nth-child(8)',
|
selectors: ['#interest_sect_level > div > span:nth-child(8)',
|
||||||
'#interest_sect_level > div > span:nth-child(7)',
|
'#interest_sect_level > div > span:nth-child(7)',
|
||||||
@ -497,4 +516,35 @@ export const SyncConditionTypeRecords: { [key in SyncConditionType|string]: stri
|
|||||||
[SyncConditionType.CUSTOM_ITEM]: i18nHelper.getMessage('110076'),
|
[SyncConditionType.CUSTOM_ITEM]: i18nHelper.getMessage('110076'),
|
||||||
[SyncConditionType.CUSTOM_TIME]: i18nHelper.getMessage('110074'),
|
[SyncConditionType.CUSTOM_TIME]: i18nHelper.getMessage('110074'),
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const DoubanSearchResultSubject_EMPTY: DoubanSearchResultSubject = {
|
||||||
|
id: '',
|
||||||
|
title: i18nHelper.getMessage('150107'),
|
||||||
|
score: null,
|
||||||
|
cast: '',
|
||||||
|
type: 'navigate',
|
||||||
|
desc: '-',
|
||||||
|
url: 'https://www.douban.com',
|
||||||
|
image: "",
|
||||||
|
imageUrl: "",
|
||||||
|
publisher: "",
|
||||||
|
datePublished: undefined,
|
||||||
|
genre: []
|
||||||
|
};
|
||||||
|
|
||||||
|
export const DoubanSearchResultSubject_TIP_EMPTY: DoubanSearchResultSubject = {
|
||||||
|
id: '',
|
||||||
|
title: i18nHelper.getMessage('150108'),
|
||||||
|
score: null,
|
||||||
|
cast: '',
|
||||||
|
type: 'navigate',
|
||||||
|
desc: '-',
|
||||||
|
url: 'https://www.douban.com',
|
||||||
|
image: "",
|
||||||
|
imageUrl: "",
|
||||||
|
publisher: "",
|
||||||
|
datePublished: undefined,
|
||||||
|
genre: []
|
||||||
|
};
|
||||||
@ -38,12 +38,12 @@ export const DEFAULT_SETTINGS: DoubanPluginSetting = {
|
|||||||
statusBar: true,
|
statusBar: true,
|
||||||
debugMode: false,
|
debugMode: false,
|
||||||
customProperties: [
|
customProperties: [
|
||||||
{name: 'myType', value: 'movie', field: SupportType.MOVIE},
|
{name: 'myType', value: 'movie', field: SupportType.movie},
|
||||||
{name: 'myType', value: 'book', field: SupportType.BOOK},
|
{name: 'myType', value: 'book', field: SupportType.book},
|
||||||
{name: 'myType', value: 'music', field: SupportType.MUSIC},
|
{name: 'myType', value: 'music', field: SupportType.music},
|
||||||
{name: 'myType', value: 'note', field: SupportType.NOTE},
|
{name: 'myType', value: 'note', field: SupportType.note},
|
||||||
{name: 'myType', value: 'game', field: SupportType.GAME},
|
{name: 'myType', value: 'game', field: SupportType.game},
|
||||||
{name: 'myType', value: 'teleplay', field: SupportType.TELEPLAY},
|
{name: 'myType', value: 'teleplay', field: SupportType.teleplay},
|
||||||
],
|
],
|
||||||
loginCookiesContent: '',
|
loginCookiesContent: '',
|
||||||
loginHeadersContent: '',
|
loginHeadersContent: '',
|
||||||
@ -57,7 +57,8 @@ export const DEFAULT_SETTINGS: DoubanPluginSetting = {
|
|||||||
starEmpty: '☆',
|
starEmpty: '☆',
|
||||||
displayStarEmpty: false,
|
displayStarEmpty: false,
|
||||||
maxStar: 5,
|
maxStar: 5,
|
||||||
}
|
},
|
||||||
|
searchDefaultType: SupportType.all,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -66,14 +66,14 @@ export const DoubanSubjectStateRecords_THEATER: { [key in DoubanSubjectState]: s
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const DoubanSubjectStateRecords: { [key in SupportType]: Record<DoubanSubjectState, string> } = {
|
export const DoubanSubjectStateRecords: { [key in SupportType]: Record<DoubanSubjectState, string> } = {
|
||||||
[SupportType.ALL]:DoubanSubjectStateRecords_ALL,
|
[SupportType.all]:DoubanSubjectStateRecords_ALL,
|
||||||
[SupportType.MOVIE]:DoubanSubjectStateRecords_MOVIE,
|
[SupportType.movie]:DoubanSubjectStateRecords_MOVIE,
|
||||||
[SupportType.BOOK]:DoubanSubjectStateRecords_BOOK,
|
[SupportType.book]:DoubanSubjectStateRecords_BOOK,
|
||||||
[SupportType.MUSIC]:DoubanSubjectStateRecords_MUSIC,
|
[SupportType.music]:DoubanSubjectStateRecords_MUSIC,
|
||||||
[SupportType.NOTE]:DoubanSubjectStateRecords_NOTE,
|
[SupportType.note]:DoubanSubjectStateRecords_NOTE,
|
||||||
[SupportType.GAME]:DoubanSubjectStateRecords_GAME,
|
[SupportType.game]:DoubanSubjectStateRecords_GAME,
|
||||||
[SupportType.TELEPLAY]:DoubanSubjectStateRecords_TELEPLAY,
|
[SupportType.teleplay]:DoubanSubjectStateRecords_TELEPLAY,
|
||||||
[SupportType.THEATER]:DoubanSubjectStateRecords_THEATER,
|
[SupportType.theater]:DoubanSubjectStateRecords_THEATER,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ export const DoubanSubjectStateRecords_BOOK_SYNC: { [key in DoubanSubjectState]:
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
export const DoubanSubjectStateRecords_GAME_SYNC: { [key in DoubanSubjectState]: string } = {
|
export const DoubanSubjectStateRecords_GAME_SYNC: { [key in DoubanSubjectState]: string } = {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
[ALL]: i18nHelper.getMessage('500004'),
|
// [ALL]: i18nHelper.getMessage('500004'),
|
||||||
[DoubanSubjectState.wish]: i18nHelper.getMessage('500602'),
|
[DoubanSubjectState.wish]: i18nHelper.getMessage('500602'),
|
||||||
[DoubanSubjectState.do]: i18nHelper.getMessage('500603'),
|
[DoubanSubjectState.do]: i18nHelper.getMessage('500603'),
|
||||||
[DoubanSubjectState.collect]: i18nHelper.getMessage('500604'),
|
[DoubanSubjectState.collect]: i18nHelper.getMessage('500604'),
|
||||||
@ -146,32 +146,32 @@ export const DoubanSubjectStateRecords_SYNC: { [key in SyncType]: Record<DoubanS
|
|||||||
|
|
||||||
|
|
||||||
export const DoubanSubjectStateRecords_KEY_WORD_TYPE: Map<string, SupportType> = new Map<string, SupportType> (
|
export const DoubanSubjectStateRecords_KEY_WORD_TYPE: Map<string, SupportType> = new Map<string, SupportType> (
|
||||||
[['我看过这部电视剧', SupportType.TELEPLAY],
|
[['我看过这部电视剧', SupportType.teleplay],
|
||||||
['我最近看过这部电视剧', SupportType.TELEPLAY],
|
['我最近看过这部电视剧', SupportType.teleplay],
|
||||||
['我想看这部电视剧', SupportType.TELEPLAY],
|
['我想看这部电视剧', SupportType.teleplay],
|
||||||
['我在看这部电视剧', SupportType.TELEPLAY],
|
['我在看这部电视剧', SupportType.teleplay],
|
||||||
['我最近在看这部电视剧', SupportType.TELEPLAY],
|
['我最近在看这部电视剧', SupportType.teleplay],
|
||||||
|
|
||||||
['我最近看过这部电影', SupportType.MOVIE],
|
['我最近看过这部电影', SupportType.movie],
|
||||||
['我看过这部电影', SupportType.MOVIE],
|
['我看过这部电影', SupportType.movie],
|
||||||
['我想看这部电影', SupportType.MOVIE],
|
['我想看这部电影', SupportType.movie],
|
||||||
|
|
||||||
['我读过这本书', SupportType.BOOK],
|
['我读过这本书', SupportType.book],
|
||||||
['我想读这本书', SupportType.BOOK],
|
['我想读这本书', SupportType.book],
|
||||||
['我在读这本书', SupportType.BOOK],
|
['我在读这本书', SupportType.book],
|
||||||
['我最近在读这本书', SupportType.BOOK],
|
['我最近在读这本书', SupportType.book],
|
||||||
|
|
||||||
['我最近听过这张唱片', SupportType.MUSIC],
|
['我最近听过这张唱片', SupportType.music],
|
||||||
['我听过这张唱片', SupportType.MUSIC],
|
['我听过这张唱片', SupportType.music],
|
||||||
['我想听这张唱片', SupportType.MUSIC],
|
['我想听这张唱片', SupportType.music],
|
||||||
['我在听这张唱片', SupportType.MUSIC],
|
['我在听这张唱片', SupportType.music],
|
||||||
['我最近在听这张唱片', SupportType.MUSIC],
|
['我最近在听这张唱片', SupportType.music],
|
||||||
|
|
||||||
['我最近玩过这个游戏', SupportType.GAME],
|
['我最近玩过这个游戏', SupportType.game],
|
||||||
['我玩过这个游戏', SupportType.GAME],
|
['我玩过这个游戏', SupportType.game],
|
||||||
['我想玩这个游戏', SupportType.GAME],
|
['我想玩这个游戏', SupportType.game],
|
||||||
['我在玩这个游戏', SupportType.GAME],
|
['我在玩这个游戏', SupportType.game],
|
||||||
['我最近在玩这个游戏', SupportType.GAME],]
|
['我最近在玩这个游戏', SupportType.game],]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -235,6 +235,7 @@ ${syncStatus.getHandle() == 0? '...' : i18nHelper.getMessage('110042') + ':' + T
|
|||||||
this.showScopeDropdown(contentEl, DoubanSubjectStateRecords_TELEPLAY_SYNC, config, disable);
|
this.showScopeDropdown(contentEl, DoubanSubjectStateRecords_TELEPLAY_SYNC, config, disable);
|
||||||
break;
|
break;
|
||||||
case SyncType.game:
|
case SyncType.game:
|
||||||
|
config.scope = DoubanSubjectState.collect;
|
||||||
this.showScopeDropdown(contentEl, DoubanSubjectStateRecords_GAME_SYNC, config, disable);
|
this.showScopeDropdown(contentEl, DoubanSubjectStateRecords_GAME_SYNC, config, disable);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -389,22 +389,22 @@ export default abstract class DoubanAbstractLoadHandler<T extends DoubanSubject>
|
|||||||
private getTemplateKey():TemplateKey {
|
private getTemplateKey():TemplateKey {
|
||||||
let templateKey: TemplateKey;
|
let templateKey: TemplateKey;
|
||||||
switch (this.getSupportType()) {
|
switch (this.getSupportType()) {
|
||||||
case SupportType.MOVIE:
|
case SupportType.movie:
|
||||||
templateKey = TemplateKey.movieTemplateFile;
|
templateKey = TemplateKey.movieTemplateFile;
|
||||||
break;
|
break;
|
||||||
case SupportType.BOOK:
|
case SupportType.book:
|
||||||
templateKey = TemplateKey.bookTemplateFile;
|
templateKey = TemplateKey.bookTemplateFile;
|
||||||
break;
|
break;
|
||||||
case SupportType.MUSIC:
|
case SupportType.music:
|
||||||
templateKey = TemplateKey.musicTemplateFile;
|
templateKey = TemplateKey.musicTemplateFile;
|
||||||
break;
|
break;
|
||||||
case SupportType.TELEPLAY:
|
case SupportType.teleplay:
|
||||||
templateKey = TemplateKey.teleplayTemplateFile;
|
templateKey = TemplateKey.teleplayTemplateFile;
|
||||||
break;
|
break;
|
||||||
case SupportType.GAME:
|
case SupportType.game:
|
||||||
templateKey = TemplateKey.gameTemplateFile;
|
templateKey = TemplateKey.gameTemplateFile;
|
||||||
break;
|
break;
|
||||||
case SupportType.NOTE:
|
case SupportType.note:
|
||||||
templateKey = TemplateKey.noteTemplateFile;
|
templateKey = TemplateKey.noteTemplateFile;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@ -17,7 +17,7 @@ export default class DoubanBookLoadHandler extends DoubanAbstractLoadHandler<Dou
|
|||||||
}
|
}
|
||||||
|
|
||||||
getSupportType(): SupportType {
|
getSupportType(): SupportType {
|
||||||
return SupportType.BOOK;
|
return SupportType.book;
|
||||||
}
|
}
|
||||||
|
|
||||||
getHighQuantityImageUrl(fileName:string):string{
|
getHighQuantityImageUrl(fileName:string):string{
|
||||||
|
|||||||
@ -17,7 +17,7 @@ export default class DoubanGameLoadHandler extends DoubanAbstractLoadHandler<Dou
|
|||||||
}
|
}
|
||||||
|
|
||||||
getSupportType(): SupportType {
|
getSupportType(): SupportType {
|
||||||
return SupportType.GAME;
|
return SupportType.game;
|
||||||
}
|
}
|
||||||
getHighQuantityImageUrl(fileName:string):string{
|
getHighQuantityImageUrl(fileName:string):string{
|
||||||
return `https://img9.doubanio.com/lpic/${fileName}`;
|
return `https://img9.doubanio.com/lpic/${fileName}`;
|
||||||
|
|||||||
@ -19,7 +19,7 @@ export default class DoubanMovieLoadHandler extends DoubanAbstractLoadHandler<Do
|
|||||||
}
|
}
|
||||||
|
|
||||||
getSupportType(): SupportType {
|
getSupportType(): SupportType {
|
||||||
return SupportType.MOVIE;
|
return SupportType.movie;
|
||||||
}
|
}
|
||||||
|
|
||||||
getHighQuantityImageUrl(fileName:string):string{
|
getHighQuantityImageUrl(fileName:string):string{
|
||||||
|
|||||||
@ -16,7 +16,7 @@ export default class DoubanMusicLoadHandler extends DoubanAbstractLoadHandler<Do
|
|||||||
}
|
}
|
||||||
|
|
||||||
getSupportType(): SupportType {
|
getSupportType(): SupportType {
|
||||||
return SupportType.MUSIC;
|
return SupportType.music;
|
||||||
}
|
}
|
||||||
|
|
||||||
getHighQuantityImageUrl(fileName:string):string{
|
getHighQuantityImageUrl(fileName:string):string{
|
||||||
|
|||||||
@ -16,7 +16,7 @@ export default class DoubanNoteLoadHandler extends DoubanAbstractLoadHandler<Dou
|
|||||||
}
|
}
|
||||||
|
|
||||||
getSupportType(): SupportType {
|
getSupportType(): SupportType {
|
||||||
return SupportType.NOTE;
|
return SupportType.note;
|
||||||
}
|
}
|
||||||
|
|
||||||
getHighQuantityImageUrl(fileName:string):string{
|
getHighQuantityImageUrl(fileName:string):string{
|
||||||
|
|||||||
@ -12,8 +12,8 @@ import {DataField} from "../../../utils/model/DataField";
|
|||||||
* 默认的处理器
|
* 默认的处理器
|
||||||
*/
|
*/
|
||||||
export default class DoubanOtherLoadHandler extends DoubanAbstractLoadHandler<DoubanSubject> {
|
export default class DoubanOtherLoadHandler extends DoubanAbstractLoadHandler<DoubanSubject> {
|
||||||
getSupportType(): SupportType.ALL {
|
getSupportType(): SupportType.all {
|
||||||
return SupportType.ALL;
|
return SupportType.all;
|
||||||
}
|
}
|
||||||
|
|
||||||
parseVariable(beforeContent: string, variableMap:Map<string, DataField>, extract: DoubanSubject, context: HandleContext): void {
|
parseVariable(beforeContent: string, variableMap:Map<string, DataField>, extract: DoubanSubject, context: HandleContext): void {
|
||||||
|
|||||||
@ -21,7 +21,7 @@ export class DoubanTeleplayLoadHandler extends DoubanAbstractLoadHandler<DoubanT
|
|||||||
}
|
}
|
||||||
|
|
||||||
getSupportType(): SupportType {
|
getSupportType(): SupportType {
|
||||||
return SupportType.TELEPLAY;
|
return SupportType.teleplay;
|
||||||
}
|
}
|
||||||
|
|
||||||
parseVariable(beforeContent: string, variableMap:Map<string, DataField>, extract: DoubanTeleplaySubject, context: HandleContext): void {
|
parseVariable(beforeContent: string, variableMap:Map<string, DataField>, extract: DoubanTeleplaySubject, context: HandleContext): void {
|
||||||
|
|||||||
@ -17,7 +17,7 @@ export default class DoubanTheaterLoadHandler extends DoubanAbstractLoadHandler<
|
|||||||
}
|
}
|
||||||
|
|
||||||
getSupportType(): SupportType {
|
getSupportType(): SupportType {
|
||||||
return SupportType.THEATER;
|
return SupportType.theater;
|
||||||
}
|
}
|
||||||
|
|
||||||
getHighQuantityImageUrl(fileName: string): string {
|
getHighQuantityImageUrl(fileName: string): string {
|
||||||
|
|||||||
@ -5,10 +5,10 @@ import {SearchPageTypeOf} from "./SearchPageTypeOf";
|
|||||||
export class SearchPage extends SearchPageTypeOf<any> {
|
export class SearchPage extends SearchPageTypeOf<any> {
|
||||||
|
|
||||||
public static empty(type: SupportType): SearchPage {
|
public static empty(type: SupportType): SearchPage {
|
||||||
return new SearchPage(0, 0, 0, type, []);
|
return new SearchPage(0, 1, 0, type, []);
|
||||||
}
|
}
|
||||||
|
|
||||||
static emptyWithNoType() {
|
static emptyWithNoType() {
|
||||||
return new SearchPage(0, 0, 0, null, []);
|
return new SearchPage(0, 1, 0, null, []);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -77,7 +77,7 @@ export class SearchPageInfo {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
return new SearchPageInfo(this.total, this._pageNum - 1,
|
return new SearchPageInfo(this.total, this._pageNum - 1,
|
||||||
this._pageSize, SupportType.ALL);
|
this._pageSize, SupportType.all);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -20,10 +20,10 @@ export class SearchPageTypeOf<T> extends SearchPageInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static empty(type: SupportType): SearchPageTypeOf<any> {
|
public static empty(type: SupportType): SearchPageTypeOf<any> {
|
||||||
return new SearchPageTypeOf(0, 0, 0, type, []);
|
return new SearchPageTypeOf(0, 1, 0, type, []);
|
||||||
}
|
}
|
||||||
|
|
||||||
static emptyWithNoType() {
|
static emptyWithNoType() {
|
||||||
return new SearchPageTypeOf(0, 0, 0, null, []);
|
return new SearchPageTypeOf(0, 1, 0, null, []);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,13 @@
|
|||||||
import {
|
import {
|
||||||
DoubanSearchGroupPublishResultSubjectNextPage, DoubanSearchGroupPublishResultSubjectPreviousPage,
|
DoubanSearchGroupPublishResultSubjectNextPage,
|
||||||
|
DoubanSearchGroupPublishResultSubjectPreviousPage,
|
||||||
|
DoubanSearchResultSubject_EMPTY, DoubanSearchResultSubject_TIP_EMPTY,
|
||||||
DoubanSearchResultSubjectNextPage,
|
DoubanSearchResultSubjectNextPage,
|
||||||
DoubanSearchResultSubjectNextPageNeedLogin,
|
DoubanSearchResultSubjectNextPageNeedLogin,
|
||||||
DoubanSearchResultSubjectPreviousPage,
|
DoubanSearchResultSubjectPreviousPage,
|
||||||
NavigateType, SEARCH_ITEM_PAGE_SIZE, SupportType
|
NavigateType,
|
||||||
|
SEARCH_ITEM_PAGE_SIZE,
|
||||||
|
SupportType
|
||||||
} from "../../../constant/Constsant";
|
} from "../../../constant/Constsant";
|
||||||
import {FuzzySuggestModal, RequestUrlParam, request} from "obsidian";
|
import {FuzzySuggestModal, RequestUrlParam, request} from "obsidian";
|
||||||
|
|
||||||
@ -106,9 +110,18 @@ class DoubanFuzzySuggester extends FuzzySuggestModal<DoubanSearchResultSubject>
|
|||||||
|
|
||||||
private initItems(searchPage: SearchPage) {
|
private initItems(searchPage: SearchPage) {
|
||||||
const doubanList: DoubanSearchResultSubject[] = searchPage.list;
|
const doubanList: DoubanSearchResultSubject[] = searchPage.list;
|
||||||
|
|
||||||
|
if (searchPage.type == SupportType.all && searchPage.pageNum == 1) {
|
||||||
|
if (doubanList.length == 0) {
|
||||||
|
// if (searchPage.list.length > 0) {
|
||||||
|
doubanList.push(DoubanSearchResultSubject_EMPTY);
|
||||||
|
}else if (searchPage.list.length < SEARCH_ITEM_PAGE_SIZE) {
|
||||||
|
doubanList.push(DoubanSearchResultSubject_TIP_EMPTY);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (searchPage.hasNext) {
|
if (searchPage.hasNext) {
|
||||||
if (this.plugin.userComponent.isLogin()) {
|
if (this.plugin.userComponent.isLogin()) {
|
||||||
if (searchPage.type == SupportType.ALL && searchPage.pageNum == 1) {
|
if (searchPage.type == SupportType.all && searchPage.pageNum == 1) {
|
||||||
doubanList.push(DoubanSearchGroupPublishResultSubjectNextPage)
|
doubanList.push(DoubanSearchGroupPublishResultSubjectNextPage)
|
||||||
}else {
|
}else {
|
||||||
doubanList.push(DoubanSearchResultSubjectNextPage)
|
doubanList.push(DoubanSearchResultSubjectNextPage)
|
||||||
@ -118,7 +131,7 @@ class DoubanFuzzySuggester extends FuzzySuggestModal<DoubanSearchResultSubject>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (searchPage.hasPrevious) {
|
if (searchPage.hasPrevious) {
|
||||||
if (searchPage.type == SupportType.ALL && searchPage.pageNum == 2) {
|
if (searchPage.type == SupportType.all && searchPage.pageNum == 2) {
|
||||||
doubanList.unshift(DoubanSearchGroupPublishResultSubjectPreviousPage)
|
doubanList.unshift(DoubanSearchGroupPublishResultSubjectPreviousPage)
|
||||||
}else {
|
}else {
|
||||||
doubanList.unshift(DoubanSearchResultSubjectPreviousPage);
|
doubanList.unshift(DoubanSearchResultSubjectPreviousPage);
|
||||||
|
|||||||
@ -8,16 +8,19 @@ import {sleep} from "../../../utils/TimeUtil";
|
|||||||
|
|
||||||
export class DoubanSearchModal extends Modal {
|
export class DoubanSearchModal extends Modal {
|
||||||
searchTerm: string;
|
searchTerm: string;
|
||||||
searchType: SupportType = SupportType.ALL;
|
searchType: SupportType = SupportType.all;
|
||||||
plugin: DoubanPlugin;
|
plugin: DoubanPlugin;
|
||||||
context: HandleContext
|
context: HandleContext
|
||||||
|
|
||||||
constructor(app: App, plugin: DoubanPlugin, context: HandleContext) {
|
constructor(app: App, plugin: DoubanPlugin, context: HandleContext, type: SupportType) {
|
||||||
super(app);
|
super(app);
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.context = context;
|
this.context = context;
|
||||||
|
this.searchType = type??SupportType.all;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
onOpen() {
|
onOpen() {
|
||||||
let {contentEl} = this;
|
let {contentEl} = this;
|
||||||
|
|
||||||
@ -42,7 +45,7 @@ export class DoubanSearchModal extends Modal {
|
|||||||
const typeSelect = content.createDiv("type-select");
|
const typeSelect = content.createDiv("type-select");
|
||||||
const typeSelectInput = new DropdownComponent(typeSelect)
|
const typeSelectInput = new DropdownComponent(typeSelect)
|
||||||
.addOptions(SearchTypeRecords)
|
.addOptions(SearchTypeRecords)
|
||||||
.setValue(SupportType.ALL)
|
.setValue(this.searchType)
|
||||||
.onChange((value:SupportType) => {
|
.onChange((value:SupportType) => {
|
||||||
this.searchType = value;
|
this.searchType = value;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
import {SupportType} from "../../../../constant/Constsant";
|
import {
|
||||||
|
SupportType
|
||||||
|
} from "../../../../constant/Constsant";
|
||||||
import {SearchResultPageParserInterface} from "./SearchResultPageParserInterface";
|
import {SearchResultPageParserInterface} from "./SearchResultPageParserInterface";
|
||||||
import {SearchPage} from "../../model/SearchPage";
|
import {SearchPage} from "../../model/SearchPage";
|
||||||
import SearchParserHandlerV2 from "../SearchParserV2";
|
import SearchParserHandlerV2 from "../SearchParserV2";
|
||||||
@ -7,7 +9,7 @@ import {log} from "../../../../utils/Logutil";
|
|||||||
|
|
||||||
export class AllFirstPageSearchResultPageParser implements SearchResultPageParserInterface {
|
export class AllFirstPageSearchResultPageParser implements SearchResultPageParserInterface {
|
||||||
support(type:SupportType, pageNum:number):boolean {
|
support(type:SupportType, pageNum:number):boolean {
|
||||||
return pageNum == 1 && type == SupportType.ALL;
|
return pageNum == 1 && type == SupportType.all;
|
||||||
}
|
}
|
||||||
parse(source:string, type:SupportType, pageNum:number, pageSize:number):SearchPage {
|
parse(source:string, type:SupportType, pageNum:number, pageSize:number):SearchPage {
|
||||||
if (!source || StringUtil.notJsonString(source)) {
|
if (!source || StringUtil.notJsonString(source)) {
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import SearchParserHandler from "../SearchParser";
|
|||||||
|
|
||||||
export class NotAllPageSearchResultPageParser implements SearchResultPageParserInterface {
|
export class NotAllPageSearchResultPageParser implements SearchResultPageParserInterface {
|
||||||
support(type:SupportType, pageNum:number):boolean {
|
support(type:SupportType, pageNum:number):boolean {
|
||||||
return type != SupportType.ALL && !(pageNum ==1 && type == SupportType.NOTE);
|
return type != SupportType.all && !(pageNum ==1 && type == SupportType.note);
|
||||||
}
|
}
|
||||||
parse(source:string, type:SupportType, pageNum:number, pageSize:number):SearchPage {
|
parse(source:string, type:SupportType, pageNum:number, pageSize:number):SearchPage {
|
||||||
log.debug("解析给多页面结果");
|
log.debug("解析给多页面结果");
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import DoubanSearchResultSubject from "../../model/DoubanSearchResultSubject";
|
|||||||
|
|
||||||
export class NoteFirstPageSearchResultPageParser implements SearchResultPageParserInterface {
|
export class NoteFirstPageSearchResultPageParser implements SearchResultPageParserInterface {
|
||||||
support(type:SupportType, pageNum:number):boolean {
|
support(type:SupportType, pageNum:number):boolean {
|
||||||
return pageNum == 1 && type == SupportType.NOTE;
|
return pageNum == 1 && type == SupportType.note;
|
||||||
}
|
}
|
||||||
parse(source:string, type:SupportType, pageNum:number, pageSize:number):SearchPage {
|
parse(source:string, type:SupportType, pageNum:number, pageSize:number):SearchPage {
|
||||||
const pageData = load(source);
|
const pageData = load(source);
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import SearchParserHandlerV2 from "../SearchParserV2";
|
|||||||
|
|
||||||
export class OtherAllPageSearchResultPageParser implements SearchResultPageParserInterface {
|
export class OtherAllPageSearchResultPageParser implements SearchResultPageParserInterface {
|
||||||
support(type:SupportType, pageNum:number):boolean {
|
support(type:SupportType, pageNum:number):boolean {
|
||||||
return pageNum > 1 && type == SupportType.ALL;
|
return pageNum > 1 && type == SupportType.all;
|
||||||
}
|
}
|
||||||
parse(source:string, type:SupportType, pageNum:number, pageSize:number):SearchPage {
|
parse(source:string, type:SupportType, pageNum:number, pageSize:number):SearchPage {
|
||||||
log.debug("解析给多页面结果");
|
log.debug("解析给多页面结果");
|
||||||
|
|||||||
@ -17,8 +17,9 @@ export abstract class AbstractSearchPageFetcher implements SearchPageFetcherInte
|
|||||||
|
|
||||||
support(type: SupportType, pageNum?:number): boolean {
|
support(type: SupportType, pageNum?:number): boolean {
|
||||||
throw new Error("Method not implemented.");
|
throw new Error("Method not implemented.");
|
||||||
}
|
}
|
||||||
fetch(keyword: string, pageNum: number, pageSize: number): Promise<string> {
|
|
||||||
|
fetch(keyword: string, pageNum: number, pageSize: number): Promise<string> {
|
||||||
const start:number = Math.floor((pageNum - 1) * pageSize);
|
const start:number = Math.floor((pageNum - 1) * pageSize);
|
||||||
const url:string = this.getSearchUrl(keyword, start, pageSize);
|
const url:string = this.getSearchUrl(keyword, start, pageSize);
|
||||||
if (!url) {
|
if (!url) {
|
||||||
@ -27,7 +28,8 @@ export abstract class AbstractSearchPageFetcher implements SearchPageFetcherInte
|
|||||||
return DoubanHttpUtil.httpRequestGet(url, this.settingsManager.getHeaders(), this.settingsManager)
|
return DoubanHttpUtil.httpRequestGet(url, this.settingsManager.getHeaders(), this.settingsManager)
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
throw log.error(i18nHelper.getMessage('130101').replace('{0}', e.toString()), e);
|
throw log.error(i18nHelper.getMessage('130101').replace('{0}', e.toString()), e);
|
||||||
}); }
|
});
|
||||||
|
}
|
||||||
|
|
||||||
getSearchUrl(keyword: string, start: number, pageSize: number):string {
|
getSearchUrl(keyword: string, start: number, pageSize: number):string {
|
||||||
keyword = keyword.trim();
|
keyword = keyword.trim();
|
||||||
|
|||||||
@ -6,7 +6,7 @@ export class AllPageSearchPageFetcher extends AbstractSearchPageFetcher {
|
|||||||
return `https://m.douban.com/rexxar/api/v2/search?q=${keyword}&start=${pageNum}&count=${pageSize}`;
|
return `https://m.douban.com/rexxar/api/v2/search?q=${keyword}&start=${pageNum}&count=${pageSize}`;
|
||||||
}
|
}
|
||||||
support(type: SupportType): boolean {
|
support(type: SupportType): boolean {
|
||||||
return type == SupportType.ALL;
|
return type == SupportType.all;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@ export class BookPageSearchPageFetcher extends AbstractSearchPageFetcher {
|
|||||||
return `https://www.douban.com/j/search?q=${keyword}&start=${start}&cat=1001`;
|
return `https://www.douban.com/j/search?q=${keyword}&start=${start}&cat=1001`;
|
||||||
}
|
}
|
||||||
support(type: SupportType): boolean {
|
support(type: SupportType): boolean {
|
||||||
return type == SupportType.BOOK;
|
return type == SupportType.book;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@ export class GamePageSearchPageFetcher extends AbstractSearchPageFetcher {
|
|||||||
return `https://www.douban.com/j/search?q=${keyword}&start=${start}&cat=3114`;
|
return `https://www.douban.com/j/search?q=${keyword}&start=${start}&cat=3114`;
|
||||||
}
|
}
|
||||||
support(type: SupportType): boolean {
|
support(type: SupportType): boolean {
|
||||||
return type == SupportType.GAME;
|
return type == SupportType.game;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@ export class MoviePageSearchPageFetcher extends AbstractSearchPageFetcher {
|
|||||||
return `https://www.douban.com/j/search?q=${keyword}&start=${start}&cat=1002`;
|
return `https://www.douban.com/j/search?q=${keyword}&start=${start}&cat=1002`;
|
||||||
}
|
}
|
||||||
support(type: SupportType): boolean {
|
support(type: SupportType): boolean {
|
||||||
return type == SupportType.MOVIE;
|
return type == SupportType.movie;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@ export class MusicPageSearchPageFetcher extends AbstractSearchPageFetcher {
|
|||||||
return `https://www.douban.com/j/search?q=${keyword}&start=${start}&cat=1003`;
|
return `https://www.douban.com/j/search?q=${keyword}&start=${start}&cat=1003`;
|
||||||
}
|
}
|
||||||
support(type: SupportType): boolean {
|
support(type: SupportType): boolean {
|
||||||
return type == SupportType.MUSIC;
|
return type == SupportType.music;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@ export class NoteFirstPageSearchPageFetcher extends AbstractSearchPageFetcher {
|
|||||||
return `https://www.douban.com/search?cat=1015&q=${keyword}`;
|
return `https://www.douban.com/search?cat=1015&q=${keyword}`;
|
||||||
}
|
}
|
||||||
support(type: SupportType, pageNum:number): boolean {
|
support(type: SupportType, pageNum:number): boolean {
|
||||||
return type == SupportType.NOTE && pageNum == 1;
|
return type == SupportType.note && pageNum == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@ export class NotePageSearchPageFetcher extends AbstractSearchPageFetcher {
|
|||||||
return `https://www.douban.com/j/search?q=${keyword}&start=${start}&cat=1015`;
|
return `https://www.douban.com/j/search?q=${keyword}&start=${start}&cat=1015`;
|
||||||
}
|
}
|
||||||
support(type: SupportType, pageNum:number): boolean {
|
support(type: SupportType, pageNum:number): boolean {
|
||||||
return type == SupportType.NOTE && pageNum > 1;
|
return type == SupportType.note && pageNum > 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@ export class TheaterPageSearchPageFetcher extends AbstractSearchPageFetcher {
|
|||||||
return `https://www.douban.com/j/search?q=${keyword}&start=${start}&cat=3069`;
|
return `https://www.douban.com/j/search?q=${keyword}&start=${start}&cat=3069`;
|
||||||
}
|
}
|
||||||
support(type: SupportType): boolean {
|
support(type: SupportType): boolean {
|
||||||
return type == SupportType.THEATER;
|
return type == SupportType.theater;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import {createFolderSelectionSetting} from "./TemplateSettingHelper";
|
|||||||
import StringUtil from "../../utils/StringUtil";
|
import StringUtil from "../../utils/StringUtil";
|
||||||
import {log} from "../../utils/Logutil";
|
import {log} from "../../utils/Logutil";
|
||||||
import DoubanPlugin from "../../main";
|
import DoubanPlugin from "../../main";
|
||||||
|
import {SearchTypeRecords, SupportType, SupportTypeMap} from "../../constant/Constsant";
|
||||||
|
|
||||||
export function constructBasicUI(containerEl: HTMLElement, manager: SettingsManager) {
|
export function constructBasicUI(containerEl: HTMLElement, manager: SettingsManager) {
|
||||||
// containerEl.createEl('h3', { text: i18nHelper.getMessage('1210') });
|
// containerEl.createEl('h3', { text: i18nHelper.getMessage('1210') });
|
||||||
@ -97,6 +98,19 @@ export function constructBasicUI(containerEl: HTMLElement, manager: SettingsMana
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
new Setting(containerEl)
|
||||||
|
.setName(i18nHelper.getMessage('121410'))
|
||||||
|
.setDesc(i18nHelper.getMessage('121411'))
|
||||||
|
.addDropdown((dropdown) => {
|
||||||
|
dropdown
|
||||||
|
.addOptions(SearchTypeRecords)
|
||||||
|
.setValue(manager.plugin.settings.searchDefaultType)
|
||||||
|
.onChange(async (value) => {
|
||||||
|
// @ts-ignore
|
||||||
|
manager.plugin.settings.searchDefaultType = SupportTypeMap[value];
|
||||||
|
await manager.plugin.saveSettings();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import {i18nHelper} from "../../lang/helper";
|
|||||||
import SettingsManager from "./SettingsManager";
|
import SettingsManager from "./SettingsManager";
|
||||||
import {CustomProperty} from "./model/CustomProperty";
|
import {CustomProperty} from "./model/CustomProperty";
|
||||||
import {ButtonComponent, DropdownComponent, ExtraButtonComponent, Setting, TextComponent} from "obsidian";
|
import {ButtonComponent, DropdownComponent, ExtraButtonComponent, Setting, TextComponent} from "obsidian";
|
||||||
import {SupportType} from "../../constant/Constsant";
|
import {SupportType, SupportTypeMap} from "../../constant/Constsant";
|
||||||
import DoubanPlugin from "../../main";
|
import DoubanPlugin from "../../main";
|
||||||
|
|
||||||
export function constructCustomPropertySettingsUI(containerEl: HTMLElement, manager: SettingsManager) {
|
export function constructCustomPropertySettingsUI(containerEl: HTMLElement, manager: SettingsManager) {
|
||||||
@ -16,7 +16,7 @@ export function constructCustomPropertySettingsUI(containerEl: HTMLElement, mana
|
|||||||
button.setTooltip(i18nHelper.getMessage('124101'));
|
button.setTooltip(i18nHelper.getMessage('124101'));
|
||||||
button.setIcon('plus');
|
button.setIcon('plus');
|
||||||
button.onClick(async () => {
|
button.onClick(async () => {
|
||||||
customProperties.push({name: '', value: '', field: SupportType.ALL});
|
customProperties.push({name: '', value: '', field: SupportType.all});
|
||||||
constructCustomPropertyUI(list, customProperties, manager);
|
constructCustomPropertyUI(list, customProperties, manager);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -68,11 +68,15 @@ function addFilterInput(data: CustomProperty, el: HTMLElement, customProperties:
|
|||||||
|
|
||||||
const fieldsDropdown = new DropdownComponent(el);
|
const fieldsDropdown = new DropdownComponent(el);
|
||||||
for (const fieldSelect in SupportType) {
|
for (const fieldSelect in SupportType) {
|
||||||
// @ts-ignore
|
|
||||||
fieldsDropdown.addOption(fieldSelect, i18nHelper.getMessage(fieldSelect));
|
fieldsDropdown.addOption(fieldSelect, i18nHelper.getMessage(fieldSelect));
|
||||||
}
|
}
|
||||||
item.createEl('span', { text: i18nHelper.getMessage('124106') });
|
item.createEl('span', { text: i18nHelper.getMessage('124106') });
|
||||||
fieldsDropdown.setValue(data.field)
|
let dataFieldValue = data.field;
|
||||||
|
if(typeof dataFieldValue === 'string') {
|
||||||
|
// @ts-ignore
|
||||||
|
dataFieldValue = SupportTypeMap[dataFieldValue];
|
||||||
|
}
|
||||||
|
fieldsDropdown.setValue(dataFieldValue)
|
||||||
.onChange(async (value: SupportType) => {
|
.onChange(async (value: SupportType) => {
|
||||||
customProperties[idx].field = value;
|
customProperties[idx].field = value;
|
||||||
await manager.plugin.saveSettings();
|
await manager.plugin.saveSettings();
|
||||||
|
|||||||
@ -33,7 +33,7 @@ export function showFileExample(containerEl: HTMLElement, manager: SettingsManag
|
|||||||
const document = new DocumentFragment();
|
const document = new DocumentFragment();
|
||||||
document.createDiv('file-path-example')
|
document.createDiv('file-path-example')
|
||||||
.innerHTML = `${i18nHelper.getMessage('121604')}<a href="https://book.douban.com/subject/2253379/">《简爱》</a>: ${VariableUtil.replaceSubject(EXAMPLE_SUBJECT_MAP,
|
.innerHTML = `${i18nHelper.getMessage('121604')}<a href="https://book.douban.com/subject/2253379/">《简爱》</a>: ${VariableUtil.replaceSubject(EXAMPLE_SUBJECT_MAP,
|
||||||
FileUtil.join(manager.plugin.settings.dataFilePath, manager.plugin.settings.dataFileNamePath + ".md"), SupportType.BOOK,
|
FileUtil.join(manager.plugin.settings.dataFilePath, manager.plugin.settings.dataFileNamePath + ".md"), SupportType.book,
|
||||||
manager)}`;
|
manager)}`;
|
||||||
|
|
||||||
new Setting(containerEl)
|
new Setting(containerEl)
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import {SyncHandledData} from "./SyncHandledData";
|
|||||||
import {ArraySetting} from "./ArraySetting";
|
import {ArraySetting} from "./ArraySetting";
|
||||||
import {ScoreSetting} from "./ScoreSetting";
|
import {ScoreSetting} from "./ScoreSetting";
|
||||||
import PictureBedSetting from "./PictureBedSetting";
|
import PictureBedSetting from "./PictureBedSetting";
|
||||||
|
import {SupportType} from "../../../constant/Constsant";
|
||||||
|
|
||||||
export interface DoubanPluginSetting {
|
export interface DoubanPluginSetting {
|
||||||
onlineSettingsFileName: string;
|
onlineSettingsFileName: string;
|
||||||
@ -39,4 +40,5 @@ export interface DoubanPluginSetting {
|
|||||||
// syncLastUpdateTime: Map<string, string>,
|
// syncLastUpdateTime: Map<string, string>,
|
||||||
arraySettings: ArraySetting[],
|
arraySettings: ArraySetting[],
|
||||||
scoreSetting: ScoreSetting,
|
scoreSetting: ScoreSetting,
|
||||||
|
searchDefaultType: SupportType,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,7 +40,7 @@ export abstract class DoubanGameListHandler extends DoubanAbstractListHandler {
|
|||||||
.find("div.title > a")
|
.find("div.title > a")
|
||||||
.text()
|
.text()
|
||||||
.trim();
|
.trim();
|
||||||
const updateDateStr: string = item.find("div.date").text().trim();
|
const updateDateStr: string = item.find("span.date").text().trim();
|
||||||
let updateDate = null;
|
let updateDate = null;
|
||||||
try {
|
try {
|
||||||
updateDate = new Date(updateDateStr);
|
updateDate = new Date(updateDateStr);
|
||||||
@ -73,11 +73,10 @@ export abstract class DoubanGameListHandler extends DoubanAbstractListHandler {
|
|||||||
});
|
});
|
||||||
const {syncConfig} = context;
|
const {syncConfig} = context;
|
||||||
const {scope} = syncConfig;
|
const {scope} = syncConfig;
|
||||||
const pattern = /(\d+)/g;
|
|
||||||
|
|
||||||
const wishCount = this.getCount(countDescs, '想玩', pattern);
|
const wishCount = this.getCount(countDescs, '想玩');
|
||||||
const collectCount = this.getCount(countDescs, '玩过', pattern);
|
const collectCount = this.getCount(countDescs, '玩过');
|
||||||
const doCount = this.getCount(countDescs, '在玩', pattern);
|
const doCount = this.getCount(countDescs, '在玩');
|
||||||
|
|
||||||
|
|
||||||
switch (scope) {
|
switch (scope) {
|
||||||
@ -94,8 +93,9 @@ export abstract class DoubanGameListHandler extends DoubanAbstractListHandler {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private getCount(countDescs:string[], keyword:string, pattern:RegExp):number {
|
private getCount(countDescs:string[], keyword:string):number {
|
||||||
return countDescs.filter(desc => desc.includes(keyword)).map(desc => {
|
return countDescs.filter(desc => desc.includes(keyword)).map(desc => {
|
||||||
|
const pattern = /(\d+)/g;
|
||||||
const result = pattern.exec(desc);
|
const result = pattern.exec(desc);
|
||||||
return result ? parseInt(result[0], 10) : 0;
|
return result ? parseInt(result[0], 10) : 0;
|
||||||
})[0];
|
})[0];
|
||||||
|
|||||||
@ -1,13 +1,18 @@
|
|||||||
//简体中文
|
//简体中文
|
||||||
export default {
|
export default {
|
||||||
//main.ts
|
//main.ts
|
||||||
'110001': 'search douban by current file name',
|
'110001': 'search by current file name',
|
||||||
'110002': 'search douban and import to current file',
|
'110002': 'search and import to current file',
|
||||||
'110003': `Enter Search Term:`,
|
'110003': `Enter Search Term:`,
|
||||||
'110004': `Search`,
|
'110004': `Search`,
|
||||||
'110005': `Cancel`,
|
'110005': `Cancel`,
|
||||||
'110006': `sync douban personal book-movie-music to Obsidian`,
|
'110006': `sync personal book-movie-music to Obsidian`,
|
||||||
'110101': 'search douban and create file',
|
'110101': 'search and create file',
|
||||||
|
'110102': 'search movie or tv and create ',
|
||||||
|
'110104': 'search book and create',
|
||||||
|
'110105': 'search music and create ',
|
||||||
|
'110106': 'search game and create ',
|
||||||
|
|
||||||
'110201': `{0} already exists`,
|
'110201': `{0} already exists`,
|
||||||
'110202': `{0} template can not read`,
|
'110202': `{0} template can not read`,
|
||||||
'110103': 'sync personal data from douban',
|
'110103': 'sync personal data from douban',
|
||||||
@ -240,6 +245,9 @@ PS: This file could be delete if you want to.
|
|||||||
'121401': `Status Bar`,
|
'121401': `Status Bar`,
|
||||||
'121402': `Display status bar when import data ?`,
|
'121402': `Display status bar when import data ?`,
|
||||||
|
|
||||||
|
'121410': `Search Default Type`,
|
||||||
|
'121411': `Search defuault type when open command palette 'search douban and create file'`,
|
||||||
|
|
||||||
'121430': `Save Attachment File`,
|
'121430': `Save Attachment File`,
|
||||||
'121431': `Save attachment file to local disk, such as image ? If you do not enable this feature, it will not show cover image in note`,
|
'121431': `Save attachment file to local disk, such as image ? If you do not enable this feature, it will not show cover image in note`,
|
||||||
'121432': `Attachment folder`,
|
'121432': `Attachment folder`,
|
||||||
@ -349,6 +357,8 @@ PS: This file could be delete if you want to.
|
|||||||
'150103': `[Next Page]...`,
|
'150103': `[Next Page]...`,
|
||||||
'150105': `[Next Page (Group Post)]...`,
|
'150105': `[Next Page (Group Post)]...`,
|
||||||
'150104': `[Next Page (Please Login First)]...`,
|
'150104': `[Next Page (Please Login First)]...`,
|
||||||
|
'150107': `Result is empty. Please choose type before search`,
|
||||||
|
'150108': `If you can't find what you want, try changing the keyword or search type`,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -648,6 +658,18 @@ PS: This file could be delete if you want to.
|
|||||||
|
|
||||||
'MOVIE_AND_TELEPLAY': `movie&tv`,
|
'MOVIE_AND_TELEPLAY': `movie&tv`,
|
||||||
|
|
||||||
|
'all': `all`,
|
||||||
|
'movie': `movie`,
|
||||||
|
'book': `book`,
|
||||||
|
'music': `music`,
|
||||||
|
'note': `note`,
|
||||||
|
'game': `game`,
|
||||||
|
'teleplay': `teleplay`,
|
||||||
|
'theater': `theater`,
|
||||||
|
|
||||||
|
'movie_and_teleplay': `movie&tv`,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
'DAY': `D`,
|
'DAY': `D`,
|
||||||
'HOUR': `H`,
|
'HOUR': `H`,
|
||||||
|
|||||||
@ -4,14 +4,22 @@ import {SyncItemStatus} from "../../constant/Constsant";
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
//main.ts
|
//main.ts
|
||||||
'110001': '搜索豆瓣当前文档名并写入',
|
'110001': '搜索当前文档名并写入',
|
||||||
'110002': '搜索豆瓣并写入当前文档',
|
'110002': '搜索并写入当前文档',
|
||||||
'110003': `输入搜索内容:`,
|
'110003': `输入搜索内容:`,
|
||||||
'110004': `搜索`,
|
'110004': `搜索`,
|
||||||
'110005': `取消`,
|
'110005': `取消`,
|
||||||
'110006': `同步豆瓣广播至Obsidian`,
|
'110006': `同步广播至Obsidian`,
|
||||||
'110101': '搜索豆瓣并创建文档',
|
'110101': '搜索并创建文档',
|
||||||
'110103': '同步豆瓣个人书影音广播记录',
|
'110103': '同步个人书影音广播记录',
|
||||||
|
//'110102': 'search douban and create movie or tv',
|
||||||
|
'110102': '搜索电影或电视剧并创建',
|
||||||
|
// '110104': 'search douban and create book',
|
||||||
|
'110104': '搜索书籍并创建',
|
||||||
|
//'110105': 'search douban and create music',
|
||||||
|
'110105': '搜索音乐并创建',
|
||||||
|
//'110106': 'search douban and create game',
|
||||||
|
'110106': '搜索游戏并创建',
|
||||||
'110007': `开始同步`,
|
'110007': `开始同步`,
|
||||||
'110009': `停止同步`,
|
'110009': `停止同步`,
|
||||||
'110010': `后台运行`,
|
'110010': `后台运行`,
|
||||||
@ -61,7 +69,7 @@ export default {
|
|||||||
{1}
|
{1}
|
||||||
|
|
||||||
### 同步结果明细
|
### 同步结果明细
|
||||||
{1}
|
{2}
|
||||||
|
|
||||||
---
|
---
|
||||||
注:此文档可删除
|
注:此文档可删除
|
||||||
@ -284,6 +292,14 @@ export default {
|
|||||||
'121401': `状态栏`,
|
'121401': `状态栏`,
|
||||||
'121402': `当在导入数据时, 是否需要在状态栏显示处理状态? `,
|
'121402': `当在导入数据时, 是否需要在状态栏显示处理状态? `,
|
||||||
|
|
||||||
|
// '121410': `Search Default Type`,
|
||||||
|
// '121411': `Search defuault type for open command palette 'search douban and create file'`,
|
||||||
|
'121410': `默认搜索类型`,
|
||||||
|
'121411': `在打开"搜索豆瓣并创建文件"时默认搜索的类型`,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
'121430': `保存图片附件`,
|
'121430': `保存图片附件`,
|
||||||
'121431': `导入数据会同步保存图片附件到本地文件夹, 如电影封面,书籍封面。如果需要显示封面,请保持开启该功能。`,
|
'121431': `导入数据会同步保存图片附件到本地文件夹, 如电影封面,书籍封面。如果需要显示封面,请保持开启该功能。`,
|
||||||
'121432': `附件存放位置`,
|
'121432': `附件存放位置`,
|
||||||
@ -355,6 +371,9 @@ export default {
|
|||||||
'150103': `[下一页]...`,
|
'150103': `[下一页]...`,
|
||||||
'150105': `[下一页]...(小组帖子结果)`,
|
'150105': `[下一页]...(小组帖子结果)`,
|
||||||
'150104': `[下一页]...(请先在插件中登录才能使用此功能)`,
|
'150104': `[下一页]...(请先在插件中登录才能使用此功能)`,
|
||||||
|
// '150107': `Result is empty. Please choose type before search`,
|
||||||
|
'150107': `结果为空,请先选择类型再搜索`,
|
||||||
|
'150108': `如果没有找到你想要的内容, 请尝试更换关键字或者更换搜索类型`,
|
||||||
|
|
||||||
//content
|
//content
|
||||||
'200101': `。`,
|
'200101': `。`,
|
||||||
@ -655,6 +674,16 @@ export default {
|
|||||||
'MOVIE_AND_TELEPLAY': `影视剧`,
|
'MOVIE_AND_TELEPLAY': `影视剧`,
|
||||||
|
|
||||||
|
|
||||||
|
'all': `全部类型`,
|
||||||
|
'movie': `电影`,
|
||||||
|
'book': `书籍`,
|
||||||
|
'music': `音乐`,
|
||||||
|
'note': `笔记`,
|
||||||
|
'game': `游戏`,
|
||||||
|
'teleplay': `电视剧`,
|
||||||
|
'theater': `戏剧`,
|
||||||
|
'movie_and_teleplay': `影视剧`,
|
||||||
|
|
||||||
'DAY': `天`,
|
'DAY': `天`,
|
||||||
'HOUR': `时`,
|
'HOUR': `时`,
|
||||||
'MINUTE': `分`,
|
'MINUTE': `分`,
|
||||||
|
|||||||
@ -151,17 +151,21 @@ export default class DoubanPlugin extends Plugin {
|
|||||||
if (activeFile) {
|
if (activeFile) {
|
||||||
const searchTerm = activeFile.basename;
|
const searchTerm = activeFile.basename;
|
||||||
if (searchTerm) {
|
if (searchTerm) {
|
||||||
await this.search(searchTerm, SupportType.ALL, context);
|
await this.search(searchTerm, SupportType.all, context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async getDoubanTextForCreateNewNote(context: HandleContext) {
|
async getDoubanTextForCreateNewNote(context: HandleContext) {
|
||||||
new DoubanSearchModal(this.app, this, context).open();
|
new DoubanSearchModal(this.app, this, context, null).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
async getDoubanTextForCreateNewNoteForType(context: HandleContext, type: SupportType) {
|
||||||
|
new DoubanSearchModal(this.app, this, context, type).open();
|
||||||
}
|
}
|
||||||
|
|
||||||
async getDoubanTextForSearchTerm(context: HandleContext) {
|
async getDoubanTextForSearchTerm(context: HandleContext) {
|
||||||
new DoubanSearchModal(this.app, this, context).open();
|
new DoubanSearchModal(this.app, this, context, null).open();
|
||||||
}
|
}
|
||||||
|
|
||||||
async showSyncModal(context: HandleContext) {
|
async showSyncModal(context: HandleContext) {
|
||||||
@ -180,13 +184,13 @@ export default class DoubanPlugin extends Plugin {
|
|||||||
id: "searcher-douban-import-and-create-file",
|
id: "searcher-douban-import-and-create-file",
|
||||||
name: i18nHelper.getMessage("110101"),
|
name: i18nHelper.getMessage("110101"),
|
||||||
callback: () =>
|
callback: () =>
|
||||||
this.getDoubanTextForCreateNewNote({plugin: this,
|
this.getDoubanTextForCreateNewNoteForType({plugin: this,
|
||||||
mode: SearchHandleMode.FOR_CREATE,
|
mode: SearchHandleMode.FOR_CREATE,
|
||||||
settings: this.settings,
|
settings: this.settings,
|
||||||
userComponent: this.userComponent,
|
userComponent: this.userComponent,
|
||||||
netFileHandler: this.netFileHandler,
|
netFileHandler: this.netFileHandler,
|
||||||
showAfterCreate:true,
|
showAfterCreate:true,
|
||||||
action: Action.SearchAndCrate}),
|
action: Action.SearchAndCrate}, this.settings.searchDefaultType),
|
||||||
});
|
});
|
||||||
|
|
||||||
this.addCommand({
|
this.addCommand({
|
||||||
@ -228,6 +232,61 @@ export default class DoubanPlugin extends Plugin {
|
|||||||
syncStatusHolder: this.statusHolder}),
|
syncStatusHolder: this.statusHolder}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.addCommand({
|
||||||
|
id: "searcher-douban-import-and-create-file-movie-tv",
|
||||||
|
name: i18nHelper.getMessage("110102"),
|
||||||
|
callback: () =>
|
||||||
|
this.getDoubanTextForCreateNewNoteForType({plugin: this,
|
||||||
|
mode: SearchHandleMode.FOR_CREATE,
|
||||||
|
settings: this.settings,
|
||||||
|
userComponent: this.userComponent,
|
||||||
|
netFileHandler: this.netFileHandler,
|
||||||
|
showAfterCreate:true,
|
||||||
|
action: Action.SearchAndCrate}, SupportType.movie),
|
||||||
|
});
|
||||||
|
|
||||||
|
this.addCommand({
|
||||||
|
id: "searcher-douban-import-and-create-file-book",
|
||||||
|
name: i18nHelper.getMessage("110104"),
|
||||||
|
callback: () =>
|
||||||
|
this.getDoubanTextForCreateNewNoteForType({plugin: this,
|
||||||
|
mode: SearchHandleMode.FOR_CREATE,
|
||||||
|
settings: this.settings,
|
||||||
|
userComponent: this.userComponent,
|
||||||
|
netFileHandler: this.netFileHandler,
|
||||||
|
showAfterCreate:true,
|
||||||
|
action: Action.SearchAndCrate}, SupportType.book),
|
||||||
|
});
|
||||||
|
|
||||||
|
this.addCommand({
|
||||||
|
id: "searcher-douban-import-and-create-file-music",
|
||||||
|
name: i18nHelper.getMessage("110105"),
|
||||||
|
callback: () =>
|
||||||
|
this.getDoubanTextForCreateNewNoteForType({plugin: this,
|
||||||
|
mode: SearchHandleMode.FOR_CREATE,
|
||||||
|
settings: this.settings,
|
||||||
|
userComponent: this.userComponent,
|
||||||
|
netFileHandler: this.netFileHandler,
|
||||||
|
showAfterCreate:true,
|
||||||
|
action: Action.SearchAndCrate}, SupportType.music),
|
||||||
|
});
|
||||||
|
|
||||||
|
this.addCommand({
|
||||||
|
id: "searcher-douban-import-and-create-file-game",
|
||||||
|
name: i18nHelper.getMessage("110106"),
|
||||||
|
callback: () =>
|
||||||
|
this.getDoubanTextForCreateNewNoteForType({plugin: this,
|
||||||
|
mode: SearchHandleMode.FOR_CREATE,
|
||||||
|
settings: this.settings,
|
||||||
|
userComponent: this.userComponent,
|
||||||
|
netFileHandler: this.netFileHandler,
|
||||||
|
showAfterCreate:true,
|
||||||
|
action: Action.SearchAndCrate}, SupportType.game),
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.settingsManager = new SettingsManager(app, this);
|
this.settingsManager = new SettingsManager(app, this);
|
||||||
// this.fetchOnlineData(this.settingsManager);
|
// this.fetchOnlineData(this.settingsManager);
|
||||||
this.userComponent = new UserComponent(this.settingsManager);
|
this.userComponent = new UserComponent(this.settingsManager);
|
||||||
|
|||||||
@ -244,7 +244,7 @@ export class VariableUtil {
|
|||||||
const customPropertiesMap= new Map();
|
const customPropertiesMap= new Map();
|
||||||
customProperties.filter(customProperty => customProperty.name &&
|
customProperties.filter(customProperty => customProperty.name &&
|
||||||
customProperty.field
|
customProperty.field
|
||||||
&& (customProperty.field.toLowerCase() == SupportType.ALL ||
|
&& (customProperty.field.toLowerCase() == SupportType.all ||
|
||||||
customProperty.field.toLowerCase() == subjectType)).forEach(customProperty => {
|
customProperty.field.toLowerCase() == subjectType)).forEach(customProperty => {
|
||||||
customPropertiesMap.set(customProperty.name, customProperty.value);
|
customPropertiesMap.set(customProperty.name, customProperty.value);
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user