From 14864629b9acd0b0017336bf4e29774333ad6964 Mon Sep 17 00:00:00 2001 From: Iago Cavalcante Date: Wed, 25 Jul 2018 15:45:03 -0300 Subject: [PATCH] Test with auto update --- package.json | 2 +- quasar.conf.js | 7 +++ src-electron/main-process/electron-main.js | 58 +++++++++++++++++++++- src/layouts/default.vue | 2 +- src/pages/musics.vue | 2 +- 5 files changed, 66 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 6b57871..56b753a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "qtube", - "version": "1.0.0", + "version": "0.0.1", "description": "App to copy link and paste, download from youtube", "productName": "QTube", "cordovaId": "br.com.qtube.app", diff --git a/quasar.conf.js b/quasar.conf.js index b8b091c..71bc852 100644 --- a/quasar.conf.js +++ b/quasar.conf.js @@ -153,6 +153,13 @@ module.exports = function (ctx) { // https://www.electron.build/configuration/configuration // appId: 'quasar-app' + win: { + target: 'nsis', + arch: [ + 'x64', + 'ia32' + ] + } } } } diff --git a/src-electron/main-process/electron-main.js b/src-electron/main-process/electron-main.js index df4edf4..2422f20 100644 --- a/src-electron/main-process/electron-main.js +++ b/src-electron/main-process/electron-main.js @@ -1,4 +1,4 @@ -import { app, BrowserWindow, ipcMain } from 'electron' +import { app, BrowserWindow, ipcMain, autoUpdater, dialog } from 'electron' import server from './server/server.js' import fs from 'fs' /** @@ -13,6 +13,60 @@ const defaultPath = `${app.getPath('downloads')}/Ytdown/`.replace(/\\/g, '/') let mainWindow +const urlUpdate = 'https://api.github.com/repos/iagocavalcante/qtube/releases/latest' + +const startAutoUpdater = (squirrelUrl) => { + autoUpdater.setFeedURL(squirrelUrl) + + autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => { + const dialogOpts = { + type: 'info', + buttons: ['Restart', 'Later'], + title: 'Application Update', + message: process.platform === 'win32' ? releaseNotes : releaseName, + detail: 'A new version has been downloaded. Restart the application to apply the updates.' + } + + dialog.showMessageBox(dialogOpts, (response) => { + if (response === 0) autoUpdater.quitAndInstall() + }) + }) + + autoUpdater.on('error', message => { + console.error('There was a problem updating the application') + console.error(message) + }) + + + setInterval(() => { + autoUpdater.checkForUpdates() + }, 60000) +} + +const handleSquirrelEvent = () => { + if (process.argv.length === 1) { + return false; + } + + const squirrelEvent = process.argv[1]; + switch (squirrelEvent) { + case '--squirrel-install': + case '--squirrel-updated': + case '--squirrel-uninstall': + setTimeout(app.quit, 1000); + return true; + + case '--squirrel-obsolete': + app.quit(); + return true; + } +} + +if (handleSquirrelEvent()) { + // squirrel event handled and app will exit in 1000ms, so don't do anything else + app.quit(); +} + function createWindow () { /** * Initial window options @@ -33,7 +87,7 @@ function createWindow () { mainWindow.on('closed', () => { mainWindow = null }) - + server.listen(defaultPath) } diff --git a/src/layouts/default.vue b/src/layouts/default.vue index 433d45e..260eff9 100644 --- a/src/layouts/default.vue +++ b/src/layouts/default.vue @@ -69,7 +69,7 @@ export default { display: none; } .minimize { - margin-left: 29em; + margin-left: 22em; } .background{ background: #fff url(../statics/darkrola.jpeg); diff --git a/src/pages/musics.vue b/src/pages/musics.vue index 2fe972c..cfab687 100644 --- a/src/pages/musics.vue +++ b/src/pages/musics.vue @@ -31,7 +31,7 @@
-

Don't find any videos in your app!!

+

Don't find any musics in your app!!