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

removed mentions of electron.remote (still one left)

This commit is contained in:
Quentin Legot 2021-03-02 15:22:38 +01:00
parent 5f58118537
commit 7bfcab4610
3 changed files with 2 additions and 29 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
node_modules/ node_modules/
game game
out/ out/
.vscode/

View File

@ -1,5 +1,4 @@
const { remote } = require('electron') const { remote } = require('electron')
const {Menu, BrowserWindow, MenuItem, shell} = remote
function getCurrentWindow() { function getCurrentWindow() {
return remote.getCurrentWindow() return remote.getCurrentWindow()
@ -7,36 +6,16 @@ function getCurrentWindow() {
function minimizeWindow(browserWindow = getCurrentWindow()) { function minimizeWindow(browserWindow = getCurrentWindow()) {
if (browserWindow.minimizable) { if (browserWindow.minimizable) {
// browserWindow.isMinimizable() for old electron versions
browserWindow.minimize() browserWindow.minimize()
} }
} }
function unmaximizeWindow(browserWindow = getCurrentWindow()) {
browserWindow.unmaximize()
}
function maxUnmaxWindow(browserWindow = getCurrentWindow()) {
if (browserWindow.isMaximized()) {
browserWindow.unmaximize()
} else {
browserWindow.maximize()
}
}
function closeWindow(browserWindow = getCurrentWindow()) { function closeWindow(browserWindow = getCurrentWindow()) {
browserWindow.close() browserWindow.close()
} }
function isWindowMaximized(browserWindow = getCurrentWindow()) {
return browserWindow.isMaximized()
}
module.exports = { module.exports = {
getCurrentWindow, getCurrentWindow,
minimizeWindow, minimizeWindow,
unmaximizeWindow,
maxUnmaxWindow,
isWindowMaximized,
closeWindow, closeWindow,
} }

View File

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