修复在勿扰模式下,使用快捷键启动项目和显示快速搜索窗口仍然生效的问题。

This commit is contained in:
unknown 2024-07-05 22:14:56 +08:00
parent 8c6de3fdc2
commit 6f04f8ccbd
2 changed files with 47 additions and 24 deletions

View File

@ -113,30 +113,43 @@ function showQuickSearchWindowBefore() {
* *
*/ */
function showQuickSearchWindow() { function showQuickSearchWindow() {
// 获取鼠标所在的屏幕 // flag
let currentDisplay = screen.getDisplayNearestPoint( let flag = true;
screen.getCursorScreenPoint() // 是否开启勿扰模式
); if (global.setting.general.notDisturb) {
// 获取窗口所在的屏幕 if (global.addon.isFullscreen()) {
let windowDisplay = getWindowInScreen(quickSearchWindow); flag = false;
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);
} }
} }
// 显示 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();
}
} }
/** /**

View File

@ -119,8 +119,18 @@ function setShortcutKey(setting: Setting = global.setting) {
globalShortcut.register( globalShortcut.register(
item.shortcutKey.replace("Win", "Super"), item.shortcutKey.replace("Win", "Super"),
() => { () => {
// 项目 // flag
run("main", "open", item); let flag = true;
// 是否开启勿扰模式
if (global.setting.general.notDisturb) {
if (global.addon.isFullscreen()) {
flag = false;
}
}
if (flag) {
// 项目
run("main", "open", item);
}
} }
); );
} catch (e) { } catch (e) {