mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 10:31:47 +00:00
Formatting
This commit is contained in:
44
index.js
44
index.js
@ -1,13 +1,13 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
|
||||||
const electron = require("electron");
|
const electron = require("electron");
|
||||||
const is = require("electron-is");
|
const is = require("electron-is");
|
||||||
const { autoUpdater } = require("electron-updater");
|
const { autoUpdater } = require("electron-updater");
|
||||||
|
|
||||||
const { setApplicationMenu } = require("./menu");
|
|
||||||
const { getEnabledPlugins, store } = require("./store");
|
const { getEnabledPlugins, store } = require("./store");
|
||||||
const { fileExists, injectCSS } = require("./plugins/utils");
|
const { setApplicationMenu } = require("./menu");
|
||||||
|
const { fileExists, injectCSS } = require("./plugins/utils");
|
||||||
|
|
||||||
const app = electron.app;
|
const app = electron.app;
|
||||||
|
|
||||||
@ -32,23 +32,23 @@ function onClosed() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function createMainWindow() {
|
function createMainWindow() {
|
||||||
const windowSize = store.get("window-size");
|
const windowSize = store.get("window-size");
|
||||||
const windowMaximized = store.get("window-maximized");
|
const windowMaximized = store.get("window-maximized");
|
||||||
|
|
||||||
const win = new electron.BrowserWindow({
|
const win = new electron.BrowserWindow({
|
||||||
icon : icon,
|
icon: icon,
|
||||||
width : windowSize.width,
|
width: windowSize.width,
|
||||||
height : windowSize.height,
|
height: windowSize.height,
|
||||||
backgroundColor: "#000",
|
backgroundColor: "#000",
|
||||||
show : false,
|
show: false,
|
||||||
webPreferences : {
|
webPreferences: {
|
||||||
nodeIntegration : false,
|
nodeIntegration: false,
|
||||||
preload : path.join(__dirname, "preload.js"),
|
preload: path.join(__dirname, "preload.js"),
|
||||||
nativeWindowOpen: true, // window.open return Window object(like in regular browsers), not BrowserWindowProxy
|
nativeWindowOpen: true, // window.open return Window object(like in regular browsers), not BrowserWindowProxy
|
||||||
affinity : "main-window" // main window, and addition windows should work in one process
|
affinity: "main-window", // main window, and addition windows should work in one process
|
||||||
},
|
},
|
||||||
frame : !is.macOS(),
|
frame: !is.macOS(),
|
||||||
titleBarStyle: is.macOS() ? "hiddenInset": "default"
|
titleBarStyle: is.macOS() ? "hiddenInset" : "default",
|
||||||
});
|
});
|
||||||
if (windowMaximized) {
|
if (windowMaximized) {
|
||||||
win.maximize();
|
win.maximize();
|
||||||
@ -65,7 +65,7 @@ function createMainWindow() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
getEnabledPlugins().forEach(plugin => {
|
getEnabledPlugins().forEach((plugin) => {
|
||||||
console.log("Loaded plugin - " + plugin);
|
console.log("Loaded plugin - " + plugin);
|
||||||
const pluginPath = path.join(__dirname, "plugins", plugin, "back.js");
|
const pluginPath = path.join(__dirname, "plugins", plugin, "back.js");
|
||||||
fileExists(pluginPath, () => {
|
fileExists(pluginPath, () => {
|
||||||
@ -146,12 +146,12 @@ app.on("ready", () => {
|
|||||||
autoUpdater.checkForUpdatesAndNotify();
|
autoUpdater.checkForUpdatesAndNotify();
|
||||||
autoUpdater.on("update-available", () => {
|
autoUpdater.on("update-available", () => {
|
||||||
const dialogOpts = {
|
const dialogOpts = {
|
||||||
type : "info",
|
type: "info",
|
||||||
buttons: ["OK"],
|
buttons: ["OK"],
|
||||||
title : "Application Update",
|
title: "Application Update",
|
||||||
message: "A new version is available",
|
message: "A new version is available",
|
||||||
detail :
|
detail:
|
||||||
"A new version is available and can be downloaded at https://github.com/th-ch/youtube-music/releases/latest"
|
"A new version is available and can be downloaded at https://github.com/th-ch/youtube-music/releases/latest",
|
||||||
};
|
};
|
||||||
electron.dialog.showMessageBox(dialogOpts);
|
electron.dialog.showMessageBox(dialogOpts);
|
||||||
});
|
});
|
||||||
@ -163,7 +163,7 @@ app.on("ready", () => {
|
|||||||
app.on("before-quit", () => {
|
app.on("before-quit", () => {
|
||||||
forceQuit = true;
|
forceQuit = true;
|
||||||
});
|
});
|
||||||
mainWindow.on("close", event => {
|
mainWindow.on("close", (event) => {
|
||||||
if (!forceQuit) {
|
if (!forceQuit) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
mainWindow.hide();
|
mainWindow.hide();
|
||||||
|
|||||||
12
menu.js
12
menu.js
@ -1,7 +1,7 @@
|
|||||||
const { app, Menu } = require("electron");
|
const { app, Menu } = require("electron");
|
||||||
|
|
||||||
const { getAllPlugins } = require("./plugins/utils");
|
|
||||||
const { isPluginEnabled, enablePlugin, disablePlugin } = require("./store");
|
const { isPluginEnabled, enablePlugin, disablePlugin } = require("./store");
|
||||||
|
const { getAllPlugins } = require("./plugins/utils");
|
||||||
|
|
||||||
module.exports.setApplicationMenu = () => {
|
module.exports.setApplicationMenu = () => {
|
||||||
const menuTemplate = [
|
const menuTemplate = [
|
||||||
@ -27,7 +27,7 @@ module.exports.setApplicationMenu = () => {
|
|||||||
if (process.platform === "darwin") {
|
if (process.platform === "darwin") {
|
||||||
const name = app.getName();
|
const name = app.getName();
|
||||||
menuTemplate.unshift({
|
menuTemplate.unshift({
|
||||||
label : name,
|
label: name,
|
||||||
submenu: [
|
submenu: [
|
||||||
{ role: "about" },
|
{ role: "about" },
|
||||||
{ type: "separator" },
|
{ type: "separator" },
|
||||||
@ -36,9 +36,9 @@ module.exports.setApplicationMenu = () => {
|
|||||||
{ role: "unhide" },
|
{ role: "unhide" },
|
||||||
{ type: "separator" },
|
{ type: "separator" },
|
||||||
{
|
{
|
||||||
label : "Select All",
|
label: "Select All",
|
||||||
accelerator: "CmdOrCtrl+A",
|
accelerator: "CmdOrCtrl+A",
|
||||||
selector : "selectAll:"
|
selector: "selectAll:",
|
||||||
},
|
},
|
||||||
{ label: "Cut", accelerator: "CmdOrCtrl+X", selector: "cut:" },
|
{ label: "Cut", accelerator: "CmdOrCtrl+X", selector: "cut:" },
|
||||||
{ label: "Copy", accelerator: "CmdOrCtrl+C", selector: "copy:" },
|
{ label: "Copy", accelerator: "CmdOrCtrl+C", selector: "copy:" },
|
||||||
@ -46,8 +46,8 @@ module.exports.setApplicationMenu = () => {
|
|||||||
{ type: "separator" },
|
{ type: "separator" },
|
||||||
{ role: "minimize" },
|
{ role: "minimize" },
|
||||||
{ role: "close" },
|
{ role: "close" },
|
||||||
{ role: "quit" }
|
{ role: "quit" },
|
||||||
]
|
],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,18 +4,18 @@ const plugins = require("./plugins");
|
|||||||
const store = new Store({
|
const store = new Store({
|
||||||
defaults: {
|
defaults: {
|
||||||
"window-size": {
|
"window-size": {
|
||||||
width : 1100,
|
width: 1100,
|
||||||
height: 550
|
height: 550
|
||||||
},
|
},
|
||||||
url : "https://music.youtube.com",
|
url: "https://music.youtube.com",
|
||||||
plugins: ["navigation", "shortcuts", "adblocker"]
|
plugins: ["navigation", "shortcuts", "adblocker"],
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
store : store,
|
store: store,
|
||||||
isPluginEnabled : plugin => plugins.isEnabled(store, plugin),
|
isPluginEnabled: plugin => plugins.isEnabled(store, plugin),
|
||||||
getEnabledPlugins: () => plugins.getEnabledPlugins(store),
|
getEnabledPlugins: () => plugins.getEnabledPlugins(store),
|
||||||
enablePlugin : plugin => plugins.enablePlugin(store, plugin),
|
enablePlugin: plugin => plugins.enablePlugin(store, plugin),
|
||||||
disablePlugin : plugin => plugins.disablePlugin(store, plugin)
|
disablePlugin: plugin => plugins.disablePlugin(store, plugin),
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user