diff --git a/src/js/app.js b/src/js/app.js index 3b30985..c28372c 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -25,15 +25,14 @@ const log = console.log const fs = require('iofs') const path = require('path') -const { remote, ipcRenderer, screen } = require('electron') +const { remote, ipcRenderer } = require('electron') const { createDesktopLrcWindow, createMiniWindow } = remote.require( './tools/windows' ) -const MAIN_SCREEN = screen.getPrimaryDisplay() const WIN = remote.getCurrentWindow() -const __LRC__ = createDesktopLrcWindow(MAIN_SCREEN) -const __MINI__ = createMiniWindow(MAIN_SCREEN) +const __LRC__ = createDesktopLrcWindow(screen) +const __MINI__ = createMiniWindow(screen) const PLAY_MODE = { 0: 'all', diff --git a/src/main.js b/src/main.js index 6c94640..83e4daf 100644 --- a/src/main.js +++ b/src/main.js @@ -41,7 +41,9 @@ const ROOT = __dirname app.commandLine.appendSwitch('--lang', 'zh-CN') app.commandLine.appendSwitch('--autoplay-policy', 'no-user-gesture-required') -protocol.registerStandardSchemes(['app'], { secure: true }) +protocol.registerSchemesAsPrivileged([ + { scheme: 'app', privileges: { secure: true, standard: true } } +]) /* ----------------------------------------------------- */ diff --git a/src/tools/windows.js b/src/tools/windows.js index bac8561..7c017d5 100644 --- a/src/tools/windows.js +++ b/src/tools/windows.js @@ -22,7 +22,8 @@ exports.createMainWindow = function(icon) { icon, webPreferences: { webSecurity: false, - experimentalFeatures: true + experimentalFeatures: true, + nodeIntegration: true }, show: false }) @@ -74,12 +75,15 @@ exports.createDesktopLrcWindow = function(screen) { resizable: false, alwaysOnTop: true, skipTaskbar: true, - x: (screen.size.width - 1024) / 2, - y: screen.size.height - 100, + x: (screen.width - 1024) / 2, + y: screen.height - 100, transparent: true, hasShadow: false, thickFrame: false, - show: false + show: false, + webPreferences: { + nodeIntegration: true + } }) win.loadURL('app://local/desktop-lrc.html') @@ -98,10 +102,13 @@ exports.createMiniWindow = function(screen) { resizable: false, alwaysOnTop: true, skipTaskbar: true, - x: screen.size.width - 320, + x: screen.width - 320, y: 0, thickFrame: false, - show: false + show: false, + webPreferences: { + nodeIntegration: true + } }) win.loadURL('app://local/mini-win.html')