Skip to content

Instantly share code, notes, and snippets.

@mnquintana
Last active January 29, 2018 21:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mnquintana/6641275ef58ea599c4d58c5f89a8e42e to your computer and use it in GitHub Desktop.
Save mnquintana/6641275ef58ea599c4d58c5f89a8e42e to your computer and use it in GitHub Desktop.
IL: Code Samples
const mainWindow = new BrowserWindow({ width: 800, height: 800 });
mainWindow.loadURL(‘https://<remote-web-app-goes-here>’);
// ==============
// Guest page (remote web app)
// ==============
const {remote} = require(‘electron’);
remote.app.setBadgeCount(9001);
const mainWindow = new BrowserWindow({
width: 800,
height: 800,
webPreferences: {
preload: './path/to/preload/script.js',
nodeIntegration: false,
contextIsolation: true,
// ...
}
});
mainWindow.loadURL('https://<remote-web-app-goes-here>');
// ==============
// Preload script
// ==============
const {remote} = require('electron');
window.interop = {
setBadgeCount(count) {
return remote.app.setBadgeCount(count);
}
};
// ==============
// Guest page (remote web app)
// ==============
if (window.interop) window.interop.setBadgeCount(9001);
const {remote} = require('electron');
const {Component} = require('react');
const {Header, Sidebar} = require('@remote-web-app/ui');
const desktopInterop = {
setBadgeCount(count) {
return remote.app.setBadgeCount(count);
}
};
class DesktopApp extends Component {
render() {
return (
<div>
<Header desktopInterop={desktopInterop} />
<Sidebar desktopInterop={desktopInterop} />
</div>
);
}
}
const mainWindow = new BrowserWindow({
width: 800,
height: 800
});
mainWindow.loadURL('file://path/to/app/shell.html');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment