Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimization for Windows #28

Merged
merged 17 commits into from
Jan 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ node_modules

# logs
npm-debug.log
package-lock.json

# Certificates
Certificates.p12
59 changes: 50 additions & 9 deletions main/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@

'use strict'

// Native
const { format } = require('url')
const { join } = require('path')
const { platform } = require('os')

// Packages
const { BrowserWindow, app } = require('electron')
const { BrowserWindow, app, Menu } = require('electron')
const isDev = require('electron-is-dev')
const prepareNext = require('electron-next')
const { resolve } = require('app-root-path')
Expand All @@ -16,14 +18,17 @@ const autoUpdater = require('./updater')
// Prepare the renderer once the app is ready
app.on('ready', async () => {
await prepareNext('./renderer')

const mainWindow = new BrowserWindow({
width: 320,
height: 580,
resizable: true,
titleBarStyle: 'hiddenInset',
icon: join(__dirname, 'main/static/icon.icns')
})
width: 320,
height: 580,
minWidth: 320,
minHeight: 580,
resizable: true,
backgroundColor: '#000000',
frame: platform() !== 'win32',
titleBarStyle: 'hiddenInset',
icon: platform() === 'win32' ? join(__dirname, 'main/static/icon.ico') : join(__dirname, 'main/static/icon.icns')
})

const devPath = 'http://localhost:8000/start'

Expand All @@ -33,10 +38,46 @@ app.on('ready', async () => {
slashes: true
})

autoUpdater()
const template = [
{
label: 'Application',
submenu: [
{
label: 'About Application',
selector: 'orderFrontStandardAboutPanel:'
},
{ type: 'separator' },
{
label: 'Quit',
accelerator: 'Command+Q',
click: () => app.quit()
}
]
},
{
label: 'Edit',
submenu: [
{ label: 'Undo', accelerator: 'CmdOrCtrl+Z', selector: 'undo:' },
{ label: 'Redo', accelerator: 'Shift+CmdOrCtrl+Z', selector: 'redo:' },
{ type: 'separator' },
{ label: 'Cut', accelerator: 'CmdOrCtrl+X', selector: 'cut:' },
{ label: 'Copy', accelerator: 'CmdOrCtrl+C', selector: 'copy:' },
{ label: 'Paste', accelerator: 'CmdOrCtrl+V', selector: 'paste:' },
{
label: 'Select All',
accelerator: 'CmdOrCtrl+A',
selector: 'selectAll:'
}
]
}
]

if (platform() !== 'win32'){
autoUpdater()
}
const url = isDev ? devPath : prodPath
mainWindow.loadURL(url)
Menu.setApplicationMenu(Menu.buildFromTemplate(template))
})

// Quit the app once all windows are closed
Expand Down
Binary file modified main/static/icon.ico
Binary file not shown.
Loading