From de1fe6504594553f970ac81da44d7a0080a99fa4 Mon Sep 17 00:00:00 2001 From: Elysia Date: Fri, 30 Jan 2026 21:54:51 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=B7=BB=E5=8A=A0=E6=B7=B1?= =?UTF-8?q?=E5=BA=A6=E9=93=BE=E6=8E=A5=E5=A4=84=E7=90=86=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E4=BB=A5=E6=94=AF=E6=8C=81=E6=9B=B4=E6=96=B0=E3=80=81=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E5=92=8C=E5=B7=B2=E5=AE=89=E8=A3=85=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- electron/main/handle-url-scheme.ts | 31 +++++++++++++++++++++++++++++- src/App.vue | 31 ++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/electron/main/handle-url-scheme.ts b/electron/main/handle-url-scheme.ts index 0f7216c8..f3e40b41 100644 --- a/electron/main/handle-url-scheme.ts +++ b/electron/main/handle-url-scheme.ts @@ -1,5 +1,34 @@ +import { BrowserWindow } from 'electron'; import { deepLink } from './deeplink'; deepLink.on("event", (query) => { console.log(`Deep link: event "event" fired with query: ${JSON.stringify(query)}`); -}); \ No newline at end of file +}); + +deepLink.on("action", (query) => { + console.log(`Deep link: event "action" fired with query: ${JSON.stringify(query)}`); + const win = BrowserWindow.getAllWindows()[0]; + if (!win) return; + + if (query.cmd === 'update') { + win.webContents.send('deep-link-update'); + if (win.isMinimized()) win.restore(); + win.focus(); + } else if (query.cmd === 'list') { + win.webContents.send('deep-link-installed'); + if (win.isMinimized()) win.restore(); + win.focus(); + } +}); + +deepLink.on("install", (query) => { + console.log(`Deep link: event "install" fired with query: ${JSON.stringify(query)}`); + const win = BrowserWindow.getAllWindows()[0]; + if (!win) return; + + if (query.pkg) { + win.webContents.send('deep-link-install', query.pkg); + if (win.isMinimized()) win.restore(); + win.focus(); + } +}); diff --git a/src/App.vue b/src/App.vue index c8776684..de8cb5cd 100644 --- a/src/App.vue +++ b/src/App.vue @@ -515,6 +515,37 @@ onMounted(async () => { closeDetail(); } }); + + // Deep link Handlers + window.ipcRenderer.on('deep-link-update', () => { + openUpdateModal(); + }); + + window.ipcRenderer.on('deep-link-installed', () => { + openInstalledModal(); + }); + + window.ipcRenderer.on('deep-link-install', (_event, pkgname) => { + const tryOpen = () => { + const target = apps.value.find(a => a.Pkgname === pkgname); + if (target) { + openDetail(target); + } else { + logger.warn(`Deep link: app ${pkgname} not found`); + } + }; + + if (loading.value) { + const stop = watch(loading, (val) => { + if (!val) { + tryOpen(); + stop(); + } + }); + } else { + tryOpen(); + } + }); }); // 观察器