From 87a01682221b87dacf2a3bc57ea70a295269b566 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sat, 13 Dec 2025 00:18:01 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/16524 --- app/electron/main.js | 10 ++++-- app/src/boot/onGetConfig.ts | 4 +++ app/src/config/editor.ts | 61 +++++++++++++++++++++++++++++++------ app/src/types/config.d.ts | 4 +++ 4 files changed, 68 insertions(+), 11 deletions(-) diff --git a/app/electron/main.js b/app/electron/main.js index b8bb43c0d..592dba2c9 100644 --- a/app/electron/main.js +++ b/app/electron/main.js @@ -359,8 +359,6 @@ const initMainWindow = () => { }); }); - currentWindow.webContents.session.setSpellCheckerLanguages(["en-US"]); - // 发起互联网服务请求时绕过安全策略 https://github.com/siyuan-note/siyuan/issues/5516 currentWindow.webContents.session.webRequest.onBeforeSendHeaders((details, cb) => { if (-1 < details.url.toLowerCase().indexOf("bili")) { @@ -787,6 +785,9 @@ app.whenReady().then(() => { if (data.cmd === "getContentsId") { return event.sender.id; } + if (data.cmd === "getSpellCheckerLanguages") { + return event.sender.session.getSpellCheckerLanguages(); + } if (data.cmd === "setProxy") { return setProxy(data.proxyURL, event.sender); } @@ -894,6 +895,11 @@ app.whenReady().then(() => { case "showItemInFolder": shell.showItemInFolder(data.filePath); break; + case "setSpellCheckerLanguages": + BrowserWindow.getAllWindows().forEach(item => { + item.webContents.session.setSpellCheckerLanguages(data.languages); + }); + break; case "openPath": shell.openPath(data.filePath); break; diff --git a/app/src/boot/onGetConfig.ts b/app/src/boot/onGetConfig.ts index da840f194..c42fcaebd 100644 --- a/app/src/boot/onGetConfig.ts +++ b/app/src/boot/onGetConfig.ts @@ -114,6 +114,10 @@ const winOnMaxRestore = async () => { export const initWindow = async (app: App) => { /// #if !BROWSER + ipcRenderer.send(Constants.SIYUAN_CMD, { + cmd: "setSpellCheckerLanguages", + languages: window.siyuan.config.editor.spellcheckLanguages + }); const winOnClose = (close = false) => { exportLayout({ cb() { diff --git a/app/src/config/editor.ts b/app/src/config/editor.ts index 8dfcb4573..43f5f4e4e 100644 --- a/app/src/config/editor.ts +++ b/app/src/config/editor.ts @@ -1,4 +1,7 @@ import {getAllModels} from "../layout/getAll"; +/// #if !BROWSER +import {ipcRenderer} from "electron"; +/// #endif import {setInlineStyle} from "../util/assets"; import {fetchPost} from "../util/fetch"; import {confirmDialog} from "../dialog/confirmDialog"; @@ -97,14 +100,17 @@ export const editor = { - +
+ +
+