4
0
mirror of https://github.com/AltarikMC/Launcher synced 2024-11-21 06:09:51 +01:00

deleted last use of remote

This commit is contained in:
Quentin Legot 2021-03-03 14:06:17 +01:00
parent 7bfcab4610
commit 48e77b11ce
4 changed files with 39 additions and 33 deletions

View File

@ -1,21 +0,0 @@
const { remote } = require('electron')
function getCurrentWindow() {
return remote.getCurrentWindow()
}
function minimizeWindow(browserWindow = getCurrentWindow()) {
if (browserWindow.minimizable) {
browserWindow.minimize()
}
}
function closeWindow(browserWindow = getCurrentWindow()) {
browserWindow.close()
}
module.exports = {
getCurrentWindow,
minimizeWindow,
closeWindow,
}

View File

@ -1,21 +1,11 @@
'use strict'; 'use strict';
const {ipcRenderer} = require('electron'); const {ipcRenderer} = require('electron');
const {
getCurrentWindow,
minimizeWindow,
closeWindow,
} = require("./assets/js/menubar.js");
window.addEventListener("DOMContentLoaded", () => { window.addEventListener("DOMContentLoaded", () => {
window.getCurrentWindow = getCurrentWindow
window.minimizeWindow = minimizeWindow
window.closeWindow = closeWindow
const minimizeButton = document.getElementById("minimize-btn") const minimizeButton = document.getElementById("minimize-btn")
const closeButton = document.getElementById("close-btn") const closeButton = document.getElementById("close-btn")
minimizeButton.addEventListener("click", e => window.minimizeWindow()) minimizeButton.addEventListener("click", e => ipcRenderer.send('minimizeWindow'))
// maxUnmaxButton.addEventListener("click", e => window.maxUnmaxWindow()) closeButton.addEventListener("click", e => ipcRenderer.send('closeWindow'))
closeButton.addEventListener("click", e => window.closeWindow())
}) })

View File

@ -39,6 +39,14 @@ function createWindow () {
win.loadFile('src/client/login.html') win.loadFile('src/client/login.html')
} }
const {
setWindow,
minimizeWindow,
closeWindow
} = require("./menubar.js");
setWindow(win)
app.whenReady().then(() => { app.whenReady().then(() => {
createWindow() createWindow()
}) })
@ -49,6 +57,14 @@ app.on('window-all-closed', () => {
} }
}) })
ipcMain.on('minimizeWindow', () => {
minimizeWindow(win)
})
ipcMain.on('closeWindow', () => {
closeWindow(win)
})
app.on('activate', () => { app.on('activate', () => {
if (win === null){ if (win === null){
createWindow() createWindow()

21
src/server/menubar.js Normal file
View File

@ -0,0 +1,21 @@
let win;
function setWindow(browserWindow) {
win = browserWindow;
}
function minimizeWindow(browserWindow = win) {
if(browserWindow.minimizable) {
browserWindow.minimize()
}
}
function closeWindow(browserWindow = win) {
browserWindow.close()
}
module.exports = {
setWindow,
minimizeWindow,
closeWindow
}