From dae639d791b51f8e806ac89d3dba94024a35352d Mon Sep 17 00:00:00 2001 From: aooiuu Date: Wed, 15 May 2024 21:18:38 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=89=93=E5=BC=80?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E7=9B=AE=E5=BD=95=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/vscode/package.json | 2 +- packages/vscode/src/webview/WebviewEvent.ts | 11 ++++++++++- packages/web/src/api/vsc.ts | 7 +++++++ packages/web/src/pages/home/Local.vue | 18 ++++++++++++++---- packages/web/src/plugins/vsc-ui.ts | 6 ++++-- 5 files changed, 36 insertions(+), 8 deletions(-) diff --git a/packages/vscode/package.json b/packages/vscode/package.json index c16b3f4e..d3ffd5e5 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": "1.0.0", + "version": "1.0.1", "publisher": "aooiu", "qna": "https://github.com/aooiuu/any-reader/issues", "bugs": { diff --git a/packages/vscode/src/webview/WebviewEvent.ts b/packages/vscode/src/webview/WebviewEvent.ts index c5a0ae80..5936b13b 100644 --- a/packages/vscode/src/webview/WebviewEvent.ts +++ b/packages/vscode/src/webview/WebviewEvent.ts @@ -5,6 +5,8 @@ import * as vscode from 'vscode'; import * as EasyPostMessage from 'easy-post-message'; import { ContentType, Rule, RuleManager } from '@any-reader/core'; +import { CONSTANTS } from '@any-reader/shared'; +import * as localBookManager from '@any-reader/shared/localBookManager'; import type { BookChapter } from '@any-reader/shared/localBookManager'; import { COMMANDS } from '../constants'; import * as ruleFileManager from '../utils/ruleFileManager'; @@ -12,7 +14,7 @@ import { createAdapter } from '../utils/easyPostMessage'; import favoritesProvider from '../sidebar/favorites'; import favoritesManager from '../utils/favoritesManager'; import historyManager from '../utils/historyManager'; -import * as localBookManager from '@any-reader/shared/localBookManager'; +import openExplorer from 'explorer-opener'; function success(data: any, msg = '') { return { @@ -57,6 +59,7 @@ export class WebviewEvent { this._pm.answer('post@vscode/getChapter', this._vscGetChapter.bind(this)); this._pm.answer('get@vscode/editBookSource', this._vscEditBookSource.bind(this)); this._pm.answer('get@vscode/github', this._vscGithub.bind(this)); + this._pm.answer('get@vscode/openLocalBookDir', this._vscOpenLocalBookDir.bind(this)); this._pm.answer('get@discoverMap', this._discoverMap.bind(this)); this._pm.answer('get@getFavorites', this._getFavorites.bind(this)); @@ -74,6 +77,12 @@ export class WebviewEvent { this._pm.answer('post@getChapter', this._getChapter.bind(this)); } + // 打开本地书籍目录 + _vscOpenLocalBookDir() { + localBookManager.checkDir(); + openExplorer(CONSTANTS.LOCAL_BOOK_DIR); + } + // github private _vscGithub() { const doc = 'https://github.com/aooiuu/any-reader'; diff --git a/packages/web/src/api/vsc.ts b/packages/web/src/api/vsc.ts index c1296921..ef853628 100644 --- a/packages/web/src/api/vsc.ts +++ b/packages/web/src/api/vsc.ts @@ -24,3 +24,10 @@ export function github() { url: 'vscode/github' }); } + +export function openLocalBookDir() { + return request({ + method: 'get', + url: 'vscode/openLocalBookDir' + }); +} diff --git a/packages/web/src/pages/home/Local.vue b/packages/web/src/pages/home/Local.vue index dac71026..a1690d6e 100644 --- a/packages/web/src/pages/home/Local.vue +++ b/packages/web/src/pages/home/Local.vue @@ -1,13 +1,23 @@