build setup - electron-builder

This commit is contained in:
Lynn Neir
2016-11-07 12:31:39 -08:00
parent be734b9694
commit 04250c1fcf
6 changed files with 222 additions and 31 deletions

BIN
build/background.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

BIN
build/icon.icns Normal file

Binary file not shown.

BIN
build/icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 291 KiB

43
main.js
View File

@@ -1,34 +1,39 @@
const electron = require('electron') const electron = require('electron');
const packageJSON = require('./package.json') const packageJSON = require('./package.json');
const menuTemplate = require('./menuTemplate.js');
// Module to control application life.
const app = electron.app const app = electron.app
// Module to create native browser window.
const BrowserWindow = electron.BrowserWindow const BrowserWindow = electron.BrowserWindow
if (require('electron-squirrel-startup')) return;
// Keep a global reference of the window object, if you don't, the window will // Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected. // be closed automatically when the JavaScript object is garbage collected.
let mainWindow let mainWindow;
function createWindow () { function createWindow () {
// Create the browser window. // note: for now, turning off node integration as this is causing failure with
mainWindow = new BrowserWindow({width: 800, height: 600}) // onelogin, jquery can not get initialized. electron's node integration
// conflicts on the window object.
mainWindow = new BrowserWindow({
title: 'Symphony',
width: 1024, height: 768,
webPreferences: {
sandbox: false,
nodeIntegration: false
}
});
// and load the index.html of the app. const menu = electron.Menu.buildFromTemplate(menuTemplate(app));
//mainWindow.loadURL(`file://${__dirname}/index.html`) electron.Menu.setApplicationMenu(menu)
//mainWindow.loadURL(`https://corporate.symphony.com`) mainWindow.loadURL(packageJSON.homepage);
mainWindow.loadURL(packageJSON.homepage)
// Open the DevTools.
//mainWindow.webContents.openDevTools()
// Emitted when the window is closed.
mainWindow.on('closed', function () { mainWindow.on('closed', function () {
// Dereference the window object, usually you would store windows // Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time // in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element. // when you should delete the corresponding element.
mainWindow = null mainWindow = null;
}) })
} }
@@ -37,7 +42,6 @@ mainWindow.loadURL(packageJSON.homepage)
// Some APIs can only be used after this event occurs. // Some APIs can only be used after this event occurs.
app.on('ready', createWindow) app.on('ready', createWindow)
// Quit when all windows are closed.
app.on('window-all-closed', function () { app.on('window-all-closed', function () {
// On OS X it is common for applications and their menu bar // On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q // to stay active until the user quits explicitly with Cmd + Q
@@ -52,7 +56,4 @@ app.on('activate', function () {
if (mainWindow === null) { if (mainWindow === null) {
createWindow() createWindow()
} }
}) });
// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.

174
menuTemplate.js Normal file
View File

@@ -0,0 +1,174 @@
const template = [
{
label: 'Edit',
submenu: [
{
role: 'undo'
},
{
role: 'redo'
},
{
type: 'separator'
},
{
role: 'cut'
},
{
role: 'copy'
},
{
role: 'paste'
},
{
role: 'pasteandmatchstyle'
},
{
role: 'delete'
},
{
role: 'selectall'
}
]
},
{
label: 'View',
submenu: [
{
label: 'Reload',
accelerator: 'CmdOrCtrl+R',
click (item, focusedWindow) {
if (focusedWindow) focusedWindow.reload()
}
},
{
label: 'Toggle Developer Tools',
accelerator: process.platform === 'darwin' ? 'Alt+Command+I' : 'Ctrl+Shift+I',
click (item, focusedWindow) {
if (focusedWindow) focusedWindow.webContents.toggleDevTools()
}
},
{
type: 'separator'
},
{
role: 'resetzoom'
},
{
role: 'zoomin'
},
{
role: 'zoomout'
},
{
type: 'separator'
},
{
role: 'togglefullscreen'
}
]
},
{
role: 'window',
submenu: [
{
role: 'minimize'
},
{
role: 'close'
}
]
},
{
role: 'help',
submenu: [
{
label: 'Learn More',
click () { require('electron').shell.openExternal('http://electron.atom.io') }
}
]
}
];
function getTemplate(app) {
if (process.platform === 'darwin') {
template.unshift({
label: app.getName(),
submenu: [
{
role: 'about'
},
{
type: 'separator'
},
{
role: 'services',
submenu: []
},
{
type: 'separator'
},
{
role: 'hide'
},
{
role: 'hideothers'
},
{
role: 'unhide'
},
{
type: 'separator'
},
{
role: 'quit'
}
]
})
// Edit menu.
template[1].submenu.push(
{
type: 'separator'
},
{
label: 'Speech',
submenu: [
{
role: 'startspeaking'
},
{
role: 'stopspeaking'
}
]
}
)
// Window menu.
template[3].submenu = [
{
label: 'Close',
accelerator: 'CmdOrCtrl+W',
role: 'close'
},
{
label: 'Minimize',
accelerator: 'CmdOrCtrl+M',
role: 'minimize'
},
{
label: 'Zoom',
role: 'zoom'
},
{
type: 'separator'
},
{
label: 'Bring All to Front',
role: 'front'
}
]
}
return template;
}
module.exports = getTemplate;

View File

@@ -1,28 +1,44 @@
{ {
"name": "Symphony", "name": "Symphony",
"productName": "Symphony",
"version": "1.0.0", "version": "1.0.0",
"description": "Symphony", "description": "Symphony desktop app",
"author": "Symphony",
"main": "main.js", "main": "main.js",
"scripts": { "scripts": {
"start": "electron ." "start": "electron .",
"dist-mac": "build --mac",
"dist-win": "build --win --x64"
},
"build": {
"appId": "symphony-electron-desktop",
"mac": {
"target": "dmg",
"category": "public.app-category.business"
},
"win": {
"target": "squirrel"
}
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/electron/electron-quick-start.git" "url": "git+https://github.com/SymphonyOSF/SymphonyElectron.git"
}, },
"keywords": [ "keywords": [
"Symphony", "Symphony",
"quick", "start"
"start",
"tutorial"
], ],
"author": "GitHub", "license": "tbd",
"license": "CC0-1.0",
"bugs": { "bugs": {
"url": "https://github.com/electron/electron-quick-start/issues" "url": "https://support.symphony.com"
}, },
"homepage": "https://corporate.symphony.com", "homepage": "https://corporate.symphony.com",
"devDependencies": { "devDependencies": {
"electron": "^1.3.4" "electron": "1.4.5",
"electron-builder": "^7.23.2",
"electron-packager": "^8.2.0"
},
"dependencies": {
"electron-squirrel-startup": "^1.0.0"
} }
} }