From 9403046dfc68567b5cc8c2aaa7f0df6683430447 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Sun, 19 Nov 2023 22:44:12 +0800 Subject: [PATCH 1/4] :art: Force using discrete GPU when there are multiple GPUs available on the desktop https://github.com/siyuan-note/siyuan/issues/9694 --- app/electron/main.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/electron/main.js b/app/electron/main.js index dec79e7c5..3dc0a811d 100644 --- a/app/electron/main.js +++ b/app/electron/main.js @@ -595,6 +595,7 @@ app.commandLine.appendSwitch("disable-web-security"); app.commandLine.appendSwitch("auto-detect", "false"); app.commandLine.appendSwitch("no-proxy-server"); app.commandLine.appendSwitch("enable-features", "PlatformHEVCDecoderSupport"); +app.commandLine.appendSwitch("force_high_performance_gpu"); // Force using discrete GPU when there are multiple GPUs available on the desktop https://github.com/siyuan-note/siyuan/issues/9694 app.setPath("userData", app.getPath("userData") + "-Electron"); // `~/.config` 下 Electron 相关文件夹名称改为 `SiYuan-Electron` https://github.com/siyuan-note/siyuan/issues/3349 From 5a727078bea7fe633428f1bdeccc8d368751fecf Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Mon, 20 Nov 2023 10:29:12 +0800 Subject: [PATCH 2/4] :art: Support set Chromium command line arguments on the desktop https://github.com/siyuan-note/siyuan/issues/9696 --- app/electron/main.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/app/electron/main.js b/app/electron/main.js index 3dc0a811d..26e7622ee 100644 --- a/app/electron/main.js +++ b/app/electron/main.js @@ -590,6 +590,7 @@ const initKernel = (workspace, port, lang) => { }; app.setAsDefaultProtocolClient("siyuan"); +app.setPath("userData", app.getPath("userData") + "-Electron"); // `~/.config` 下 Electron 相关文件夹名称改为 `SiYuan-Electron` https://github.com/siyuan-note/siyuan/issues/3349 app.commandLine.appendSwitch("disable-web-security"); app.commandLine.appendSwitch("auto-detect", "false"); @@ -597,7 +598,21 @@ app.commandLine.appendSwitch("no-proxy-server"); app.commandLine.appendSwitch("enable-features", "PlatformHEVCDecoderSupport"); app.commandLine.appendSwitch("force_high_performance_gpu"); // Force using discrete GPU when there are multiple GPUs available on the desktop https://github.com/siyuan-note/siyuan/issues/9694 -app.setPath("userData", app.getPath("userData") + "-Electron"); // `~/.config` 下 Electron 相关文件夹名称改为 `SiYuan-Electron` https://github.com/siyuan-note/siyuan/issues/3349 +// Support set Chromium command line arguments on the desktop https://github.com/siyuan-note/siyuan/issues/9696 +writeLog("app is packaged [" + app.isPackaged + "], command line args [" + process.argv.join(", ") + "]"); +let argStart = 1; +if (!app.isPackaged) { + argStart = 2 +} +for (let i = argStart; i < process.argv.length; i++) { + if (process.argv[i].startsWith("--workspace=") || process.argv[i].startsWith("--port=")) { + // 跳过内置参数 + continue + } + + app.commandLine.appendSwitch(process.argv[i]); + writeLog("command line switch [" + process.argv[i] + "]"); +} app.whenReady().then(() => { const resetTrayMenu = (tray, lang, mainWindow) => { From 1399757e76661aa6178eedb077043ebca4b84328 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Mon, 20 Nov 2023 10:54:06 +0800 Subject: [PATCH 3/4] :art: Support set Chromium command line arguments on the desktop https://github.com/siyuan-note/siyuan/issues/9696 --- app/electron/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/electron/main.js b/app/electron/main.js index 26e7622ee..8ff0697cf 100644 --- a/app/electron/main.js +++ b/app/electron/main.js @@ -605,7 +605,7 @@ if (!app.isPackaged) { argStart = 2 } for (let i = argStart; i < process.argv.length; i++) { - if (process.argv[i].startsWith("--workspace=") || process.argv[i].startsWith("--port=")) { + if (process.argv[i].startsWith("--workspace=") || process.argv[i].startsWith("--port=") || process.argv[i].startsWith("siyuan://")) { // 跳过内置参数 continue } From dfb837e5ce2f81449cdc82acb1a8cf4110669bde Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Mon, 20 Nov 2023 10:55:04 +0800 Subject: [PATCH 4/4] :art: Support set Chromium command line arguments on the desktop https://github.com/siyuan-note/siyuan/issues/9696 --- app/electron/main.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/electron/main.js b/app/electron/main.js index 8ff0697cf..ec8b160c5 100644 --- a/app/electron/main.js +++ b/app/electron/main.js @@ -605,13 +605,14 @@ if (!app.isPackaged) { argStart = 2 } for (let i = argStart; i < process.argv.length; i++) { - if (process.argv[i].startsWith("--workspace=") || process.argv[i].startsWith("--port=") || process.argv[i].startsWith("siyuan://")) { + let arg = process.argv[i]; + if (arg.startsWith("--workspace=") || arg.startsWith("--port=") || arg.startsWith("siyuan://")) { // 跳过内置参数 continue } - app.commandLine.appendSwitch(process.argv[i]); - writeLog("command line switch [" + process.argv[i] + "]"); + app.commandLine.appendSwitch(arg); + writeLog("command line switch [" + arg + "]"); } app.whenReady().then(() => {