From b72a8d4780961a12fd5f2141e225c1031406601a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E5=A4=A9?= Date: Mon, 9 Sep 2019 00:56:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B06.x=E7=9A=84API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/js/app.js | 7 +++---- src/main.js | 4 +++- src/tools/windows.js | 19 +++++++++++++------ 3 files changed, 19 insertions(+), 11 deletions(-) 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')