// Open handlers must be added as early as possible
app.on('open-file', onOpen)
app.on('open-url', onOpen)
//...
app.once('ipcReady', function () {
processArgv(argv)
你可以对它做任何你想做的事情,例如将它重定向到程序参数以重用处理参数:
function onOpen (e, torrentId) {
e.preventDefault()
if (app.ipcReady) {
// Magnet links opened from Chrome won't focus the app without a setTimeout.
// The confirmation dialog Chrome shows causes Chrome to steal back the focus.
// Electron issue: https://github.com/atom/electron/issues/4338
setTimeout(() => windows.main.show(), 100)
processArgv([ torrentId ])
} else {
argv.push(torrentId) // [to be handled by `processArgv` later anyway]
}
}
1条答案
按热度按时间ulmd4ohb1#
在主进程中,注册打开的处理程序:
你可以对它做任何你想做的事情,例如将它重定向到程序参数以重用处理参数:
并将您的应用程序安装为系统中的默认协议处理程序: