Skip to content

Commit

Permalink
Test with auto update
Browse files Browse the repository at this point in the history
  • Loading branch information
Iago Cavalcante committed Jul 25, 2018
1 parent 6dcf950 commit 1486462
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
7 changes: 7 additions & 0 deletions quasar.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,13 @@ module.exports = function (ctx) {
// https://www.electron.build/configuration/configuration

// appId: 'quasar-app'
win: {
target: 'nsis',
arch: [
'x64',
'ia32'
]
}
}
}
}
Expand Down
58 changes: 56 additions & 2 deletions src-electron/main-process/electron-main.js
Original file line number Diff line number Diff line change
@@ -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'
/**
Expand All @@ -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
Expand All @@ -33,7 +87,7 @@ function createWindow () {
mainWindow.on('closed', () => {
mainWindow = null
})

server.listen(defaultPath)
}

Expand Down
2 changes: 1 addition & 1 deletion src/layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default {
display: none;
}
.minimize {
margin-left: 29em;
margin-left: 22em;
}
.background{
background: #fff url(../statics/darkrola.jpeg);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/musics.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<div class="row" v-else>
<div class="col-md-12 row justify-center q-mb-md">
<q-card inline class="col-md-10" color="purple">
<h2>Don't find any videos in your app!!</h2>
<h2>Don't find any musics in your app!!</h2>
</q-card>
</div>
</div>
Expand Down

0 comments on commit 1486462

Please sign in to comment.