4
0
mirror of https://github.com/AltarikMC/Launcher synced 2024-11-22 06:19:50 +01:00

Fix updater on linux, should download text on windows, dump to 2.0.2

This commit is contained in:
Quentin Legot 2022-10-14 15:34:30 +02:00
parent d13bee0dd1
commit 607cf9e68f
6 changed files with 20 additions and 12 deletions

View File

@ -1,7 +1,7 @@
{ {
"name": "altarik-launcher", "name": "altarik-launcher",
"author": "Altarik", "author": "Altarik",
"version": "2.0.1", "version": "2.0.2",
"description": "Altarik Launcher", "description": "Altarik Launcher",
"main": "src/server/main.js", "main": "src/server/main.js",
"homepage": "https://altarik.fr/", "homepage": "https://altarik.fr/",

View File

@ -3,7 +3,8 @@ app = vue.createApp({
data() { data() {
return { return {
displayFullscreen: "block", displayFullscreen: "block",
fullscreenText: "Recherche de mise à jour..." fullscreenText: "Recherche de mise à jour...",
downloadLink: null
} }
}, },
mounted() { mounted() {
@ -12,16 +13,20 @@ app = vue.createApp({
methods: { methods: {
sendCheckingUpdate() { sendCheckingUpdate() {
ipcRenderer.send("checking-update"); ipcRenderer.send("checking-update");
},
openLinkExternal() {
shell.openExternal(this.downloadLink)
} }
}, },
}); });
app.mount("#vue"); let root = app.mount("#vue");
ipcRenderer.on("update-available", (event, arg) => { 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) => { ipcRenderer.on("please-download-update", (event, args) => {
app.fullscreenText = `Veuillez télécharger la mise à jour en cliquant sur le lien suivant: <a href="${args.url}">${args.url}</a>` root.fullscreenText = `Veuillez télécharger la mise à jour en cliquant sur le lien suivant :`
root.downloadLink = `${args.url}`
}) })

View File

@ -1,5 +1,5 @@
'use strict'; 'use strict';
const { ipcRenderer } = require('electron'); const { ipcRenderer, shell } = require('electron');
let app; let app;
window.addEventListener("DOMContentLoaded", () => { window.addEventListener("DOMContentLoaded", () => {
const minimizeButton = document.getElementById("minimize-btn") const minimizeButton = document.getElementById("minimize-btn")

View File

@ -23,7 +23,7 @@
</div> </div>
<div id="fullscreen" :style="{ display: displayFullscreen }"> <div id="fullscreen" :style="{ display: displayFullscreen }">
<div id="fullscreen-content"> <div id="fullscreen-content">
<p>{{ fullscreenText }}</p> <p>{{ fullscreenText }} <br /><a @click="openLinkExternal" v-if="downloadLink !== null" href="#">{{ downloadLink }}</a></p>
<div class="dots-3"></div> <div class="dots-3"></div>
</div> </div>
</div> </div>

View File

@ -28,7 +28,7 @@ function createWindow () {
}, },
frame: false frame: false
}) })
Menu.setApplicationMenu(null) //Menu.setApplicationMenu(null)
win.loadFile('src/client/checkingUpdate.html') win.loadFile('src/client/checkingUpdate.html')
win.on("close", () => { win.on("close", () => {
app.quit() app.quit()

View File

@ -67,16 +67,19 @@ class Updater {
if(response.status === 200) { if(response.status === 200) {
response.json().then(json => { response.json().then(json => {
if(json.tag_name !== pkg.version) { if(json.tag_name !== pkg.version) {
let asset = json.assets.filter(el => el.browser_download_url.inludes(".zip")) let asset = json.assets.filter(el => el.browser_download_url.includes(".zip"))
if(asset.length === 1) { if(asset.length === 1) {
let downloadUrl = asset[0].browser_download_url let downloadUrl = asset[0].browser_download_url
win.webContents.send("please-download-update", { url: downloadUrl} ) win.webContents.send("please-download-update", { url: downloadUrl} )
this.logger.info("update available, please download")
} else { } else {
this.displayError(win, showNotification, "Can't find right asset in last update") 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 { } else {
this.displayError(win, showNotification, "Server unavailable") this.displayError(win, showNotification, "Server unavailable")
} }