Skip to content

Instantly share code, notes, and snippets.

@adamkirkwood

adamkirkwood/index.js

Last active Sep 26, 2017
Embed
What would you like to do?
/* eslint strict: 0 */
'use strict';
const electron = require('electron')
const {
app,
dialog,
autoUpdater,
protocol,
Menu,
ipcMain,
ipcRenderer,
globalShortcut
} = electron
const menubar = require('menubar')
const opts = {
dir: __dirname,
icon: __dirname + '/src/IconTemplate.png',
width: 720,
height: 540,
index: (__PRODUCTION__ && __ELECTRON__)
? `file://${__dirname}/src/dist/index.html`
: `http://localhost:${SERVER_PORT}/`,
resizable: false,
alwaysOnTop: false,
showOnAllWorkspaces: true,
preloadWindow: true,
tooltip: `Sketchpacks ${pkg.version}`,
backgroundColor: '#f8f9fa'
}
const menuBar = menubar(opts)
let mainWindow
let updater
app.on('ready', () => {
protocol.registerHttpProtocol('sketchpacks', (request, callback) => {
const uri = url.parse(request.url)
}, (err) => {
if (err) console.error('Failed to register protocol', err)
})
})
app.on('open-url', (event, resource) => {
event.preventDefault() // Handle event ourselves
const uri = url.parse(resource)
// ... logic to handle the uri
})
{
"build": {
"asar": true,
"protocols": {
"name": "Sketchpacks",
"schemes": [
"sketchpacks"
]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment