- Small change to preload to define global.ipcRenderer early.

- Changed BW options and removed redundant options that (I think) are no longer used by the renderer.
- Added launch args to app.ts
This commit is contained in:
Core 2022-01-09 15:24:42 +00:00
parent 6dad815d48
commit 312a5a7b70
No known key found for this signature in database
GPG key ID: 1B77805746C47C28
4 changed files with 28 additions and 13 deletions

View file

@ -100,7 +100,8 @@
"extends": null, "extends": null,
"files": [ "files": [
"./build/**/*", "./build/**/*",
"./resources/icons/icon.*" "./resources/icons/icon.*",
"./src/**/*"
], ],
"linux": { "linux": {
"target": [ "target": [

View file

@ -1,4 +1,5 @@
import * as electron from 'electron'; import * as electron from 'electron';
import * as path from 'path';
export class AppEvents { export class AppEvents {
constructor(store: any) { constructor(store: any) {
@ -14,6 +15,28 @@ export class AppEvents {
private static start(store: any): void { private static start(store: any): void {
console.log('App started'); console.log('App started');
/**********************************************************************************************************************
* Startup arguments handling
**********************************************************************************************************************/
if (electron.app.commandLine.hasSwitch('version') || electron.app.commandLine.hasSwitch('v')) {
console.log(electron.app.getVersion())
electron.app.exit()
}
// Verbose Check
if (electron.app.commandLine.hasSwitch('verbose')) {
console.log("[Apple-Music-Electron] User has launched the application with --verbose");
}
// Log File Location
if (electron.app.commandLine.hasSwitch('log') || electron.app.commandLine.hasSwitch('l')) {
console.log(path.join(electron.app.getPath('userData'), 'logs'))
electron.app.exit()
}
/***********************************************************************************************************************
* Commandline arguments
**********************************************************************************************************************/
switch (store.get("visual.hw_acceleration")) { switch (store.get("visual.hw_acceleration")) {
default: default:
case "default": case "default":

View file

@ -45,18 +45,11 @@ export class Win {
frame: false, frame: false,
title: "Cider", title: "Cider",
vibrancy: 'dark', vibrancy: 'dark',
// transparent: true, transparent: (process.platform === "darwin"),
hasShadow: false, hasShadow: false,
webPreferences: { webPreferences: {
webviewTag: true,
plugins: true,
nodeIntegration: true, nodeIntegration: true,
nodeIntegrationInWorker: false,
webSecurity: false,
allowRunningInsecureContent: true,
enableRemoteModule: true,
sandbox: true, sandbox: true,
nativeWindowOpen: true,
contextIsolation: false, contextIsolation: false,
preload: path.join(this.paths.srcPath, './preload/cider-preload.js') preload: path.join(this.paths.srcPath, './preload/cider-preload.js')
} }
@ -133,7 +126,7 @@ export class Win {
app.use(express.static(path.join(this.paths.srcPath, './renderer/'))); app.use(express.static(path.join(this.paths.srcPath, './renderer/')));
app.set("views", path.join(this.paths.srcPath, './renderer/views')); app.set("views", path.join(this.paths.srcPath, './renderer/views'));
app.set("view engine", "ejs"); app.set("view engine", "ejs");
app.use((req, res, next) => { app.use((req, res, next) => {
// @ts-ignore // @ts-ignore
if (req.url.includes("audio.webm") || (req.headers.host.includes("localhost") && (this.devMode || req.headers["user-agent"].includes("Electron")))) { if (req.url.includes("audio.webm") || (req.headers.host.includes("localhost") && (this.devMode || req.headers["user-agent"].includes("Electron")))) {

View file

@ -1,5 +1,4 @@
const electron = require('electron') global.ipcRenderer = require('electron').ipcRenderer;
console.log('Loaded Preload') console.log('Loaded Preload')
let cache = {playParams: {id: 0}, status: null, remainingTime: 0}, let cache = {playParams: {id: 0}, status: null, remainingTime: 0},
@ -91,6 +90,5 @@ const MusicKitInterop = {
process.once('loaded', () => { process.once('loaded', () => {
console.log("Setting ipcRenderer") console.log("Setting ipcRenderer")
global.ipcRenderer = electron.ipcRenderer;
global.MusicKitInterop = MusicKitInterop; global.MusicKitInterop = MusicKitInterop;
}); });