From 607cf9e68fe01b685fcd81030040fe55b1b3a149 Mon Sep 17 00:00:00 2001 From: Quentin Legot Date: Fri, 14 Oct 2022 15:34:30 +0200 Subject: [PATCH] Fix updater on linux, should download text on windows, dump to 2.0.2 --- package.json | 2 +- src/client/assets/js/checkingUpdate.js | 13 +++++++++---- src/client/assets/js/preload.js | 2 +- src/client/checkingUpdate.html | 2 +- src/server/main.js | 2 +- src/server/updater.js | 11 +++++++---- 6 files changed, 20 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 3479555..13a0742 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "altarik-launcher", "author": "Altarik", - "version": "2.0.1", + "version": "2.0.2", "description": "Altarik Launcher", "main": "src/server/main.js", "homepage": "https://altarik.fr/", diff --git a/src/client/assets/js/checkingUpdate.js b/src/client/assets/js/checkingUpdate.js index b1977f5..f5386f4 100644 --- a/src/client/assets/js/checkingUpdate.js +++ b/src/client/assets/js/checkingUpdate.js @@ -3,7 +3,8 @@ app = vue.createApp({ data() { return { displayFullscreen: "block", - fullscreenText: "Recherche de mise à jour..." + fullscreenText: "Recherche de mise à jour...", + downloadLink: null } }, mounted() { @@ -12,16 +13,20 @@ app = vue.createApp({ methods: { sendCheckingUpdate() { ipcRenderer.send("checking-update"); + }, + openLinkExternal() { + shell.openExternal(this.downloadLink) } }, }); -app.mount("#vue"); +let root = app.mount("#vue"); ipcRenderer.on("update-available", (event, arg) => { - app.fullscreenText = "Mise à jour disponible, téléchargement..." + root.fullscreenText = "Mise à jour disponible, téléchargement..." }); ipcRenderer.on("please-download-update", (event, args) => { - app.fullscreenText = `Veuillez télécharger la mise à jour en cliquant sur le lien suivant: ${args.url}` + root.fullscreenText = `Veuillez télécharger la mise à jour en cliquant sur le lien suivant :` + root.downloadLink = `${args.url}` }) \ No newline at end of file diff --git a/src/client/assets/js/preload.js b/src/client/assets/js/preload.js index 4fd6d9a..feb32a5 100644 --- a/src/client/assets/js/preload.js +++ b/src/client/assets/js/preload.js @@ -1,5 +1,5 @@ 'use strict'; -const { ipcRenderer } = require('electron'); +const { ipcRenderer, shell } = require('electron'); let app; window.addEventListener("DOMContentLoaded", () => { const minimizeButton = document.getElementById("minimize-btn") diff --git a/src/client/checkingUpdate.html b/src/client/checkingUpdate.html index ecd3e3a..1075d1d 100644 --- a/src/client/checkingUpdate.html +++ b/src/client/checkingUpdate.html @@ -23,7 +23,7 @@
-

{{ fullscreenText }}

+

{{ fullscreenText }}
{{ downloadLink }}

diff --git a/src/server/main.js b/src/server/main.js index a001ac9..8f2ac01 100644 --- a/src/server/main.js +++ b/src/server/main.js @@ -28,7 +28,7 @@ function createWindow () { }, frame: false }) - Menu.setApplicationMenu(null) + //Menu.setApplicationMenu(null) win.loadFile('src/client/checkingUpdate.html') win.on("close", () => { app.quit() diff --git a/src/server/updater.js b/src/server/updater.js index 894b6a2..3ba55a2 100644 --- a/src/server/updater.js +++ b/src/server/updater.js @@ -67,16 +67,19 @@ class Updater { if(response.status === 200) { response.json().then(json => { if(json.tag_name !== pkg.version) { - let asset = json.assets.filter(el => el.browser_download_url.inludes(".zip")) - if(asset.length ===1) { + let asset = json.assets.filter(el => el.browser_download_url.includes(".zip")) + if(asset.length === 1) { let downloadUrl = asset[0].browser_download_url win.webContents.send("please-download-update", { url: downloadUrl} ) + this.logger.info("update available, please download") } else { this.displayError(win, showNotification, "Can't find right asset in last update") } + } else { + this.logger.info("update not available") + win.loadFile('src/client/login.html') } - }).catch(err => this.displayError(win, showNotification, err) - ) + }).catch(err => this.displayError(win, showNotification, err)) } else { this.displayError(win, showNotification, "Server unavailable") }