An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: https://github.com/siyuan-note/siyuan/issues/9368 init
Vanessad7666659c3a6
diff --git a/app/electron/error.html b/app/electron/error.htmlindex 435baf7815..0f7e4285ab 100644--- a/app/electron/error.html+++ b/app/electron/error.html@@ -182,12 +182,12 @@})document.getElementById('close').addEventListener('click', () => {- const {getCurrentWindow} = require('@electron/remote')- getCurrentWindow().destroy()+ const {ipcRenderer} = require('electron')+ ipcRenderer.send("siyuan-cmd", "destroy");})document.getElementById('min').addEventListener('click', () => {- const {getCurrentWindow} = require('@electron/remote')- getCurrentWindow().minimize()+ const {ipcRenderer} = require('electron')+ ipcRenderer.send("siyuan-cmd", "minimize");})</script></body>diff --git a/app/electron/init.html b/app/electron/init.htmlindex 3e9c6c9f33..bc20ebc066 100644--- a/app/electron/init.html+++ b/app/electron/init.html@@ -343,13 +343,12 @@ipcRenderer.send('siyuan-first-quit')})document.getElementById('min').addEventListener('click', () => {- const {getCurrentWindow} = require('@electron/remote')- getCurrentWindow().minimize()+ const {ipcRenderer} = require('electron')+ ipcRenderer.send("siyuan-cmd", "minimize");})document.querySelectorAll('.choosePath').forEach((item) => {- item.addEventListener('click', () => {- const {dialog} = require('@electron/remote')+ item.addEventListener('click', async () => {const path = require('path')const fs = require('fs')@@ -358,50 +357,48 @@fs.mkdirSync(defaultWorkspace, {mode: 0o755, recursive: true})}- dialog.showOpenDialog({+ const {ipcRenderer} = require('electron')+ const result = await ipcRenderer.invoke(Constants.SIYUAN_GET, {+ cmd: "showOpenDialog",defaultPath: defaultWorkspace,properties: ['openDirectory', 'createDirectory'],- }).then((result) => {- if (result.canceled) {- return- }+ });- const {ipcRenderer} = require('electron')- const initPath = result.filePaths[0]-- if (isICloudPath(initPath)) {- let msg = '⚠️ This folder is under the iCloud sync path, please change another path'- if (isChinese(currentLang)) {- msg = '⚠️ 该文件夹位于 iCloud 同步路径下,请更换其他路径'- }- alert(msg)- return- }-- if (isCloudDrivePath(initPath)) {- let msg = '⚠️ The folder path can not contain onedrive, dropbox, google drive, pcloud and 坚果云, please change another path'- if (isChinese(currentLang)) {- msg = '⚠️ 文件夹路径不能包含 onedrive、dropbox、google drive、pcloud 和 坚果云,请更换其他路径'- }- alert(msg)- return- }+ if (result.canceled) {+ return+ }+ const initPath = result.filePaths[0]- let msg = '⚠️ Do not set the workspace under the path of a third-party sync disk, otherwise the data will be damaged (iCloud/OneDrive/Dropbox/Google Drive/Nutstore/Baidu Netdisk/Tencent Weiyun, etc.), continue?'+ if (isICloudPath(initPath)) {+ let msg = '⚠️ This folder is under the iCloud sync path, please change another path'if (isChinese(currentLang)) {- msg = '⚠️ 请勿将工作空间设置在第三方同步盘路径下,否则数据会被损坏(iCloud/OneDrive/Dropbox/Google Drive/坚果云/百度网盘/腾讯微云等),是否继续?'- }- if (!confirm(msg)) {- return+ msg = '⚠️ 该文件夹位于 iCloud 同步路径下,请更换其他路径'}+ alert(msg)+ return+ }- if (!fs.existsSync(initPath)) {- fs.mkdirSync(initPath, {mode: 0o755, recursive: true})+ if (isCloudDrivePath(initPath)) {+ let msg = '⚠️ The folder path can not contain onedrive, dropbox, google drive, pcloud and 坚果云, please change another path'+ if (isChinese(currentLang)) {+ msg = '⚠️ 文件夹路径不能包含 onedrive、dropbox、google drive、pcloud 和 坚果云,请更换其他路径'}- ipcRenderer.send('siyuan-first-init', {- workspace: initPath,- lang: document.querySelector('.lang').value- })+ alert(msg)+ return+ }+ let msg = '⚠️ Do not set the workspace under the path of a third-party sync disk, otherwise the data will be damaged (iCloud/OneDrive/Dropbox/Google Drive/Nutstore/Baidu Netdisk/Tencent Weiyun, etc.), continue?'+ if (isChinese(currentLang)) {+ msg = '⚠️ 请勿将工作空间设置在第三方同步盘路径下,否则数据会被损坏(iCloud/OneDrive/Dropbox/Google Drive/坚果云/百度网盘/腾讯微云等),是否继续?'+ }+ if (!confirm(msg)) {+ return+ }+ if (!fs.existsSync(initPath)) {+ fs.mkdirSync(initPath, {mode: 0o755, recursive: true})+ }+ ipcRenderer.send('siyuan-first-init', {+ workspace: initPath,+ lang: document.querySelector('.lang').value})})})diff --git a/app/electron/main.js b/app/electron/main.jsindex 1268e2b21a..737815f5ec 100644--- a/app/electron/main.js+++ b/app/electron/main.js@@ -31,7 +31,6 @@ let firstOpen = false;let workspaces = []; // workspaceDir, id, browserWindow, traylet kernelPort = 6806;let resetWindowStateOnRestart = false;-require("@electron/remote/main").initialize();if (!app.requestSingleInstanceLock()) {app.quit();@@ -160,7 +159,6 @@ const showErrorWindow = (title, content) => {nodeIntegration: true, webviewTag: true, webSecurity: false, contextIsolation: false,},});- require("@electron/remote/main").enable(errWindow.webContents);errWindow.loadFile(errorHTMLPath, {query: {home: app.getPath("home"),@@ -281,7 +279,6 @@ const boot = () => {icon: path.join(appDir, "stage", "icon-large.png"),});windowStateInitialized ? currentWindow.setPosition(x, y) : currentWindow.center();- require("@electron/remote/main").enable(currentWindow.webContents);currentWindow.webContents.userAgent = "SiYuan/" + appVer + " https://b3log.org/siyuan Electron " + currentWindow.webContents.userAgent;currentWindow.webContents.session.setSpellCheckerLanguages(["en-US"]);@@ -674,6 +671,9 @@ app.whenReady().then(() => {if (data.cmd === "isFullScreen") {return getWindowByContentId(event.sender.id).isFullScreen();}+ if (data.cmd === "isMaximized") {+ return getWindowByContentId(event.sender.id).isMaximized();+ }if (data.cmd === "getMicrophone") {return systemPreferences.getMediaAccessStatus("microphone");}@@ -700,6 +700,29 @@ app.whenReady().then(() => {return hasMatch}});+ ipcMain.once("siyuan-event", (event) => {+ const currentWindow = getWindowByContentId(event.sender.id);+ currentWindow.on("focus", () => {+ event.sender.send("siyuan-event", "focus");+ });+ currentWindow.on("blur", () => {+ event.sender.send("siyuan-event", "blur");+ });+ if ("darwin" !== process.platform) {+ currentWindow.on("maximize", () => {+ event.sender.send("siyuan-event", "maximize");+ });+ currentWindow.on("unmaximize", () => {+ event.sender.send("siyuan-event", "unmaximize");+ });+ }+ currentWindow.on("enter-full-screen", () => {+ event.sender.send("siyuan-event", "enter-full-screen");+ });+ currentWindow.on("leave-full-screen", () => {+ event.sender.send("siyuan-event", "leave-full-screen");+ });+ })ipcMain.on("siyuan-cmd", (event, data) => {let cmd = data;let webContentsId = event.sender.id@@ -720,9 +743,28 @@ app.whenReady().then(() => {case "hide":currentWindow.hide();break;+ case "minimize":+ currentWindow.minimize();+ break;+ case "maximize":+ currentWindow.maximize();+ break;+ case "restore":+ if (currentWindow.isFullScreen()) {+ currentWindow.setFullScreen(false);+ } else {+ currentWindow.unmaximize();+ }+ break;case "focus":currentWindow.focus();break;+ case "setAlwaysOnTopFalse":+ currentWindow.setAlwaysOnTop(false);+ break;+ case "setAlwaysOnTopTrue":+ currentWindow.setAlwaysOnTop(true, "pop-up-menu");+ break;case "clearCache":event.sender.session.clearCache();break;@@ -735,6 +777,16 @@ app.whenReady().then(() => {case "destroy":currentWindow.destroy();break;+ case "closeButtonBehavior":+ if (currentWindow.isFullScreen()) {+ currentWindow.once("leave-full-screen", () => {+ currentWindow.hide();+ });+ currentWindow.setFullScreen(false);+ } else {+ currentWindow.hide();+ }+ break;case "setProxy":event.sender.session.closeAllConnections().then(() => {event.sender.session.setProxy({proxyRules: data.proxyURL}).then(() => {@@ -842,7 +894,6 @@ app.whenReady().then(() => {if (mainScreen.id !== targetScreen.id) {win.setBounds(targetScreen.workArea);}- require("@electron/remote/main").enable(win.webContents);});ipcMain.on("siyuan-open-workspace", (event, data) => {const foundWorkspace = workspaces.find((item) => {@@ -960,7 +1011,6 @@ app.whenReady().then(() => {nodeIntegration: true, webviewTag: true, webSecurity: false, contextIsolation: false,},});- require("@electron/remote/main").enable(firstOpenWindow.webContents);let initHTMLPath = path.join(appDir, "app", "electron", "init.html");if (isDevEnv) {initHTMLPath = path.join(appDir, "electron", "init.html");diff --git a/app/package.json b/app/package.jsonindex 9d6d677b4a..8e49c5124e 100644--- a/app/package.json+++ b/app/package.json@@ -72,8 +72,5 @@"webpack": "^5.76.0","webpack-bundle-analyzer": "^4.5.0","webpack-cli": "^4.10.0"- },- "dependencies": {- "@electron/remote": "^2.0.11"}}diff --git a/app/pnpm-lock.yaml b/app/pnpm-lock.yamlindex 4507ac7fa6..cb468f42fb 100644--- a/app/pnpm-lock.yaml+++ b/app/pnpm-lock.yaml@@ -4,11 +4,6 @@ settings:autoInstallPeers: trueexcludeLinksFromLockfile: false-dependencies:- '@electron/remote':- specifier: ^2.0.11- version: 2.0.11([email protected])-devDependencies:'@types/node':specifier: ^18.13.0@@ -134,6 +129,7 @@ packages:global-agent: 3.0.0transitivePeerDependencies:- supports-color+ dev: true/@electron/[email protected]:resolution: {integrity: sha512-W5GQhJEosFNafewnS28d3bpQ37/s91CDWqxVchHfmv2dQSTWpOzNlUVQwYzC1ay5bChRV/A9BTL68yj0Pa+TSg==}@@ -160,14 +156,6 @@ packages:- supports-colordev: true- /@electron/[email protected]([email protected]):- resolution: {integrity: sha512-PYEs7W3GrQNuhgiMHjFEvL5MbAL6C7m1AwSAHGqC+xc33IdP7rcGtJSdTP2eg1ssyB3oI00KwTsiSlsQbAoXpA==}- peerDependencies:- electron: '>= 13.0.0'- dependencies:- electron: 26.3.0- dev: false-/@electron/[email protected]:resolution: {integrity: sha512-BdhBgm2ZBnYyYRLRgOjM5VHkyFItsbggJ0MHycOjKWdFGYwK97ZFXH54dTvUWEfha81vfvwr5On6XBjt99uDcg==}engines: {node: '>=8.6'}@@ -497,12 +485,14 @@ packages:/@sindresorhus/[email protected]:resolution: {integrity: sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw==}engines: {node: '>=10'}+ dev: true/@szmarczak/[email protected]:resolution: {integrity: sha512-4BAffykYOgO+5nzBWYwE3W90sBgLJoUPRWWcL8wlyiM8IB8ipJz3UMJ9KXQd1RKQXpKp8Tutn80HZtWsu2u76w==}engines: {node: '>=10'}dependencies:defer-to-connect: 2.0.1+ dev: true/@tootallnate/[email protected]:resolution: {integrity: sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==}@@ -516,6 +506,7 @@ packages:'@types/keyv': 3.1.4'@types/node': 18.13.0'@types/responselike': 1.0.0+ dev: true/@types/[email protected]:resolution: {integrity: sha512-9AonUzyTjXXhEOa0DnqpzZi6VHlqKMswga9EXjpXnnqxwLtdvPPtlO8evrI5D9S6asFRCQ6v+wpiUKbw+vKqyg==}@@ -560,6 +551,7 @@ packages:/@types/[email protected]:resolution: {integrity: sha512-SZs7ekbP8CN0txVG2xVRH6EgKmEm31BOxA07vkFaETzZz1xh+cbt8BcI0slpymvwhx5dlFnQG2rTlPVQn+iRPQ==}+ dev: true/@types/[email protected]:resolution: {integrity: sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==}@@ -569,6 +561,7 @@ packages:resolution: {integrity: sha512-BQ5aZNSCpj7D6K2ksrRCTmKRLEpnPvWDiLPfoGyhZ++8YtiK9d/3DBKPJgry359X/P1PfruyYwvnvwFjuEiEIg==}dependencies:'@types/node': 18.13.0+ dev: true/@types/[email protected]:resolution: {integrity: sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==}@@ -580,6 +573,7 @@ packages:/@types/[email protected]:resolution: {integrity: sha512-gC3TazRzGoOnoKAhUx+Q0t8S9Tzs74z7m0ipwGpSqQrleP14hKxP4/JUeEQcD3W1/aIpnWl8pHowI7WokuZpXg==}+ dev: true/@types/[email protected]:resolution: {integrity: sha512-ULqvZNGMv0zRFvqn8/4LSPtnmN4MfhlPNtJCTpKuIIxGVGZ2rYWzFXrvEBoh9CVyqSE7D6YFRJ1hydLHI6kbWw==}@@ -594,6 +588,7 @@ packages:resolution: {integrity: sha512-85Y2BjiufFzaMIlvJDvTTB8Fxl2xfLo4HgmHzVBz08w4wDePCTjYw66PdrolO0kzli3yam/YCgRufyo1DdQVTA==}dependencies:'@types/node': 18.13.0+ dev: true/@types/[email protected]:resolution: {integrity: sha512-NNm+gdePAX1VGvPcGZCDKQZKYSiAWigKhKaz5KF94hG6f2s8de9Ow5+7AbXoeKxL8gavZfk4UquSAygOF2duEQ==}@@ -606,6 +601,7 @@ packages:requiresBuild: truedependencies:'@types/node': 18.13.0+ dev: trueoptional: true/@typescript-eslint/[email protected](@typescript-eslint/[email protected])([email protected])([email protected]):@@ -1113,6 +1109,7 @@ packages:resolution: {integrity: sha512-d0II/GO9uf9lfUHH2BQsjxzRJZBdsjgsBiW4BvhWk/3qoKwQFjIDVN19PfX8F2D/r9PCMTtLWjYVCFrpeYUzsw==}requiresBuild: true+ dev: trueoptional: true@@ -1148,6 +1145,7 @@ packages:resolution: {integrity: sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==}+ dev: trueresolution: {integrity: sha512-tcBWO2Dl4e7Asr9hTGcpVrCe+F7DubpmqWCTbj4FHLmjqO2hIaC383acQubWtRJhdceqs5uBHs6Es+Sk//RKiQ==}@@ -1203,6 +1201,7 @@ packages:resolution: {integrity: sha512-2/kNscPhpcxrOigMZzbiWF7dz8ilhb/nIHU3EyZiXWXpeq/au8qJ8VhdftMkty3n7Gj6HIGalQG8oiBNB3AJgA==}engines: {node: '>=10.6.0'}+ dev: trueresolution: {integrity: sha512-pouW8/FmiPQbuGpkXQ9BAPv/Mo5xDGANgSNXzTzJ8DrKGuXOssM4wIQRjfanNRh3Yu5cfYPvcorqbhg2KIJtew==}@@ -1215,6 +1214,7 @@ packages:lowercase-keys: 2.0.0normalize-url: 6.1.0responselike: 2.0.1+ dev: trueresolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==}@@ -1329,6 +1329,7 @@ packages:resolution: {integrity: sha512-yjLXh88P599UOyPTFX0POsd7WxnbsVsGohcwzHOLspIhhpalPw1BcqED8NblyZLKcGrL8dTgMlcaZxV2jAD41Q==}dependencies:mimic-response: 1.0.1+ dev: trueresolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==}@@ -1469,12 +1470,14 @@ packages:optional: truedependencies:ms: 2.1.2+ dev: trueresolution: {integrity: sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==}engines: {node: '>=10'}dependencies:mimic-response: 3.1.0+ dev: trueresolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==}@@ -1483,6 +1486,7 @@ packages:resolution: {integrity: sha512-4tvttepXG1VaYGrRibk5EwJd1t4udunSOVMdLSAL6mId1ix438oPwPZMALY41FCijukO1L0twNcGsdzS7dHgDg==}engines: {node: '>=10'}+ dev: trueresolution: {integrity: sha512-uckOqKcfaVvtBdsVkdPv3XjveQJsNQqmhXgRi8uhvWWuPYZCNlzT8qAyblUgNoXdHdjMTzAqeGjAoli8f+bzPA==}@@ -1491,6 +1495,7 @@ packages:dependencies:has-property-descriptors: 1.0.0object-keys: 1.1.1+ dev: trueoptional: true@@ -1514,6 +1519,7 @@ packages:resolution: {integrity: sha512-T0NIuQpnTvFDATNuHN5roPwSBG83rFsuO+MXXH9/3N1eFbn4wcPjttvjMLEPWJ0RGUYgQE7cGgS3tNxbqCGM7g==}requiresBuild: true+ dev: trueoptional: true@@ -1680,6 +1686,7 @@ packages:extract-zip: 2.0.1transitivePeerDependencies:- supports-color+ dev: trueresolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==}@@ -1701,6 +1708,7 @@ packages:resolution: {integrity: sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==}dependencies:once: 1.4.0+ dev: trueresolution: {integrity: sha512-T0yTFjdpldGY8PmuXXR0PyQ1ufZpEGiHVrp7zHKB7jdR4qlmZHhONVM5AQOAWXuF/w3dnHbEQVrNptJgt7F+cQ==}@@ -1717,6 +1725,7 @@ packages:resolution: {integrity: sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==}engines: {node: '>=6'}+ dev: trueresolution: {integrity: sha512-/o+BXHmB7ocbHEAs6F2EnG0ogybVVUdkRunTT2glZU9XAaGmhqskrvKwqXuDfNjEO0LZKWdejEEpnq8aM0tOaw==}@@ -1731,6 +1740,7 @@ packages:resolution: {integrity: sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==}requiresBuild: true+ dev: trueoptional: true@@ -1783,6 +1793,7 @@ packages:resolution: {integrity: sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==}engines: {node: '>=10'}+ dev: trueresolution: {integrity: sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==}@@ -1919,6 +1930,7 @@ packages:'@types/yauzl': 2.10.0transitivePeerDependencies:- supports-color+ dev: trueresolution: {integrity: sha512-Wrk35e8ydCKDj/ArClo1VrPVmN8zph5V4AtHwIuHhvMXsKf73UT3BOD+azBIW+3wOJ4FhEH7zyaJCFvChjYvMA==}@@ -1964,6 +1976,7 @@ packages:resolution: {integrity: sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g==}dependencies:pend: 1.2.0+ dev: trueresolution: {integrity: sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==}@@ -2041,6 +2054,7 @@ packages:graceful-fs: 4.2.11jsonfile: 4.0.0universalify: 0.1.2+ dev: trueresolution: {integrity: sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==}@@ -2074,6 +2088,7 @@ packages:resolution: {integrity: sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==}requiresBuild: true+ dev: trueresolution: {integrity: sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g==}@@ -2091,6 +2106,7 @@ packages:function-bind: 1.1.1has: 1.0.3has-symbols: 1.0.3+ dev: trueoptional: true@@ -2098,6 +2114,7 @@ packages:engines: {node: '>=8'}dependencies:pump: 3.0.0+ dev: trueresolution: {integrity: sha512-0Gdjo/9+FzsYhXCEFueo2aY1z1tpXrxWZzP7k8ul9qt1U5o8rYJwTJYmaeHdrVosYIVYkOy2iwCJ9FdpocJhPQ==}@@ -2143,6 +2160,7 @@ packages:roarr: 2.15.4semver: 7.5.4serialize-error: 7.0.1+ dev: trueoptional: true@@ -2158,6 +2176,7 @@ packages:requiresBuild: truedependencies:define-properties: 1.1.4+ dev: trueoptional: true@@ -2198,9 +2217,11 @@ packages:lowercase-keys: 2.0.0p-cancelable: 2.1.1responselike: 2.0.1+ dev: trueresolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==}+ dev: trueresolution: {integrity: sha512-ax7ZYomf6jqPTQ4+XCpUGyXKHk5WweS+e05MBO4/y3WJ5RkmPXNKvX+bx1behVILVwr6JSQvZAku021CHPXG3Q==}@@ -2219,12 +2240,14 @@ packages:requiresBuild: truedependencies:get-intrinsic: 1.1.2+ dev: trueoptional: trueresolution: {integrity: sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==}engines: {node: '>= 0.4'}requiresBuild: true+ dev: trueoptional: true@@ -2232,6 +2255,7 @@ packages:engines: {node: '>= 0.4.0'}dependencies:function-bind: 1.1.1+ dev: trueresolution: {integrity: sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==}@@ -2309,6 +2333,7 @@ packages:resolution: {integrity: sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ==}+ dev: trueresolution: {integrity: sha512-n2hY8YdoRE1i7r6M0w9DIw5GgZN0G25P8zLCRQ8rjXtTU3vsNFBI/vWK/UIeE6g5MUUz6avwAPXmL6Fy9D/90w==}@@ -2327,6 +2352,7 @@ packages:dependencies:quick-lru: 5.1.1resolve-alpn: 1.2.1+ dev: trueresolution: {integrity: sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==}@@ -2541,6 +2567,7 @@ packages:resolution: {integrity: sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==}+ dev: trueresolution: {integrity: sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==}@@ -2561,6 +2588,7 @@ packages:resolution: {integrity: sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==}requiresBuild: true+ dev: trueoptional: true@@ -2580,6 +2608,7 @@ packages:resolution: {integrity: sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==}optionalDependencies:graceful-fs: 4.2.11+ dev: trueresolution: {integrity: sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==}@@ -2593,6 +2622,7 @@ packages:resolution: {integrity: sha512-5MHbFaKn8cNSmVW7BYnijeAVlE4cYA/SVkifVgrh7yotnfhKmjuXpDKjrABLnT0SfHWV21P8ow07OGfRrNDg8g==}dependencies:json-buffer: 3.0.1+ dev: trueresolution: {integrity: sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==}@@ -2663,12 +2693,14 @@ packages:resolution: {integrity: sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==}engines: {node: '>=8'}+ dev: trueresolution: {integrity: sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==}engines: {node: '>=10'}dependencies:yallist: 4.0.0+ dev: trueresolution: {integrity: sha512-OkeDaAZ/bQCxeFAozM55PKcKU0yJMPGifLwV4Qgjitu+5MoAfSQN4lsLJeXZ1b8w0x+/Emda6MZgXS1jvsapng==}@@ -2676,6 +2708,7 @@ packages:requiresBuild: truedependencies:escape-string-regexp: 4.0.0+ dev: trueoptional: true@@ -2716,10 +2749,12 @@ packages:resolution: {integrity: sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==}engines: {node: '>=4'}+ dev: trueresolution: {integrity: sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==}engines: {node: '>=10'}+ dev: trueresolution: {integrity: sha512-Qk7HcgaPkGG6eD77mLvZS1nmxlao3j+9PkrT9Uc7HAE1id3F41+DdBRYRYkbyfNRGzm8/YWtzhw7nVPmwhqTQw==}@@ -2781,6 +2816,7 @@ packages:resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==}+ dev: trueresolution: {integrity: sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==}@@ -2821,6 +2857,7 @@ packages:resolution: {integrity: sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A==}engines: {node: '>=10'}+ dev: trueresolution: {integrity: sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==}@@ -2837,12 +2874,14 @@ packages:resolution: {integrity: sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==}engines: {node: '>= 0.4'}requiresBuild: true+ dev: trueoptional: trueresolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==}dependencies:wrappy: 1.0.2+ dev: trueresolution: {integrity: sha512-ur5UIdyw5Y7yEj9wLzhqXiy6GZ3Mwx0yGI+5sMn2r0N0v3cKJvUmFH5yPP+WXh9e0xfyzyJX95D8l088DNFj7A==}@@ -2864,6 +2903,7 @@ packages:resolution: {integrity: sha512-BZOr3nRQHOntUjTrH8+Lh54smKHoHyur8We1V8DSMVrl5A2malOOwuJRnKRDjSnkoeBh4at6BwEnb5I7Jl31wg==}engines: {node: '>=8'}+ dev: trueresolution: {integrity: sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==}@@ -2948,6 +2988,7 @@ packages:resolution: {integrity: sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==}+ dev: trueresolution: {integrity: sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==}@@ -3072,12 +3113,14 @@ packages:resolution: {integrity: sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==}engines: {node: '>=0.4.0'}+ dev: trueresolution: {integrity: sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==}dependencies:end-of-stream: 1.4.4once: 1.4.0+ dev: trueresolution: {integrity: sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==}@@ -3091,6 +3134,7 @@ packages:resolution: {integrity: sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA==}engines: {node: '>=10'}+ dev: trueresolution: {integrity: sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==}@@ -3156,6 +3200,7 @@ packages:resolution: {integrity: sha512-0a1F4l73/ZFZOakJnQ3FvkJ2+gSTQWz/r2KE5OdDY0TxPm5h4GkqkWWfM47T7HsbnOtcJVEF4epCVy6u7Q3K+g==}+ dev: trueresolution: {integrity: sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg==}@@ -3187,6 +3232,7 @@ packages:resolution: {integrity: sha512-4gl03wn3hj1HP3yzgdI7d3lCkF95F21Pz4BPGvKHinyQzALR5CapwC8yIi0Rh58DEMQ/SguC03wFj2k0M/mHhw==}dependencies:lowercase-keys: 2.0.0+ dev: trueresolution: {integrity: sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==}@@ -3218,6 +3264,7 @@ packages:json-stringify-safe: 5.0.1semver-compare: 1.0.0sprintf-js: 1.1.2+ dev: trueoptional: true@@ -3301,11 +3348,13 @@ packages:resolution: {integrity: sha512-YM3/ITh2MJ5MtzaM429anh+x2jiLVjqILF4m4oyQB18W7Ggea7BfqdH/wGMK7dDiMghv/6WG7znWMwUDzJiXow==}requiresBuild: true+ dev: trueoptional: trueresolution: {integrity: sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==}hasBin: true+ dev: trueresolution: {integrity: sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==}@@ -3321,6 +3370,7 @@ packages:hasBin: truedependencies:lru-cache: 6.0.0+ dev: trueresolution: {integrity: sha512-8I8TjW5KMOKsZQTvoxjuSIa7foAwPWGOts+6o7sgjz41/qMD9VQHEDxi6PBvK2l0MXUmqZyNpUK+T2tQaaElvw==}@@ -3328,6 +3378,7 @@ packages:requiresBuild: truedependencies:type-fest: 0.13.1+ dev: trueoptional: true@@ -3418,6 +3469,7 @@ packages:resolution: {integrity: sha512-VE0SOVEHCk7Qc8ulkWw3ntAzXuqf7S2lvwQaDLRnUeIEaKNQJzV6BwmLKhOqT61aGhfUMrXeaBk+oDGCzvhcug==}requiresBuild: true+ dev: trueoptional: true@@ -3453,6 +3505,7 @@ packages:debug: 4.3.4transitivePeerDependencies:- supports-color+ dev: trueresolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==}@@ -3607,6 +3660,7 @@ packages:resolution: {integrity: sha512-34R7HTnG0XIJcBSn5XhDd7nNFPRcXYRZrBB2O2jdKqYODldSzBAqzsWoZYYvduky73toYS/ESqxPvkDf/F0XMg==}engines: {node: '>=10'}requiresBuild: true+ dev: trueoptional: true@@ -3623,6 +3677,7 @@ packages:resolution: {integrity: sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==}engines: {node: '>= 4.0.0'}+ dev: trueresolution: {integrity: sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==}@@ -3825,6 +3880,7 @@ packages:resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==}+ dev: trueresolution: {integrity: sha512-ri1Id1WinAX5Jqn9HejiGb8crfRio0Qgu8+MtL36rlTA6RLsMdWt1Az/19A2Qij6uSHUMphEFaTKa4WG+UNHNw==}@@ -3852,6 +3908,7 @@ packages:resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==}+ dev: trueresolution: {integrity: sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==}@@ -3876,3 +3933,4 @@ packages:dependencies:buffer-crc32: 0.2.13fd-slicer: 1.1.0+ dev: truediff --git a/app/src/boot/onGetConfig.ts b/app/src/boot/onGetConfig.tsindex d2c6289099..334ba91228 100644--- a/app/src/boot/onGetConfig.ts+++ b/app/src/boot/onGetConfig.ts@@ -1,7 +1,6 @@import {exportLayout, JSONToLayout, resetLayout, resizeTopbar, resizeTabs} from "../layout/util";import {setStorageVal} from "../protyle/util/compatibility";/// #if !BROWSER-import {getCurrentWindow} from "@electron/remote";import {ipcRenderer, webFrame} from "electron";import * as fs from "fs";import * as path from "path";@@ -153,34 +152,29 @@ export const onGetConfig = (isStart: boolean, app: App) => {addGA();};-export const initWindow = (app: App) => {+const winOnMaxRestore = async () => {/// #if !BROWSER- const winOnFocus = () => {- if (getSelection().rangeCount > 0) {- const range = getSelection().getRangeAt(0);- const startNode = range.startContainer.childNodes[range.startOffset] as HTMLElement;- if (startNode && startNode.nodeType !== 3 && (startNode.tagName === "TEXTAREA" || startNode.tagName === "INPUT")) {- startNode.focus();- } else {- focusByRange(getSelection().getRangeAt(0));- }- }- exportLayout({- reload: false,- onlyData: false,- errorExit: false- });- window.siyuan.altIsPressed = false;- window.siyuan.ctrlIsPressed = false;- window.siyuan.shiftIsPressed = false;- document.body.classList.remove("body--blur");- };-- const winOnBlur = () => {- document.body.classList.add("body--blur");- };+ const maxBtnElement = document.getElementById("maxWindow");+ const restoreBtnElement = document.getElementById("restoreWindow");+ const isFullScreen = await ipcRenderer.invoke(Constants.SIYUAN_GET, {+ cmd: "isFullScreen",+ });+ const isMaximized = await ipcRenderer.invoke(Constants.SIYUAN_GET, {+ cmd: "isMaximized",+ });+ if (isMaximized || isFullScreen) {+ restoreBtnElement.style.display = "flex";+ maxBtnElement.style.display = "none";+ } else {+ restoreBtnElement.style.display = "none";+ maxBtnElement.style.display = "flex";+ }+ /// #endif+};- const winOnClose = (currentWindow: Electron.BrowserWindow, close = false) => {+export const initWindow = async (app: App) => {+ /// #if !BROWSER+ const winOnClose = (close = false) => {exportLayout({reload: false,cb() {@@ -191,12 +185,7 @@ export const initWindow = (app: App) => {languages: window.siyuan.languages["_trayMenu"],});} else {- if (currentWindow.isFullScreen()) {- currentWindow.once("leave-full-screen", () => currentWindow.hide());- currentWindow.setFullScreen(false);- } else {- currentWindow.hide();- }+ ipcRenderer.send(Constants.SIYUAN_CMD, "closeButtonBehavior");}} else {exitSiYuan();@@ -207,38 +196,55 @@ export const initWindow = (app: App) => {});};- const winOnMaxRestore = () => {- const currentWindow = getCurrentWindow();- const maxBtnElement = document.getElementById("maxWindow");- const restoreBtnElement = document.getElementById("restoreWindow");- if (currentWindow.isMaximized() || currentWindow.isFullScreen()) {- restoreBtnElement.style.display = "flex";- maxBtnElement.style.display = "none";- } else {- restoreBtnElement.style.display = "none";- maxBtnElement.style.display = "flex";- }- };-- const winOnEnterFullscreen = () => {- if (isWindow()) {- setTabPosition();- } else {- document.getElementById("toolbar").style.paddingLeft = "0";- }- };-- const winOnLeaveFullscreen = () => {- if (isWindow()) {- setTabPosition();- } else {- document.getElementById("toolbar").setAttribute("style", "");+ ipcRenderer.send(Constants.SIYUAN_EVENT, "onEvent")+ ipcRenderer.on(Constants.SIYUAN_EVENT, (event, cmd) => {+ if (cmd === "focus") {+ if (getSelection().rangeCount > 0) {+ const range = getSelection().getRangeAt(0);+ const startNode = range.startContainer.childNodes[range.startOffset] as HTMLElement;+ if (startNode && startNode.nodeType !== 3 && (startNode.tagName === "TEXTAREA" || startNode.tagName === "INPUT")) {+ startNode.focus();+ } else {+ focusByRange(getSelection().getRangeAt(0));+ }+ }+ exportLayout({+ reload: false,+ onlyData: false,+ errorExit: false+ });+ window.siyuan.altIsPressed = false;+ window.siyuan.ctrlIsPressed = false;+ window.siyuan.shiftIsPressed = false;+ document.body.classList.remove("body--blur");+ } else if (cmd === "blur") {+ document.body.classList.add("body--blur");+ } else if (cmd === "enter-full-screen") {+ if ("darwin" === window.siyuan.config.system.os) {+ if (isWindow()) {+ setTabPosition();+ } else {+ document.getElementById("toolbar").style.paddingLeft = "0";+ }+ } else {+ winOnMaxRestore()+ }+ } else if (cmd === "leave-full-screen") {+ if ("darwin" === window.siyuan.config.system.os) {+ if (isWindow()) {+ setTabPosition();+ } else {+ document.getElementById("toolbar").setAttribute("style", "");+ }+ } else {+ winOnMaxRestore();+ }+ } else if (cmd === "maximize") {+ winOnMaxRestore();+ } else if (cmd === "unmaximize") {+ winOnMaxRestore();}- };-- const currentWindow = getCurrentWindow();- currentWindow.on("focus", winOnFocus);- currentWindow.on("blur", winOnBlur);+ });if (!isWindow()) {ipcRenderer.on(Constants.SIYUAN_OPEN_URL, (event, url) => {if (url.startsWith("siyuan://plugins/")) {@@ -304,7 +310,7 @@ export const initWindow = (app: App) => {if (isWindow()) {closeWindow(app);} else {- winOnClose(currentWindow, close);+ winOnClose(close);}});ipcRenderer.on(Constants.SIYUAN_SEND_WINDOWS, (e, ipcData: IWebSocketData) => {@@ -403,20 +409,6 @@ ${response.data.replace("%pages", "<span class=totalPages></span>").replace("%paipcRenderer.send(Constants.SIYUAN_CMD, {cmd: "hide", webContentsId: ipcData.webContentsId});});- window.addEventListener("beforeunload", () => {- currentWindow.off("focus", winOnFocus);- currentWindow.off("blur", winOnBlur);- if ("darwin" === window.siyuan.config.system.os) {- currentWindow.off("enter-full-screen", winOnEnterFullscreen);- currentWindow.off("leave-full-screen", winOnLeaveFullscreen);- } else {- currentWindow.off("enter-full-screen", winOnMaxRestore);- currentWindow.off("leave-full-screen", winOnMaxRestore);- currentWindow.off("maximize", winOnMaxRestore);- currentWindow.off("unmaximize", winOnMaxRestore);- }- }, false);-if (isWindow()) {document.body.insertAdjacentHTML("beforeend", `<div class="toolbar__window"><div class="toolbar__item ariaLabel" aria-label="${window.siyuan.languages.pin}" id="pinWindow">@@ -429,34 +421,18 @@ ${response.data.replace("%pages", "<span class=totalPages></span>").replace("%papinElement.classList.toggle("toolbar__item--active");if (pinElement.classList.contains("toolbar__item--active")) {pinElement.setAttribute("aria-label", window.siyuan.languages.unpin);- currentWindow.setAlwaysOnTop(true, "pop-up-menu");+ ipcRenderer.send(Constants.SIYUAN_CMD, "setAlwaysOnTopTrue");} else {pinElement.setAttribute("aria-label", window.siyuan.languages.pin);- currentWindow.setAlwaysOnTop(false);+ ipcRenderer.send(Constants.SIYUAN_CMD, "setAlwaysOnTopFalse");}});}- if ("darwin" === window.siyuan.config.system.os) {- document.getElementById("drag")?.addEventListener("dblclick", () => {- if (currentWindow.isMaximized()) {- currentWindow.unmaximize();- } else {- currentWindow.maximize();- }- });- const toolbarElement = document.getElementById("toolbar");- currentWindow.on("enter-full-screen", winOnEnterFullscreen);- currentWindow.on("leave-full-screen", winOnLeaveFullscreen);- if (currentWindow.isFullScreen() && !isWindow()) {- toolbarElement.style.paddingLeft = "0";- }- return;- }-- document.body.classList.add("body--win32");+ if ("darwin" !== window.siyuan.config.system.os) {+ document.body.classList.add("body--win32");- // 添加窗口控件- const controlsHTML = `<div class="toolbar__item ariaLabel toolbar__item--win" aria-label="${window.siyuan.languages.min}" id="minWindow">+ // 添加窗口控件+ const controlsHTML = `<div class="toolbar__item ariaLabel toolbar__item--win" aria-label="${window.siyuan.languages.min}" id="minWindow"><svg><use xlink:href="#iconMin"></use></svg>@@ -476,45 +452,46 @@ ${response.data.replace("%pages", "<span class=totalPages></span>").replace("%pa<use xlink:href="#iconClose"></use></svg></div>`;- if (isWindow()) {- document.querySelector(".toolbar__window").insertAdjacentHTML("beforeend", controlsHTML);- } else {- document.getElementById("windowControls").innerHTML = controlsHTML;- }- const maxBtnElement = document.getElementById("maxWindow");- const restoreBtnElement = document.getElementById("restoreWindow");-- restoreBtnElement.addEventListener("click", () => {- if (currentWindow.isFullScreen()) {- currentWindow.setFullScreen(false);+ if (isWindow()) {+ document.querySelector(".toolbar__window").insertAdjacentHTML("beforeend", controlsHTML);} else {- currentWindow.unmaximize();+ document.getElementById("windowControls").innerHTML = controlsHTML;}- });- maxBtnElement.addEventListener("click", () => {- currentWindow.maximize();- });+ const maxBtnElement = document.getElementById("maxWindow");+ const restoreBtnElement = document.getElementById("restoreWindow");- winOnMaxRestore();- currentWindow.on("maximize", winOnMaxRestore);- currentWindow.on("unmaximize", winOnMaxRestore);- currentWindow.on("enter-full-screen", winOnMaxRestore);- currentWindow.on("leave-full-screen", winOnMaxRestore);- const minBtnElement = document.getElementById("minWindow");- const closeBtnElement = document.getElementById("closeWindow");- minBtnElement.addEventListener("click", () => {- if (minBtnElement.classList.contains("window-controls__item--disabled")) {- return;- }- currentWindow.minimize();- });- closeBtnElement.addEventListener("click", () => {- if (isWindow()) {- closeWindow(app);- } else {- winOnClose(currentWindow);+ restoreBtnElement.addEventListener("click", () => {+ ipcRenderer.send(Constants.SIYUAN_CMD, "restore");+ });+ maxBtnElement.addEventListener("click", () => {+ ipcRenderer.send(Constants.SIYUAN_CMD, "maximize");+ });++ winOnMaxRestore();+ const minBtnElement = document.getElementById("minWindow");+ const closeBtnElement = document.getElementById("closeWindow");+ minBtnElement.addEventListener("click", () => {+ if (minBtnElement.classList.contains("window-controls__item--disabled")) {+ return;+ }+ ipcRenderer.send(Constants.SIYUAN_CMD, "minimize");+ });+ closeBtnElement.addEventListener("click", () => {+ if (isWindow()) {+ closeWindow(app);+ } else {+ winOnClose();+ }+ });+ } else {+ const toolbarElement = document.getElementById("toolbar");+ const isFullScreen = await ipcRenderer.invoke(Constants.SIYUAN_GET, {+ cmd: "isFullScreen",+ });+ if (isFullScreen && !isWindow()) {+ toolbarElement.style.paddingLeft = "0";}- });+ }/// #elseif (!isWindow()) {document.querySelector(".toolbar").classList.add("toolbar--browser");diff --git a/app/src/config/exportConfig.ts b/app/src/config/exportConfig.tsindex d409a98169..42a9426da5 100644--- a/app/src/config/exportConfig.ts+++ b/app/src/config/exportConfig.ts@@ -187,7 +187,7 @@ export const exportConfig = {});/// #elseconst filePaths = await ipcRenderer.invoke(Constants.SIYUAN_GET,{- cmd: "showOpenDialogSync",+ cmd: "showOpenDialog",title: window.siyuan.languages.export + " " + "Data",properties: ["createDirectory", "openDirectory"],});diff --git a/app/src/constants.ts b/app/src/constants.tsindex ae373d75ea..896b9f3199 100644--- a/app/src/constants.ts+++ b/app/src/constants.ts@@ -26,6 +26,7 @@ export abstract class Constants {// 渲染进程调主进程public static readonly SIYUAN_CMD: string = "siyuan-cmd";public static readonly SIYUAN_GET: string = "siyuan-get";+ public static readonly SIYUAN_EVENT: string = "siyuan-event";public static readonly SIYUAN_CONFIG_TRAY: string = "siyuan-config-tray";public static readonly SIYUAN_QUIT: string = "siyuan-quit";diff --git a/app/src/menus/workspace.ts b/app/src/menus/workspace.tsindex c9bd801e7f..35e8bdc108 100644--- a/app/src/menus/workspace.ts+++ b/app/src/menus/workspace.ts@@ -1,6 +1,5 @@import {MenuItem} from "./Menu";/// #if !BROWSER-import {getCurrentWindow} from "@electron/remote";import {ipcRenderer} from "electron";/// #endifimport {openHistory} from "../history/history";@@ -407,7 +406,7 @@ export const workspaceMenu = (app: App, rect: DOMRect) => {label: window.siyuan.languages.debug,icon: "iconBug",click: () => {- getCurrentWindow().webContents.openDevTools({mode: "bottom"});+ ipcRenderer.send(Constants.SIYUAN_CMD, "openDevTools");}}).element);/// #endifdiff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.tsindex 060a4ddc20..4e03d597df 100644--- a/app/src/protyle/wysiwyg/index.ts+++ b/app/src/protyle/wysiwyg/index.ts@@ -46,8 +46,7 @@ import {import {transaction, updateTransaction} from "./transaction";import {hideElements} from "../ui/hideElements";/// #if !BROWSER-import {shell} from "electron";-import {getCurrentWindow} from "@electron/remote";+import {ipcRenderer, shell} from "electron";/// #endifimport {getEnableHTML, removeEmbed} from "./removeEmbed";import {keydown} from "./keydown";@@ -1502,7 +1501,7 @@ export class WYSIWYG {}if (event.inputType === "historyUndo") {/// #if !BROWSER- getCurrentWindow().webContents.redo();+ ipcRenderer.send(Constants.SIYUAN_CMD, "redo");/// #endifwindow.siyuan.menus.menu.remove();return;diff --git a/app/stage/auth.html b/app/stage/auth.htmlindex 669e1e6d68..ff0ad56542 100644--- a/app/stage/auth.html+++ b/app/stage/auth.html@@ -437,7 +437,6 @@const exitApp = () => {try {const {ipcRenderer} = require('electron')- const {getCurrentWindow} = require('@electron/remote')ipcRenderer.send('siyuan-quit', window.location.port)} catch (e) {if ((window.webkit && window.webkit.messageHandlers) || window.JSAndroid) {