新增桌面歌词
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
const { BrowserView } = require('electron')
|
||||
const { mainHandle } = require('../../../common/ipc')
|
||||
const { mainHandle, NAMES: { mainWindow: ipcMainWindowNames } } = require('../../../common/ipc')
|
||||
const { getWindowSizeInfo } = require('../../utils')
|
||||
|
||||
let view
|
||||
@@ -9,16 +9,16 @@ let rejectFn
|
||||
const closeView = async() => {
|
||||
if (!view) return
|
||||
// await view.webContents.session.clearCache()
|
||||
if (global.mainWindow) global.mainWindow.removeBrowserView(view)
|
||||
if (global.modals.mainWindow) global.modals.mainWindow.removeBrowserView(view)
|
||||
await view.webContents.session.clearStorageData()
|
||||
view.destroy()
|
||||
view = null
|
||||
}
|
||||
|
||||
mainHandle('xm_verify_open', (event, url) => new Promise((resolve, reject) => {
|
||||
if (!global.mainWindow) return reject(new Error('mainwindow is undefined'))
|
||||
mainHandle(ipcMainWindowNames.handle_xm_verify_open, (event, url) => new Promise((resolve, reject) => {
|
||||
if (!global.modals.mainWindow) return reject(new Error('mainWindow is undefined'))
|
||||
if (view) {
|
||||
global.mainWindow.removeBrowserView(view)
|
||||
global.modals.mainWindow.removeBrowserView(view)
|
||||
view.destroy()
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ mainHandle('xm_verify_open', (event, url) => new Promise((resolve, reject) => {
|
||||
})
|
||||
})
|
||||
|
||||
global.mainWindow.setBrowserView(view)
|
||||
global.modals.mainWindow.setBrowserView(view)
|
||||
const windowSizeInfo = getWindowSizeInfo(global.appSetting)
|
||||
view.setBounds({ x: (windowSizeInfo.width - 380) / 2, y: ((windowSizeInfo.height - 320 + 52) / 2), width: 380, height: 320 })
|
||||
view.webContents.loadURL(url, {
|
||||
@@ -57,7 +57,7 @@ mainHandle('xm_verify_open', (event, url) => new Promise((resolve, reject) => {
|
||||
// view.webContents.openDevTools()
|
||||
}))
|
||||
|
||||
mainHandle('xm_verify_close', async() => {
|
||||
mainHandle(ipcMainWindowNames.handle_xm_verify_close, async() => {
|
||||
await closeView()
|
||||
if (!rejectFn) return
|
||||
if (!isActioned) rejectFn(new Error('canceled verify'))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const { BrowserWindow } = require('electron')
|
||||
const { mainHandle } = require('../../../common/ipc')
|
||||
const { mainHandle, NAMES: { mainWindow: ipcMainWindowNames } } = require('../../../common/ipc')
|
||||
const { getWindowSizeInfo } = require('../../utils')
|
||||
|
||||
let win
|
||||
@@ -7,7 +7,7 @@ let win
|
||||
const closeWin = async() => {
|
||||
if (!win) return
|
||||
// await win.webContents.session.clearCache()
|
||||
// if (global.mainWindow) global.mainWindow.removeBrowserView(win)
|
||||
// if (global.modals.mainWindow) global.modals.mainWindow.removeBrowserView(win)
|
||||
if (win.isDestroyed()) {
|
||||
win = null
|
||||
return
|
||||
@@ -17,16 +17,16 @@ const closeWin = async() => {
|
||||
win = null
|
||||
}
|
||||
|
||||
mainHandle('xm_verify_open', (event, url) => new Promise((resolve, reject) => {
|
||||
if (!global.mainWindow) return reject(new Error('mainwindow is undefined'))
|
||||
mainHandle(ipcMainWindowNames.handle_xm_verify_open, (event, url) => new Promise((resolve, reject) => {
|
||||
if (!global.modals.mainWindow) return reject(new Error('mainWindow is undefined'))
|
||||
if (win) win.destroy()
|
||||
|
||||
let isActioned = false
|
||||
|
||||
const mainWindowSizeInfo = global.mainWindow.getBounds()
|
||||
const mainWindowSizeInfo = global.modals.mainWindow.getBounds()
|
||||
const windowSizeInfo = getWindowSizeInfo(global.appSetting)
|
||||
win = new BrowserWindow({
|
||||
parent: global.mainWindow,
|
||||
parent: global.modals.mainWindow,
|
||||
width: 460,
|
||||
height: 370,
|
||||
resizable: false,
|
||||
@@ -72,6 +72,6 @@ mainHandle('xm_verify_open', (event, url) => new Promise((resolve, reject) => {
|
||||
// win.webContents.openDevTools()
|
||||
}))
|
||||
|
||||
mainHandle('xm_verify_close', async() => {
|
||||
mainHandle(ipcMainWindowNames.handle_xm_verify_close, async() => {
|
||||
await closeWin()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user