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:
parent
7bfcab4610
commit
48e77b11ce
@ -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,
|
|
||||||
}
|
|
@ -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())
|
|
||||||
})
|
})
|
||||||
|
@ -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
21
src/server/menubar.js
Normal 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
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user