From 3131281724d8fa5a64b57d7e0efa9c55f972b6f9 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Fri, 6 Jan 2023 09:49:31 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E6=A1=8C=E9=9D=A2=E7=AB=AF=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E5=90=8C=E6=97=B6=E6=89=93=E5=BC=80=E5=A4=9A=E4=B8=AA?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E7=A9=BA=E9=97=B4=20https://github.com/siyua?= =?UTF-8?q?n-note/siyuan/issues/4567?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/electron/main.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/app/electron/main.js b/app/electron/main.js index 91448136c..fb553c89c 100644 --- a/app/electron/main.js +++ b/app/electron/main.js @@ -53,10 +53,8 @@ try { } } catch (e) { console.error(e) - require('electron'). - dialog. - showErrorBox('创建配置目录失败 Failed to create config directory', - '思源需要在用户家目录下创建配置文件夹(~/.config/siyuan),请确保该路径具有写入权限。\n\nSiYuan needs to create a configuration folder (~/.config/siyuan) in the user\'s home directory. Please make sure that the path has write permissions.') + require('electron').dialog.showErrorBox('创建配置目录失败 Failed to create config directory', + '思源需要在用户家目录下创建配置文件夹(~/.config/siyuan),请确保该路径具有写入权限。\n\nSiYuan needs to create a configuration folder (~/.config/siyuan) in the user\'s home directory. Please make sure that the path has write permissions.') app.exit() } @@ -416,6 +414,8 @@ const initKernel = (workspace, lang) => { } if (workspace) { cmds.push('--workspace', workspace) + } + if (lang) { cmds.push('--lang', lang) } let cmd = `ui version [${appVer}], booting kernel [${kernelPath} ${cmds.join( @@ -826,7 +826,19 @@ app.whenReady().then(() => { firstOpenWindow.destroy() }) } else { - initKernel().then((isSucc) => { + const getArg = (name) => { + for (let i = 0; i < process.argv.length; i++) { + if (process.argv[i] === name) { + return process.argv[i + 1] + } + } + } + + const workspace = getArg("--workspace") + if (workspace) { + writeLog("got arg [--workspace=" + workspace + "]") + } + initKernel(workspace).then((isSucc) => { if (isSucc) { boot() }