- handle submodule npm tasks

- autoupdate dialog
This commit is contained in:
mediaslav 2017-03-04 17:11:12 +03:00
parent 1ede2cda58
commit 00fe005ecc
2 changed files with 77 additions and 35 deletions

View file

@ -1,11 +1,19 @@
const fs = require('fs') const fs = require('fs')
const path = require('path') const path = require('path')
const url = require('url')
const electron = require('electron') const electron = require('electron')
const ipcMain = electron.ipcMain const ipcMain = electron.ipcMain
const dialog = electron.dialog const dialog = electron.dialog
const app = electron.app const app = electron.app
const BrowserWindow = electron.BrowserWindow 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 = [] let windowsRegistry = []
function createWindow (opt = {}) { function createWindow (opt = {}) {
@ -13,6 +21,9 @@ function createWindow (opt = {}) {
width: 1600, width: 1600,
height: 1200, height: 1200,
'web-security': false, 'web-security': false,
webPreferences: {
// preload: path.resolve('./preload.js'),
},
}, opt) }, opt)
let mainWindow = new BrowserWindow(options) let mainWindow = new BrowserWindow(options)
@ -20,9 +31,27 @@ function createWindow (opt = {}) {
console.log('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. // and load the index.html of the app.
mainWindow.loadURL( mainWindow.loadURL(wurl)
`file://${__dirname}/index.html?dev=1&test=1&db=0&gapi=0&od=0&analytics=0&picker=0&mode=device&browser=0&p=electron`)
// Open the DevTools. // Open the DevTools.
mainWindow.webContents.openDevTools() mainWindow.webContents.openDevTools()
@ -85,6 +114,7 @@ app.on('ready', e => {
event.returnValue = 'pong' event.returnValue = 'pong'
}) })
createWindow() createWindow()
checkUpdate()
}) })
// Quit when all windows are closed. // 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 function checkUpdate () {
// code. You can also put them in separate files and require them here. 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", "name": "draw.io",
"version": "1.0.0", "version": "6.2.1",
"description": "draw.io desktop", "description": "draw.io desktop",
"main": "electron.js", "main": "electron.js",
"scripts": "scripts": {
{ "start": "electron ."
"start": "electron ." },
}, "repository": {
"repository": "type": "git",
{ "url": "git+https://github.com/jgraph/draw.io.git"
"type": "git", },
"url": "git+https://github.com/jgraph/draw.io.git" "keywords": [
}, "draw.io",
"keywords": [ "diagram",
"draw.io", "flowchart",
"diagram", "UML"
"flowchart", ],
"UML" "author": "JGraph",
], "license": "GPL-3.0",
"author": "JGraph", "bugs": {
"license": "GPL-3.0", "url": "https://github.com/jgraph/draw.io/issues"
"bugs": },
{ "homepage": "https://github.com/jgraph/draw.io",
"url": "https://github.com/jgraph/draw.io/issues" "dependencies": {
}, "electron-log": "^1.3.0",
"homepage": "https://github.com/jgraph/draw.io", "electron-updater": "^1.8.1"
"devDependencies": },
{ "devDependencies": {
"electron": "^1.4.13" "electron": "^1.6.2"
} }
} }