This repository has been archived on 2023-08-30. You can view files and clone it, but cannot push or open issues/pull-requests.
appcat
/
sonist
Archived
1
0
Fork 0

将桌面歌词窗口放到渲染进程中创建,以解决linux下打包后的奇葩bug

2.x
宇天 2019-01-31 21:29:14 +08:00
parent c8c73747ad
commit c5dcf47601
3 changed files with 13 additions and 14 deletions

View File

@ -25,10 +25,15 @@ const log = console.log
const fs = require('iofs') const fs = require('iofs')
const path = require('path') 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 WIN = remote.getCurrentWindow()
const { __LRC__, __MINI__ } = remote.app const __LRC__ = createDesktopLrcWindow(MAIN_SCREEN)
const __MINI__ = createMiniWindow(MAIN_SCREEN)
const PLAY_MODE = { const PLAY_MODE = {
0: 'all', 0: 'all',

View File

@ -6,8 +6,7 @@
'use strict' 'use strict'
const electron = require('electron') const { app, BrowserWindow, session, protocol } = require('electron')
const { app, BrowserWindow, session, protocol } = electron
const path = require('path') const path = require('path')
const fs = require('iofs') const fs = require('iofs')
const { exec } = require('child_process') const { exec } = require('child_process')
@ -27,12 +26,7 @@ const MIME_TYPES = {
require('./tools/init') require('./tools/init')
const createTray = require('./tools/tray') const createTray = require('./tools/tray')
const createMenu = require('./tools/menu') const createMenu = require('./tools/menu')
const { const { createMainWindow, createErrorWindow } = require('./tools/windows')
createMainWindow,
createErrorWindow,
createDesktopLrcWindow,
createMiniWindow
} = require('./tools/windows')
const ROOT = __dirname const ROOT = __dirname
@ -61,15 +55,12 @@ app.once('ready', () => {
// 判断依赖 // 判断依赖
exec('which ffprobe', (err, res) => { exec('which ffprobe', (err, res) => {
if (res) { if (res) {
let sp = electron.screen.getPrimaryDisplay()
let win = createMainWindow(path.resolve(ROOT, './images/app.png')) let win = createMainWindow(path.resolve(ROOT, './images/app.png'))
createTray(win) createTray(win)
createMenu(win) createMenu(win)
app.__MAIN__ = win app.__MAIN__ = win
app.__LRC__ = createDesktopLrcWindow(sp)
app.__MINI__ = createMiniWindow(sp)
// mac专属事件,点击dock栏图标,可激活窗口 // mac专属事件,点击dock栏图标,可激活窗口
app.on('activate', _ => { app.on('activate', _ => {

View File

@ -33,7 +33,7 @@ exports.createMainWindow = function(icon) {
win.on('ready-to-show', _ => { win.on('ready-to-show', _ => {
win.show() win.show()
// win.openDevTools() win.openDevTools()
}) })
return win return win
@ -77,6 +77,8 @@ exports.createDesktopLrcWindow = function(screen) {
x: (screen.size.width - 1024) / 2, x: (screen.size.width - 1024) / 2,
y: screen.size.height - 100, y: screen.size.height - 100,
transparent: true, transparent: true,
hasShadow: false,
thickFrame: false,
show: false show: false
}) })
@ -98,6 +100,7 @@ exports.createMiniWindow = function(screen) {
skipTaskbar: true, skipTaskbar: true,
x: screen.size.width - 320, x: screen.size.width - 320,
y: 0, y: 0,
thickFrame: false,
show: false show: false
}) })