- handle submodule npm tasks

- autoupdate dialog


Former-commit-id: 00fe005ecc
This commit is contained in:
mediaslav 2017-03-04 17:11:12 +03:00
parent 597af75372
commit ef1f1e96b6
2 changed files with 77 additions and 35 deletions

View file

@ -1,11 +1,19 @@
const fs = require('fs')
const path = require('path')
const url = require('url')
const electron = require('electron')
const ipcMain = electron.ipcMain
const dialog = electron.dialog
const app = electron.app
const BrowserWindow = electron.BrowserWindow
const autoUpdater = require('electron-updater').autoUpdater
autoUpdater.logger = require('electron-log')
autoUpdater.logger.transports.file.level = 'info'
autoUpdater.autoDownload = false
const __DEV__ = process.env.NODE_ENV === 'development'
let windowsRegistry = []
function createWindow (opt = {}) {
@ -13,6 +21,9 @@ function createWindow (opt = {}) {
width: 1600,
height: 1200,
'web-security': false,
webPreferences: {
// preload: path.resolve('./preload.js'),
},
}, opt)
let mainWindow = new BrowserWindow(options)
@ -20,9 +31,27 @@ function createWindow (opt = {}) {
console.log('createWindow', opt)
let wurl = url.format({
pathname: `${__dirname}/index.html`,
protocol: 'file:',
query: {
'dev': __DEV__ ? 1 : 0,
'test': '1',
'db': '0',
'gapi': '0',
'od': '0',
'analytics': '0',
'picker': '0',
'mode': 'device',
'browser': '0',
'p': 'electron',
},
slashes: true,
})
//`file://${__dirname}/index.html?dev=1&test=1&db=0&gapi=0&od=0&analytics=0&picker=0&mode=device&browser=0&p=electron`
// and load the index.html of the app.
mainWindow.loadURL(
`file://${__dirname}/index.html?dev=1&test=1&db=0&gapi=0&od=0&analytics=0&picker=0&mode=device&browser=0&p=electron`)
mainWindow.loadURL(wurl)
// Open the DevTools.
mainWindow.webContents.openDevTools()
@ -85,6 +114,7 @@ app.on('ready', e => {
event.returnValue = 'pong'
})
createWindow()
checkUpdate()
})
// Quit when all windows are closed.
@ -106,5 +136,17 @@ app.on('activate', function () {
}
})
// 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.
function checkUpdate () {
autoUpdater.checkForUpdates().then(UpdateCheckResult => {
if (UpdateCheckResult) {
let idx = dialog.showMessageBox({
type: 'question',
buttons: ['Ok', 'Cancel'],
title: 'Confirm Update',
message: 'Update available.\n\nWould you like to download and install new version?',
detail: 'Application will automatically restart to apply update after download',
})
if (idx === 0) return autoUpdater.downloadUpdate()
}
})
}

View file

@ -1,32 +1,32 @@
{
"name": "draw.io",
"version": "1.0.0",
"description": "draw.io desktop",
"main": "electron.js",
"scripts":
{
"start": "electron ."
},
"repository":
{
"type": "git",
"url": "git+https://github.com/jgraph/draw.io.git"
},
"keywords": [
"draw.io",
"diagram",
"flowchart",
"UML"
],
"author": "JGraph",
"license": "GPL-3.0",
"bugs":
{
"url": "https://github.com/jgraph/draw.io/issues"
},
"homepage": "https://github.com/jgraph/draw.io",
"devDependencies":
{
"electron": "^1.4.13"
}
}
"name": "draw.io",
"version": "6.2.1",
"description": "draw.io desktop",
"main": "electron.js",
"scripts": {
"start": "electron ."
},
"repository": {
"type": "git",
"url": "git+https://github.com/jgraph/draw.io.git"
},
"keywords": [
"draw.io",
"diagram",
"flowchart",
"UML"
],
"author": "JGraph",
"license": "GPL-3.0",
"bugs": {
"url": "https://github.com/jgraph/draw.io/issues"
},
"homepage": "https://github.com/jgraph/draw.io",
"dependencies": {
"electron-log": "^1.3.0",
"electron-updater": "^1.8.1"
},
"devDependencies": {
"electron": "^1.6.2"
}
}