From b8f79617748844a2f542596625b6291fdbcaea68 Mon Sep 17 00:00:00 2001 From: aooiuu Date: Mon, 27 May 2024 19:38:10 +0800 Subject: [PATCH] =?UTF-8?q?feat(desktop):=20=E6=96=B0=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E6=89=93=E5=BC=80=E8=A7=86=E9=A2=91=E6=92=AD=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/web/electron/api.ts | 16 ++++++++++++++++ packages/web/package.json | 2 +- packages/web/src/api/electron.ts | 9 +++++++++ packages/web/src/pages/pc/chapter/index.vue | 13 ++++++++----- packages/web/src/router/router.ts | 9 +++++---- 5 files changed, 39 insertions(+), 10 deletions(-) diff --git a/packages/web/electron/api.ts b/packages/web/electron/api.ts index f7c8774c..3da65b70 100644 --- a/packages/web/electron/api.ts +++ b/packages/web/electron/api.ts @@ -56,4 +56,20 @@ export function createAPI(win: BrowserWindow) { pinned ? win.setAlwaysOnTop(true, 'screen-saver') : win.setAlwaysOnTop(false); return success(win.isAlwaysOnTop()); }); + + pm.answer('post@openWindow', (data) => { + const window = new BrowserWindow({ + title: 'AnyReader', + // titleBarStyle: 'hidden', + webPreferences: { nodeIntegration: true, contextIsolation: false } + }); + + if (process.env.VITE_DEV_SERVER_URL) { + window.loadURL(process.env.VITE_DEV_SERVER_URL + '/#' + data.url); + } else { + window.loadFile('dist/electron-template/index.html', { + hash: data.url + }); + } + }); } diff --git a/packages/web/package.json b/packages/web/package.json index f9f9289f..082c0f38 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -1,6 +1,6 @@ { "name": "any-reader-web", - "version": "1.0.0-dev.1", + "version": "1.0.0-dev.4", "private": true, "scripts": { "dev": "cross-env VITE_APP_PLATFORM=browser vite", diff --git a/packages/web/src/api/electron.ts b/packages/web/src/api/electron.ts index 5ad4c6bb..c89c20b6 100644 --- a/packages/web/src/api/electron.ts +++ b/packages/web/src/api/electron.ts @@ -34,3 +34,12 @@ export function alwaysOnTop(pinned: boolean) { } }); } + +// 打开新窗口 +export function openWindow(data: any) { + return request({ + method: 'post', + url: 'openWindow', + data + }); +} diff --git a/packages/web/src/pages/pc/chapter/index.vue b/packages/web/src/pages/pc/chapter/index.vue index 8711480b..1fe10ddd 100644 --- a/packages/web/src/pages/pc/chapter/index.vue +++ b/packages/web/src/pages/pc/chapter/index.vue @@ -12,7 +12,9 @@