mirror of
https://gitee.com/spark-store-project/spark-store
synced 2026-04-26 09:20:18 +08:00
refactor: 添加深度链接处理程序以支持更新、安装和已安装事件
This commit is contained in:
@@ -1,5 +1,34 @@
|
|||||||
|
import { BrowserWindow } from 'electron';
|
||||||
import { deepLink } from './deeplink';
|
import { deepLink } from './deeplink';
|
||||||
|
|
||||||
deepLink.on("event", (query) => {
|
deepLink.on("event", (query) => {
|
||||||
console.log(`Deep link: event "event" fired with query: ${JSON.stringify(query)}`);
|
console.log(`Deep link: event "event" fired with query: ${JSON.stringify(query)}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|||||||
31
src/App.vue
31
src/App.vue
@@ -515,6 +515,37 @@ onMounted(async () => {
|
|||||||
closeDetail();
|
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();
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// 观察器
|
// 观察器
|
||||||
|
|||||||
Reference in New Issue
Block a user