Add basics of URI handling for Mac and Windows

This commit is contained in:
Alex Liebowitz 2017-05-05 05:15:58 -04:00
parent 2cc60fade1
commit 758bb59ccb
3 changed files with 22 additions and 1 deletions

View file

@ -303,3 +303,12 @@ function upgrade(event, installerPath) {
}
ipcMain.on('upgrade', upgrade);
if (process.platform == 'darwin') {
app.on('open-url', (event, uri) => {
win.webContents.send('open-uri-requested', url);
});
} else if (process.argv.length >= 3) {
// No open-url event on Win, but we can still handle URIs provided at launch time
win.webContents.send('open-uri-requested', process.argv[2]);
}

View file

@ -32,11 +32,19 @@
},
"backgroundColor": "155B4A"
},
"protocols": [{
"name": "lbry",
"role": "Viewer",
"schemes": ["lbry"]
}],
"linux": {
"target": "deb"
},
"win": {
"target": "nsis"
},
"nsis": {
"perMachine": true
}
},
"devDependencies": {

View file

@ -8,7 +8,7 @@ import SplashScreen from './component/splash.js';
import SnackBar from './component/snack-bar.js';
import {AuthOverlay} from './component/auth.js';
const {remote} = require('electron');
const {remote, ipcRenderer} = require('electron');
const contextMenu = remote.require('./menu/context-menu');
lbry.showMenuIfNeeded();
@ -19,6 +19,10 @@ window.addEventListener('contextmenu', (event) => {
event.preventDefault();
});
ipcRenderer.on('open-uri-requested', (event, uri) => {
window.location.href = `?show=${uri}`;
});
let init = function() {
window.lbry = lbry;
window.lighthouse = lighthouse;