mirror of
https://github.com/AltarikMC/Launcher
synced 2024-11-22 06:19:50 +01:00
Updated updater.js
This commit is contained in:
parent
8e6b490c07
commit
0001b54e15
@ -1,3 +1,4 @@
|
|||||||
|
const vue = require('vue/dist/vue.cjs.js')
|
||||||
app = vue.createApp({
|
app = vue.createApp({
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@ -19,6 +20,6 @@ app = vue.createApp({
|
|||||||
|
|
||||||
app.mount("#vue");
|
app.mount("#vue");
|
||||||
|
|
||||||
ipcRenderer.on("update-status", (event, arg) => {
|
ipcRenderer.on("update-available", (event, arg) => {
|
||||||
|
this.fullscreenText = "Mise à jour disponible, téléchargement..."
|
||||||
});
|
});
|
@ -1,5 +1,6 @@
|
|||||||
const os = require('os')
|
const os = require('os')
|
||||||
const totalMem = os.totalmem() / (1.049 * Math.pow(10, 6))
|
const totalMem = os.totalmem() / (1.049 * Math.pow(10, 6))
|
||||||
|
const vue = require('vue/dist/vue.cjs.js')
|
||||||
|
|
||||||
app = vue.createApp({
|
app = vue.createApp({
|
||||||
data() {
|
data() {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
const vue = require('vue/dist/vue.cjs.js')
|
||||||
app = vue.createApp({
|
app = vue.createApp({
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const { ipcRenderer } = require('electron');
|
const { ipcRenderer } = require('electron');
|
||||||
const vue = require('vue/dist/vue.cjs.js')
|
|
||||||
let app;
|
let app;
|
||||||
window.addEventListener("DOMContentLoaded", () => {
|
window.addEventListener("DOMContentLoaded", () => {
|
||||||
const minimizeButton = document.getElementById("minimize-btn")
|
const minimizeButton = document.getElementById("minimize-btn")
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
const { app, BrowserWindow, Menu, ipcMain, autoUpdater, dialog } = require('electron')
|
const { app, BrowserWindow, Menu, ipcMain, autoUpdater, dialog } = require('electron')
|
||||||
const logger = require('electron-log')
|
const logger = require('electron-log')
|
||||||
const { join } = require('path')
|
const { join } = require('path')
|
||||||
|
const updater = require('./updater.js')
|
||||||
|
let updaterInstance = null
|
||||||
|
|
||||||
|
|
||||||
if (require('electron-squirrel-startup')) {
|
if (require('electron-squirrel-startup')) {
|
||||||
require("./install.js").handleSquirrelEvent(app)
|
require("./install.js").handleSquirrelEvent(app)
|
||||||
@ -27,7 +30,8 @@ function createWindow () {
|
|||||||
})
|
})
|
||||||
//Menu.setApplicationMenu(null)
|
//Menu.setApplicationMenu(null)
|
||||||
win.loadFile('src/client/checkingUpdate.html').then(() => {
|
win.loadFile('src/client/checkingUpdate.html').then(() => {
|
||||||
require('./updater.js').configUpdater(app, autoUpdater, dialog, logger, showNotification)
|
updaterInstance = new updater.Updater(app, win, autoUpdater, dialog, logger, showNotification)
|
||||||
|
updaterInstance.configUpdater()
|
||||||
})
|
})
|
||||||
win.on("close", () => {
|
win.on("close", () => {
|
||||||
app.quit()
|
app.quit()
|
||||||
@ -91,3 +95,7 @@ ipcMain.on("pageReady", (event) => {
|
|||||||
event.sender.send("nick", { name: minecraft.auth.name })
|
event.sender.send("nick", { name: minecraft.auth.name })
|
||||||
minecraft.getModsInformations(event)
|
minecraft.getModsInformations(event)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
ipcMain.on("checking-update", () => {
|
||||||
|
updaterInstance.checkForUpdates(win, showNotification)
|
||||||
|
})
|
@ -2,52 +2,76 @@ const isDev = require('electron-is-dev')
|
|||||||
const pkg = require('../../package.json')
|
const pkg = require('../../package.json')
|
||||||
const server = 'https://update.electronjs.org'
|
const server = 'https://update.electronjs.org'
|
||||||
|
|
||||||
function configUpdater(app, autoUpdater, dialog, logger, showNotification) {
|
class Updater {
|
||||||
logger.info(`electron version: ${process.versions['electron']}`)
|
|
||||||
logger.info(`chrome version: ${process.versions['chrome']}`)
|
constructor(app, win, autoUpdater, dialog, logger, ipcMain) {
|
||||||
logger.info(`Node version: ${process.versions['node']}`)
|
this.app = app
|
||||||
logger.info(`platform: ${process.platform}`)
|
this.win = win
|
||||||
logger.info(`arch: ${process.arch}`)
|
this.autoUpdater = autoUpdater
|
||||||
if(isDev) {
|
this.dialog = dialog
|
||||||
logger.info(`developpement version ${app.getVersion()}`)
|
this.logger = logger
|
||||||
return
|
this.ipcMain = ipcMain
|
||||||
}
|
}
|
||||||
logger.info(`production version ${app.getVersion()}`)
|
|
||||||
|
|
||||||
const feed = `${server}/${pkg.repository}/${process.platform}-${process.arch}/${app.getVersion()}`
|
configUpdater() {
|
||||||
autoUpdater.setFeedURL(feed)
|
this.logger.info(`electron version: ${process.versions['electron']}`)
|
||||||
logger.info("Checking for update...")
|
this.logger.info(`chrome version: ${process.versions['chrome']}`)
|
||||||
autoUpdater.checkForUpdates()
|
this.logger.info(`Node version: ${process.versions['node']}`)
|
||||||
|
this.logger.info(`platform: ${process.platform}`)
|
||||||
autoUpdater.on('update-downloaded', (_event, releaseNotes, releaseName) => {
|
this.logger.info(`arch: ${process.arch}`)
|
||||||
const dialogOpts = {
|
if(isDev) {
|
||||||
type: 'info',
|
this.logger.info(`developpement version ${this.app.getVersion()}`)
|
||||||
buttons: ['Rédémarrer', 'Plus tard'],
|
this.win.loadFile('src/client/login.html')
|
||||||
title: 'Une mise à jour du launcher est disponible',
|
return
|
||||||
message: process.platform === 'win32' ? releaseNotes : releaseName,
|
|
||||||
detail: 'Une nouvelle version du launcher a été téléchargé. Redémarrez l\'application pour appliquer les mises à jour.'
|
|
||||||
}
|
}
|
||||||
|
this.logger.info(`production version ${this.app.getVersion()}`)
|
||||||
|
|
||||||
dialog.showMessageBox(dialogOpts).then((returnValue) => {
|
const feed = `${server}/${pkg.repository}/${process.platform}-${process.arch}/${this.app.getVersion()}`
|
||||||
if (returnValue.response === 0) {
|
this.autoUpdater.setFeedURL(feed)
|
||||||
logger.info("Leaving application to install update...")
|
|
||||||
autoUpdater.quitAndInstall()
|
// TODO : replace dialog by automatic restart
|
||||||
|
this.autoUpdater.on('update-downloaded', (_event, releaseNotes, releaseName) => {
|
||||||
|
const dialogOpts = {
|
||||||
|
type: 'info',
|
||||||
|
buttons: ['Rédémarrer', 'Plus tard'],
|
||||||
|
title: 'Une mise à jour du launcher est disponible',
|
||||||
|
message: process.platform === 'win32' ? releaseNotes : releaseName,
|
||||||
|
detail: 'Une nouvelle version du launcher a été téléchargé. Redémarrez l\'application pour appliquer les mises à jour.'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.dialog.showMessageBox(dialogOpts).then((returnValue) => {
|
||||||
|
if (returnValue.response === 0) {
|
||||||
|
this.logger.info("Leaving application to install update...")
|
||||||
|
this.autoUpdater.quitAndInstall()
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
|
||||||
autoUpdater.on('error', message => {
|
}
|
||||||
showNotification("Impossible de mettre à jour le launcher", "vérifier votre connexion", "warning")
|
|
||||||
logger.error('There was a problem updating the application')
|
checkForUpdates(win, showNotification) {
|
||||||
logger.error(message)
|
this.logger.info("Checking for update...")
|
||||||
})
|
this.autoUpdater.checkForUpdates()
|
||||||
|
this.autoUpdater.on('error', message => {
|
||||||
|
this.logger.error('There was a problem updating the application')
|
||||||
|
this.logger.error(message)
|
||||||
|
win.loadFile('src/client/login.html').then(() => {
|
||||||
|
showNotification("Une erreur est survenue lors de la vérification de la mise à jour", "Veuillez vérifier votre connexion internet et réessayer", "error")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
this.autoUpdater.on('update-available', () => {
|
||||||
|
this.logger.info("update available, downloading...")
|
||||||
|
win.webContents.send("update-available")
|
||||||
|
})
|
||||||
|
this.autoUpdater.on("update-not-available", () => {
|
||||||
|
this.logger.info("update not available")
|
||||||
|
win.loadFile('src/client/login.html')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
autoUpdater.on('update-available', () => {
|
|
||||||
showNotification("Mise à jour", "Téléchargement de la mise à jour", "warning")
|
|
||||||
logger.info("update available, downloading...")
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
configUpdater
|
Updater
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user