diff --git a/packages/vscode/package.json b/packages/vscode/package.json index 60912787..9fbdaa42 100644 --- a/packages/vscode/package.json +++ b/packages/vscode/package.json @@ -3,7 +3,7 @@ "displayName": "any-reader", "description": "自定义规则多站点聚合搜索阅读小说、漫画。包含JS规则解析库和VSCode插件。支持本地小说 TXT、EPUB", "icon": "resources/icon.png", - "version": "0.7.1", + "version": "0.7.2", "preview": true, "publisher": "aooiu", "qna": "https://github.com/aooiuu/any-reader/issues", diff --git a/packages/vscode/src/sidebar/book.ts b/packages/vscode/src/sidebar/book.ts index 4c10c840..782418e8 100644 --- a/packages/vscode/src/sidebar/book.ts +++ b/packages/vscode/src/sidebar/book.ts @@ -11,7 +11,6 @@ import { ChapterItem, Rule } from '@any-reader/core'; export class BookProvider implements vscode.TreeDataProvider { readonly _onDidChangeTreeData = new vscode.EventEmitter(); readonly onDidChangeTreeData = this._onDidChangeTreeData.event; - readonly cache = new Map(); refresh(): void { this._onDidChangeTreeData.fire(undefined); @@ -34,32 +33,23 @@ export class BookProvider implements vscode.TreeDataProvider { }; } - // 获取缓存列表 - getChildrenCache(ruleId: string, url: string) { - const key = `${ruleId}@${url}`; - return this.cache.get(key) || this.cache.get('_') || []; - } - async getChildren(element?: TreeNode): Promise { if (!element) { const items = await bookManager.getChildren(); return items; } else { const chapters = await bookManager.getChapter(element); - this.cache.set(`${element.rule.id}@${element.url}`, chapters); return chapters; } } setChapters(chapterItems: ChapterItem[], rule: Rule, url: string) { - this.cache.clear(); bookManager.list = chapterItems.map((chapterItem: ChapterItem) => ({ rule, type: 2, data: chapterItem, url })); - this.cache.set('_', bookManager.list); this.refresh(); } } diff --git a/packages/vscode/src/sidebar/localBook.ts b/packages/vscode/src/sidebar/localBook.ts index 3b322988..74bafd47 100644 --- a/packages/vscode/src/sidebar/localBook.ts +++ b/packages/vscode/src/sidebar/localBook.ts @@ -5,7 +5,6 @@ import { COMMANDS } from '../constants'; class TreeDataProvider implements vscode.TreeDataProvider { readonly _onDidChangeTreeData = new vscode.EventEmitter(); readonly onDidChangeTreeData = this._onDidChangeTreeData.event; - readonly cache = new Map(); async refresh(): Promise { this._onDidChangeTreeData.fire(undefined); @@ -43,19 +42,12 @@ class TreeDataProvider implements vscode.TreeDataProvider { }; } - // 获取缓存列表 - getChildrenCache(path: string) { - return this.cache.get(path) || []; - } - // 获取目录 async getChildren(item?: TreeNode): Promise { if (!item) { - this.cache.clear(); return getBookList(); } else { const chapters = await getChapter(item.path).catch(() => []); - this.cache.set(item.path, chapters); return chapters; } }