mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-16 12:42:06 +00:00
create sendToFront()
TODO: replace all `webcontents.send ` with `sendToFront = require('../providers/app-controls')`
This commit is contained in:
@ -1,12 +1,10 @@
|
|||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
|
||||||
const is = require("electron-is");
|
|
||||||
|
|
||||||
const { app, BrowserWindow, ipcMain, ipcRenderer } = require("electron");
|
const { app, BrowserWindow, ipcMain, ipcRenderer } = require("electron");
|
||||||
const config = require("../config");
|
const config = require("../config");
|
||||||
|
|
||||||
module.exports.restart = () => {
|
module.exports.restart = () => {
|
||||||
is.main() ? restart() : ipcRenderer.send('restart');
|
process.type === 'browser' ? restart() : ipcRenderer.send('restart');
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.setupAppControls = () => {
|
module.exports.setupAppControls = () => {
|
||||||
@ -21,3 +19,16 @@ function restart() {
|
|||||||
// execPath will be undefined if not running portable app, resulting in default behavior
|
// execPath will be undefined if not running portable app, resulting in default behavior
|
||||||
app.quit();
|
app.quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sendToFront(channel, ...args) {
|
||||||
|
BrowserWindow.getAllWindows().forEach(win => {
|
||||||
|
win.webContents.send(channel, ...args);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports.sendToFront =
|
||||||
|
process.type === 'browser'
|
||||||
|
? sendToFront
|
||||||
|
: () => {
|
||||||
|
console.error('sendToFront called from renderer');
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user