将桌面歌词窗口放到渲染进程中创建,以解决linux下打包后的奇葩bug
parent
c8c73747ad
commit
c5dcf47601
|
@ -25,10 +25,15 @@ const log = console.log
|
|||
const fs = require('iofs')
|
||||
const path = require('path')
|
||||
|
||||
const { remote, ipcRenderer } = require('electron')
|
||||
const { remote, ipcRenderer, screen } = require('electron')
|
||||
const { createDesktopLrcWindow, createMiniWindow } = remote.require(
|
||||
'./tools/windows'
|
||||
)
|
||||
const MAIN_SCREEN = screen.getPrimaryDisplay()
|
||||
|
||||
const WIN = remote.getCurrentWindow()
|
||||
const { __LRC__, __MINI__ } = remote.app
|
||||
const __LRC__ = createDesktopLrcWindow(MAIN_SCREEN)
|
||||
const __MINI__ = createMiniWindow(MAIN_SCREEN)
|
||||
|
||||
const PLAY_MODE = {
|
||||
0: 'all',
|
||||
|
|
13
src/main.js
13
src/main.js
|
@ -6,8 +6,7 @@
|
|||
|
||||
'use strict'
|
||||
|
||||
const electron = require('electron')
|
||||
const { app, BrowserWindow, session, protocol } = electron
|
||||
const { app, BrowserWindow, session, protocol } = require('electron')
|
||||
const path = require('path')
|
||||
const fs = require('iofs')
|
||||
const { exec } = require('child_process')
|
||||
|
@ -27,12 +26,7 @@ const MIME_TYPES = {
|
|||
require('./tools/init')
|
||||
const createTray = require('./tools/tray')
|
||||
const createMenu = require('./tools/menu')
|
||||
const {
|
||||
createMainWindow,
|
||||
createErrorWindow,
|
||||
createDesktopLrcWindow,
|
||||
createMiniWindow
|
||||
} = require('./tools/windows')
|
||||
const { createMainWindow, createErrorWindow } = require('./tools/windows')
|
||||
|
||||
const ROOT = __dirname
|
||||
|
||||
|
@ -61,15 +55,12 @@ app.once('ready', () => {
|
|||
// 判断依赖
|
||||
exec('which ffprobe', (err, res) => {
|
||||
if (res) {
|
||||
let sp = electron.screen.getPrimaryDisplay()
|
||||
let win = createMainWindow(path.resolve(ROOT, './images/app.png'))
|
||||
|
||||
createTray(win)
|
||||
createMenu(win)
|
||||
|
||||
app.__MAIN__ = win
|
||||
app.__LRC__ = createDesktopLrcWindow(sp)
|
||||
app.__MINI__ = createMiniWindow(sp)
|
||||
|
||||
// mac专属事件,点击dock栏图标,可激活窗口
|
||||
app.on('activate', _ => {
|
||||
|
|
|
@ -33,7 +33,7 @@ exports.createMainWindow = function(icon) {
|
|||
|
||||
win.on('ready-to-show', _ => {
|
||||
win.show()
|
||||
// win.openDevTools()
|
||||
win.openDevTools()
|
||||
})
|
||||
|
||||
return win
|
||||
|
@ -77,6 +77,8 @@ exports.createDesktopLrcWindow = function(screen) {
|
|||
x: (screen.size.width - 1024) / 2,
|
||||
y: screen.size.height - 100,
|
||||
transparent: true,
|
||||
hasShadow: false,
|
||||
thickFrame: false,
|
||||
show: false
|
||||
})
|
||||
|
||||
|
@ -98,6 +100,7 @@ exports.createMiniWindow = function(screen) {
|
|||
skipTaskbar: true,
|
||||
x: screen.size.width - 320,
|
||||
y: 0,
|
||||
thickFrame: false,
|
||||
show: false
|
||||
})
|
||||
|
||||
|
|
Reference in New Issue