From 6f04f8ccbd0b0d89f1c971d6c9bdac31726eaee3 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 5 Jul 2024 22:14:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9C=A8=E5=8B=BF=E6=89=B0?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E4=B8=8B=EF=BC=8C=E4=BD=BF=E7=94=A8=E5=BF=AB?= =?UTF-8?q?=E6=8D=B7=E9=94=AE=E5=90=AF=E5=8A=A8=E9=A1=B9=E7=9B=AE=E5=92=8C?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=BF=AB=E9=80=9F=E6=90=9C=E7=B4=A2=E7=AA=97?= =?UTF-8?q?=E5=8F=A3=E4=BB=8D=E7=84=B6=E7=94=9F=E6=95=88=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- electron/main/search/index.ts | 57 +++++++++++++++++++++------------- electron/main/setting/index.ts | 14 +++++++-- 2 files changed, 47 insertions(+), 24 deletions(-) diff --git a/electron/main/search/index.ts b/electron/main/search/index.ts index 20d86f1..290ced2 100644 --- a/electron/main/search/index.ts +++ b/electron/main/search/index.ts @@ -113,30 +113,43 @@ function showQuickSearchWindowBefore() { * 显示快速搜索窗口 */ function showQuickSearchWindow() { - // 获取鼠标所在的屏幕 - let currentDisplay = screen.getDisplayNearestPoint( - screen.getCursorScreenPoint() - ); - // 获取窗口所在的屏幕 - let windowDisplay = getWindowInScreen(quickSearchWindow); - if (windowDisplay.length === 0) { - // 代表窗口的位置不再任一屏幕内,将窗口位置移动到主窗口 - quickSearchWindow.center(); - } else if ( - (windowDisplay.length === 1 && currentDisplay.id !== windowDisplay[0].id) || - windowDisplay.length > 1 - ) { - // 在鼠标所在的屏幕显示 - let workArea = currentDisplay.workArea; - let bounds = quickSearchWindow.getBounds(); - let x = Math.round(workArea.x + workArea.width / 2 - bounds.width / 2); - let y = Math.round(workArea.y + workArea.height / 2 - 44 / 2); - quickSearchWindow.setPosition(x, y); - for (let i = 0; i < 10; i++) { - quickSearchWindow.setSize(global.setting.quickSearch.width, 44); + // flag + let flag = true; + // 是否开启勿扰模式 + if (global.setting.general.notDisturb) { + if (global.addon.isFullscreen()) { + flag = false; } } - // 显示 + if (flag) { + // 获取鼠标所在的屏幕 + let currentDisplay = screen.getDisplayNearestPoint( + screen.getCursorScreenPoint() + ); + // 获取窗口所在的屏幕 + let windowDisplay = getWindowInScreen(quickSearchWindow); + if (windowDisplay.length === 0) { + // 代表窗口的位置不再任一屏幕内,将窗口位置移动到主窗口 + quickSearchWindow.center(); + } else if ( + (windowDisplay.length === 1 && + currentDisplay.id !== windowDisplay[0].id) || + windowDisplay.length > 1 + ) { + // 在鼠标所在的屏幕显示 + let workArea = currentDisplay.workArea; + let bounds = quickSearchWindow.getBounds(); + let x = Math.round(workArea.x + workArea.width / 2 - bounds.width / 2); + let y = Math.round(workArea.y + workArea.height / 2 - 44 / 2); + quickSearchWindow.setPosition(x, y); + for (let i = 0; i < 10; i++) { + quickSearchWindow.setSize(global.setting.quickSearch.width, 44); + } + } + // 显示 + quickSearchWindow.setBounds({ width: global.setting.quickSearch.width }); + quickSearchWindow.show(); + } } /** diff --git a/electron/main/setting/index.ts b/electron/main/setting/index.ts index ec7b26e..7b01d1f 100644 --- a/electron/main/setting/index.ts +++ b/electron/main/setting/index.ts @@ -119,8 +119,18 @@ function setShortcutKey(setting: Setting = global.setting) { globalShortcut.register( item.shortcutKey.replace("Win", "Super"), () => { - // 项目 - run("main", "open", item); + // flag + let flag = true; + // 是否开启勿扰模式 + if (global.setting.general.notDisturb) { + if (global.addon.isFullscreen()) { + flag = false; + } + } + if (flag) { + // 项目 + run("main", "open", item); + } } ); } catch (e) {