mirror of
https://github.com/AltarikMC/Launcher
synced 2024-11-22 06:19:50 +01:00
commit
52d2b8aab8
68
src/client/assets/css/checkingUpdate.css
Normal file
68
src/client/assets/css/checkingUpdate.css
Normal file
@ -0,0 +1,68 @@
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
html{
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body{
|
||||
background-color: black;
|
||||
background-image: url("../images/background.jpg");
|
||||
background-size: cover;
|
||||
background-repeat: no-repeat;
|
||||
margin:0;
|
||||
height:100%;
|
||||
font-family: "Roboto", sans-serif;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.dots-3 {
|
||||
width: 60px;
|
||||
aspect-ratio: 2;
|
||||
--_g: no-repeat radial-gradient(circle closest-side,#000 90%,#0000);
|
||||
background:
|
||||
var(--_g) 0% 50%,
|
||||
var(--_g) 50% 50%,
|
||||
var(--_g) 100% 50%;
|
||||
background-size: calc(100%/3) 50%;
|
||||
animation: d3 1s infinite linear;
|
||||
position: relative;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
|
||||
@keyframes d3 {
|
||||
20%{background-position:0% 0%, 50% 50%,100% 50%}
|
||||
40%{background-position:0% 100%, 50% 0%,100% 50%}
|
||||
60%{background-position:0% 50%, 50% 100%,100% 0%}
|
||||
80%{background-position:0% 50%, 50% 50%,100% 100%}
|
||||
}
|
||||
|
||||
#fullscreen {
|
||||
position: absolute;
|
||||
top: 28px;
|
||||
width: 100%;
|
||||
height: calc(100% - 28px);
|
||||
background-color: rgba(0, 0, 0, 0.6);
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
#close {
|
||||
position: absolute;
|
||||
top: 28px;
|
||||
left: 5px;
|
||||
color: white;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#fullscreen-content {
|
||||
position: relative;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
width: 100%;
|
||||
background: white;
|
||||
max-height: 80vh;
|
||||
text-align: center;
|
||||
padding: 25px 0;
|
||||
}
|
25
src/client/assets/js/checkingUpdate.js
Normal file
25
src/client/assets/js/checkingUpdate.js
Normal file
@ -0,0 +1,25 @@
|
||||
const vue = require('vue/dist/vue.cjs.js')
|
||||
app = vue.createApp({
|
||||
data() {
|
||||
return {
|
||||
displayFullscreen: "block",
|
||||
fullscreenText: "Checking for updates..."
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
},
|
||||
methods: {
|
||||
sendCheckingUpdate() {
|
||||
ipcRenderer.send("checking-update");
|
||||
},
|
||||
closeFullscreen () {
|
||||
this.displayFullscreen = "none"
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
app.mount("#vue");
|
||||
|
||||
ipcRenderer.on("update-available", (event, arg) => {
|
||||
this.fullscreenText = "Mise à jour disponible, téléchargement..."
|
||||
});
|
@ -1,5 +1,6 @@
|
||||
const os = require('os')
|
||||
const totalMem = os.totalmem() / (1.049 * Math.pow(10, 6))
|
||||
const vue = require('vue/dist/vue.cjs.js')
|
||||
|
||||
app = vue.createApp({
|
||||
data() {
|
||||
|
@ -1,3 +1,4 @@
|
||||
const vue = require('vue/dist/vue.cjs.js')
|
||||
app = vue.createApp({
|
||||
data() {
|
||||
return {
|
||||
|
@ -1,6 +1,5 @@
|
||||
'use strict';
|
||||
const { ipcRenderer } = require('electron');
|
||||
const vue = require('vue/dist/vue.cjs.js')
|
||||
let app;
|
||||
window.addEventListener("DOMContentLoaded", () => {
|
||||
const minimizeButton = document.getElementById("minimize-btn")
|
||||
|
36
src/client/checkingUpdate.html
Normal file
36
src/client/checkingUpdate.html
Normal file
@ -0,0 +1,36 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Altarik Launcher</title>
|
||||
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline' 'unsafe-eval';" />
|
||||
<link rel="stylesheet" href="../../node_modules/izitoast/dist/css/iziToast.min.css">
|
||||
<link href="assets/css/fonts.css" rel="stylesheet" />
|
||||
<link href="assets/css/checkingUpdate.css" rel="stylesheet" />
|
||||
<link href="assets/css/menubar.css" rel="stylesheet" />
|
||||
<!-- <link rel="shortcut icon" type="image/png" href="assets/images/icon.png"/> -->
|
||||
</head>
|
||||
<body>
|
||||
<div id="vue">
|
||||
<div id="menubar">
|
||||
<ul class="left">
|
||||
<img src="../../icon.ico">
|
||||
</ul>
|
||||
<ul class="right">
|
||||
<!-- Mettre ce code en ligne pour éviter que chrome ne met un espace automatiquement entre les éléments -->
|
||||
<li id="minimize-btn"><i class="material-icons">minimize</i></li><!--<li id="max-unmax-btn"><i class="material-icons">crop_square</i></li>--><li id="close-btn"><i class="material-icons">close</i></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="fullscreen" :style="{ display: displayFullscreen }">
|
||||
<div @click="closeFullscreen" id="close"><i class="material-icons">close</i></div>
|
||||
<div id="fullscreen-content">
|
||||
<p>{{ fullscreenText }}</p>
|
||||
<div class="dots-3"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="../../node_modules/izitoast/dist/js/iziToast.js" type="text/javascript"></script>
|
||||
<script src="assets/js/preload.js"></script>
|
||||
<script src="assets/js/checkingUpdate.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -1,6 +1,9 @@
|
||||
const { app, BrowserWindow, Menu, ipcMain, autoUpdater, dialog } = require('electron')
|
||||
const logger = require('electron-log')
|
||||
const { join } = require('path')
|
||||
const updater = require('./updater.js')
|
||||
let updaterInstance = null
|
||||
|
||||
|
||||
if (require('electron-squirrel-startup')) {
|
||||
require("./install.js").handleSquirrelEvent(app)
|
||||
@ -26,8 +29,9 @@ function createWindow () {
|
||||
frame: false
|
||||
})
|
||||
//Menu.setApplicationMenu(null)
|
||||
win.loadFile('src/client/login.html').then(() => {
|
||||
require('./updater.js').configUpdater(app, autoUpdater, dialog, logger, showNotification)
|
||||
win.loadFile('src/client/checkingUpdate.html').then(() => {
|
||||
updaterInstance = new updater.Updater(app, win, autoUpdater, dialog, logger, showNotification)
|
||||
updaterInstance.configUpdater()
|
||||
})
|
||||
win.on("close", () => {
|
||||
app.quit()
|
||||
@ -91,3 +95,7 @@ ipcMain.on("pageReady", (event) => {
|
||||
event.sender.send("nick", { name: minecraft.auth.name })
|
||||
minecraft.getModsInformations(event)
|
||||
})
|
||||
|
||||
ipcMain.on("checking-update", () => {
|
||||
updaterInstance.checkForUpdates(win, showNotification)
|
||||
})
|
@ -2,52 +2,65 @@ const isDev = require('electron-is-dev')
|
||||
const pkg = require('../../package.json')
|
||||
const server = 'https://update.electronjs.org'
|
||||
|
||||
function configUpdater(app, autoUpdater, dialog, logger, showNotification) {
|
||||
logger.info(`electron version: ${process.versions['electron']}`)
|
||||
logger.info(`chrome version: ${process.versions['chrome']}`)
|
||||
logger.info(`Node version: ${process.versions['node']}`)
|
||||
logger.info(`platform: ${process.platform}`)
|
||||
logger.info(`arch: ${process.arch}`)
|
||||
if(isDev) {
|
||||
logger.info(`developpement version ${app.getVersion()}`)
|
||||
return
|
||||
class Updater {
|
||||
|
||||
constructor(app, win, autoUpdater, dialog, logger, ipcMain) {
|
||||
this.app = app
|
||||
this.win = win
|
||||
this.autoUpdater = autoUpdater
|
||||
this.dialog = dialog
|
||||
this.logger = logger
|
||||
this.ipcMain = ipcMain
|
||||
}
|
||||
logger.info(`production version ${app.getVersion()}`)
|
||||
|
||||
const feed = `${server}/${pkg.repository}/${process.platform}-${process.arch}/${app.getVersion()}`
|
||||
autoUpdater.setFeedURL(feed)
|
||||
logger.info("Checking for update...")
|
||||
autoUpdater.checkForUpdates()
|
||||
|
||||
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.'
|
||||
configUpdater() {
|
||||
this.logger.info(`electron version: ${process.versions['electron']}`)
|
||||
this.logger.info(`chrome version: ${process.versions['chrome']}`)
|
||||
this.logger.info(`Node version: ${process.versions['node']}`)
|
||||
this.logger.info(`platform: ${process.platform}`)
|
||||
this.logger.info(`arch: ${process.arch}`)
|
||||
if(isDev) {
|
||||
this.logger.info(`developpement version ${this.app.getVersion()}`)
|
||||
this.win.loadFile('src/client/login.html')
|
||||
return
|
||||
}
|
||||
this.logger.info(`production version ${this.app.getVersion()}`)
|
||||
|
||||
dialog.showMessageBox(dialogOpts).then((returnValue) => {
|
||||
if (returnValue.response === 0) {
|
||||
logger.info("Leaving application to install update...")
|
||||
autoUpdater.quitAndInstall()
|
||||
}
|
||||
const feed = `${server}/${pkg.repository}/${process.platform}-${process.arch}/${this.app.getVersion()}`
|
||||
this.autoUpdater.setFeedURL(feed)
|
||||
|
||||
// TODO : replace dialog by automatic restart
|
||||
this.autoUpdater.on('update-downloaded', (_event, releaseNotes, releaseName) => {
|
||||
this.logger.info(`update downloaded ${releaseName}`)
|
||||
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')
|
||||
logger.error(message)
|
||||
})
|
||||
}
|
||||
|
||||
checkForUpdates(win, showNotification) {
|
||||
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 = {
|
||||
configUpdater
|
||||
Updater
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user