From 2296b6dc633e520f51a17a2c44c8b25419d83391 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Fri, 6 Jan 2023 16:49:44 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E5=B7=A5=E4=BD=9C=E7=A9=BA=E9=97=B4?= =?UTF-8?q?=E5=A4=9A=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/electron/main.js | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/app/electron/main.js b/app/electron/main.js index cf840b8e1..0d386bc1f 100644 --- a/app/electron/main.js +++ b/app/electron/main.js @@ -53,8 +53,10 @@ 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() } @@ -834,9 +836,9 @@ app.whenReady().then(() => { } } - const workspace = getArg("--workspace") + const workspace = getArg('--workspace') if (workspace) { - writeLog("got arg [--workspace=" + workspace + "]") + writeLog('got arg [--workspace=' + workspace + ']') } initKernel(workspace).then((isSucc) => { if (isSucc) { @@ -933,12 +935,17 @@ powerMonitor.on('resume', async () => { } writeLog('sync after system resume') - // TODO - fetch(getServer() + '/api/sync/performSync', {method: 'POST'}) + workspaces.forEach(item => { + const currentURL = new URL(item.browserWindow.getURL()) + fetch(getServer(currentURL.port) + '/api/sync/performSync', + {method: 'POST'}) + }) }) powerMonitor.on('shutdown', () => { writeLog('system shutdown') - // TODO - fetch(getServer() + '/api/system/exit', {method: 'POST'}) + workspaces.forEach(item => { + const currentURL = new URL(item.browserWindow.getURL()) + fetch(getServer(currentURL.port) + '/api/system/exit', {method: 'POST'}) + }) })