From 773d1df529e3d65361c008489d9303f852b853b1 Mon Sep 17 00:00:00 2001 From: yonghang <1251679661@qq.com> Date: Mon, 11 Sep 2023 10:18:08 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=202=E3=80=81=E6=B7=BB=E5=8A=A0=E6=9C=80?= =?UTF-8?q?=E5=B0=8F=E5=8C=96=E8=BF=98=E5=8E=9F=E5=90=8E=E5=BA=95=E9=83=A8?= =?UTF-8?q?=E8=A2=AB=E7=B3=BB=E7=BB=9F=E4=BB=BB=E5=8A=A1=E6=A0=8F=E9=81=AE?= =?UTF-8?q?=E6=8C=A1=E8=A7=A3=E5=86=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/main/ipc.js | 2 ++ app/main/windows/main.js | 66 +++++++++++++++++++--------------------- 2 files changed, 33 insertions(+), 35 deletions(-) diff --git a/app/main/ipc.js b/app/main/ipc.js index c110dac..7dac045 100644 --- a/app/main/ipc.js +++ b/app/main/ipc.js @@ -193,6 +193,7 @@ module.exports = () => { return window[MAIN_WINDOW_FLAG] }) if (found) { + found.setFullScreen(true) found.restore(); found.show(); } else { @@ -207,6 +208,7 @@ module.exports = () => { return window[MAIN_WINDOW_FLAG] }) if (found) { + found.setFullScreen(false) found.hide(); } return true diff --git a/app/main/windows/main.js b/app/main/windows/main.js index b54a64f..bea7d41 100644 --- a/app/main/windows/main.js +++ b/app/main/windows/main.js @@ -43,41 +43,37 @@ const create = () => { found.maximize(); return found; } else { - let areaSize = require('electron').screen.getPrimaryDisplay().workAreaSize; - let width = areaSize.width; - let height = areaSize.height; - let resizable = true; - if (screen.width > 0 && screen.height > 0) { - const ratios = screen.width / screen.height; - height = areaSize.height; - width = Math.floor(areaSize.height * ratios); - resizable = false; - } - const win = createWindow(MAIN_WINDOW_URL, { - //alwaysOnTop: true, //窗口是否总是显示在其他窗口之前 - fullscreen: true, - offScreen: false, - frame: false, //要创建无边框窗口 - width: width, //悬浮窗口的宽度 比实际DIV的宽度要多2px 因为有1px的边框 - height: height, //悬浮窗口的高度 比实际DIV的高度要多2px 因为有1px的边框 - resizable: resizable, //禁止窗口大小缩放 - show: false, //先不让窗口显示 - // backgroundColor: "#0a0a0a" - }) - win[MAIN_WINDOW_FLAG] = true -// start() - sinceTimeEnd('createWindow') - win.on('ready-to-show', () => { - - sinceTimeEnd('ready-to-show') - win.show(); - sinceTimeEnd('win.show') - }); - win.on('hide', () => { - console.log('窗口hide'); - createSuspensionWindow(); - }); - return create(); + let areaSize = require('electron').screen.getPrimaryDisplay().workAreaSize + let width = areaSize.width + let height = areaSize.height + let resizable = true + if (screen.width > 0 && screen.height > 0) { + const ratios = screen.width / screen.height + height = areaSize.height + width = Math.floor(areaSize.height * ratios) + resizable = false + } + const win = createWindow(MAIN_WINDOW_URL, { + //alwaysOnTop: true, //窗口是否总是显示在其他窗口之前 + fullscreen: true, + offScreen: false, + frame: false, //要创建无边框窗口 + width: width, //悬浮窗口的宽度 比实际DIV的宽度要多2px 因为有1px的边框 + height: height, //悬浮窗口的高度 比实际DIV的高度要多2px 因为有1px的边框 + resizable: resizable, //禁止窗口大小缩放 + show: false, //先不让窗口显示 + // backgroundColor: "#0a0a0a" + }) + win[MAIN_WINDOW_FLAG] = true + // start() + win.on('ready-to-show', () => { + win.show() + }) + win.on('hide', () => { + console.log('窗口hide') + createSuspensionWindow() + }) + return create() } }