Skip to content

Commit

Permalink
feat(generator): remove old electron patches
Browse files Browse the repository at this point in the history
  • Loading branch information
nklayman committed Jun 24, 2020
1 parent 3774248 commit c13f30d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
5 changes: 0 additions & 5 deletions generator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ module.exports = (api, options = {}) => {
if (!hasBackground) {
// If user does not have a background file it should be created
api.render('./templates/base', {
// Scheme registration changed in Electron 5.0.0
newSchemeRegistrationFunction: semver.gte(
(electronVersion || pkg.devDependencies.electron).replace('^', ''),
'5.0.0'
),
devtoolsExtensionsBroken
})
}
Expand Down
25 changes: 15 additions & 10 deletions generator/templates/base/src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,21 @@ const isDevelopment = process.env.NODE_ENV !== 'production'
let win

// Scheme must be registered before the app is ready
<% if (newSchemeRegistrationFunction) { %>protocol.registerSchemesAsPrivileged([{scheme: 'app', privileges: { secure: true, standard: true } }])
<% } else { %>protocol.registerStandardSchemes(['app'], { secure: true })
<% } %>
function createWindow () {
protocol.registerSchemesAsPrivileged([
{ scheme: 'app', privileges: { secure: true, standard: true } }
])

function createWindow() {
// Create the browser window.
win = new BrowserWindow({ width: 800, height: 600, webPreferences: {
// Use pluginOptions.nodeIntegration, leave this alone
// See nklayman.github.io/vue-cli-plugin-electron-builder/guide/security.html#node-integration for more info
nodeIntegration: process.env.ELECTRON_NODE_INTEGRATION
} })
win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
// Use pluginOptions.nodeIntegration, leave this alone
// See nklayman.github.io/vue-cli-plugin-electron-builder/guide/security.html#node-integration for more info
nodeIntegration: process.env.ELECTRON_NODE_INTEGRATION
}
})

if (process.env.WEBPACK_DEV_SERVER_URL) {
// Load the url of the dev server if in development mode
Expand Down Expand Up @@ -84,7 +89,7 @@ app.on('ready', async () => {
// Exit cleanly on request from parent process in development mode.
if (isDevelopment) {
if (process.platform === 'win32') {
process.on('message', data => {
process.on('message', (data) => {
if (data === 'graceful-exit') {
app.quit()
}
Expand Down

0 comments on commit c13f30d

Please sign in to comment.