mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 14:40:12 +01:00
🎨 Fix focus issues on Windows after dialog interactions (#16073)
fix https://github.com/siyuan-note/siyuan/issues/16071
This commit is contained in:
parent
8725e5daa8
commit
067db0791f
3 changed files with 47 additions and 0 deletions
|
|
@ -866,6 +866,13 @@ app.whenReady().then(() => {
|
|||
event.sender.send("siyuan-event", "leave-full-screen");
|
||||
});
|
||||
});
|
||||
ipcMain.on("siyuan-focus-fix", (event) => {
|
||||
const currentWindow = getWindowByContentId(event.sender.id);
|
||||
if (currentWindow && process.platform === "win32") {
|
||||
currentWindow.blur();
|
||||
currentWindow.focus();
|
||||
}
|
||||
});
|
||||
ipcMain.on("siyuan-cmd", (event, data) => {
|
||||
let cmd = data;
|
||||
let webContentsId = event.sender.id;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import * as fs from "fs";
|
|||
import * as path from "path";
|
||||
import {afterExport} from "../protyle/export/util";
|
||||
import {onWindowsMsg} from "../window/onWindowsMsg";
|
||||
import {initFocusFix} from "../protyle/util/compatibility";
|
||||
/// #endif
|
||||
import {Constants} from "../constants";
|
||||
import {appearance} from "../config/appearance";
|
||||
|
|
@ -68,6 +69,9 @@ export const onGetConfig = (isStart: boolean, app: App) => {
|
|||
initBar(app);
|
||||
initStatus();
|
||||
initWindow(app);
|
||||
/// #if !BROWSER
|
||||
initFocusFix();
|
||||
/// #endif
|
||||
appearance.onSetAppearance(window.siyuan.config.appearance);
|
||||
initAssets();
|
||||
setInlineStyle();
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import {fetchPost, fetchSyncPost} from "../../util/fetch";
|
|||
import {Constants} from "../../constants";
|
||||
/// #if !BROWSER
|
||||
import {clipboard} from "electron";
|
||||
import {ipcRenderer} from "electron";
|
||||
/// #endif
|
||||
|
||||
export const encodeBase64 = (text: string): string => {
|
||||
|
|
@ -512,3 +513,38 @@ export const setStorageVal = (key: string, val: any, cb?: () => void) => {
|
|||
}
|
||||
});
|
||||
};
|
||||
|
||||
/// #if !BROWSER
|
||||
export const initFocusFix = () => {
|
||||
if (!isWindows()) {
|
||||
return;
|
||||
}
|
||||
const originalAlert = window.alert;
|
||||
const originalConfirm = window.confirm;
|
||||
const fixFocusAfterDialog = () => {
|
||||
ipcRenderer.send("siyuan-focus-fix");
|
||||
};
|
||||
window.alert = function(message: string) {
|
||||
try {
|
||||
const result = originalAlert.call(this, message);
|
||||
fixFocusAfterDialog();
|
||||
return result;
|
||||
} catch (error) {
|
||||
console.error("alert error:", error);
|
||||
fixFocusAfterDialog();
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
window.confirm = function(message: string) {
|
||||
try {
|
||||
const result = originalConfirm.call(this, message);
|
||||
fixFocusAfterDialog();
|
||||
return result;
|
||||
} catch (error) {
|
||||
console.error("confirm error:", error);
|
||||
fixFocusAfterDialog();
|
||||
return false;
|
||||
}
|
||||
};
|
||||
};
|
||||
/// #endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue