Created
November 16, 2017 15:25
-
-
Save mallendeo/a63a9b3c4bf7a14d2ff3090884e7c94b to your computer and use it in GitHub Desktop.
electron with vibrancy (macOS)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
import { app, BrowserWindow } from 'electron' | |
/** | |
* Set `__static` path to static files in production | |
* https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html | |
*/ | |
if (process.env.NODE_ENV !== 'development') { | |
global.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\') | |
} | |
let mainWindow | |
const winURL = process.env.NODE_ENV === 'development' | |
? `http://localhost:9080` | |
: `file://${__dirname}/index.html` | |
function createWindow () { | |
/** | |
* Initial window options | |
*/ | |
mainWindow = new BrowserWindow({ | |
height: 583, | |
useContentSize: true, | |
width: 480, | |
titleBarStyle: 'hiddenInset', | |
frame: false, | |
vibrancy: 'dark', | |
webPreferences: { | |
experimentalFeatures: true | |
} | |
}) | |
mainWindow.loadURL(winURL) | |
mainWindow.on('closed', () => { | |
mainWindow = null | |
}) | |
} | |
app.on('ready', createWindow) | |
app.on('window-all-closed', () => { | |
if (process.platform !== 'darwin') { | |
app.quit() | |
} | |
}) | |
app.on('activate', () => { | |
if (mainWindow === null) { | |
createWindow() | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment