From d752f006caa84c0657cff8f33e9c66712b1f68ac Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Fri, 6 Jan 2023 18:44:56 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E6=A1=8C=E9=9D=A2=E7=AB=AF=E5=86=85?= =?UTF-8?q?=E6=A0=B8=E8=BF=9B=E7=A8=8B=E6=A0=B9=E6=8D=AE=20Electron=20?= =?UTF-8?q?=E4=B8=BB=E8=BF=9B=E7=A8=8B=E5=88=A4=E6=96=AD=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E9=80=80=E5=87=BA=20Fix=20https://github.com?= =?UTF-8?q?/siyuan-note/siyuan/issues/7002?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/electron/main.js | 15 +++++++-------- kernel/model/process.go | 1 + 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/electron/main.js b/app/electron/main.js index 0d386bc1f..712db5a03 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() } @@ -897,6 +895,7 @@ app.on('before-quit', (event) => { }) const {powerMonitor} = require('electron') +const {write} = require("fs"); powerMonitor.on('suspend', () => { writeLog('system suspend') @@ -934,11 +933,11 @@ powerMonitor.on('resume', async () => { return } - writeLog('sync after system resume') workspaces.forEach(item => { const currentURL = new URL(item.browserWindow.getURL()) - fetch(getServer(currentURL.port) + '/api/sync/performSync', - {method: 'POST'}) + const server = getServer(currentURL.port) + writeLog('sync after system resume [' + server + '/api/sync/performSync' + ']') + fetch(server + '/api/sync/performSync', {method: 'POST'}) }) }) @@ -946,6 +945,6 @@ powerMonitor.on('shutdown', () => { writeLog('system shutdown') workspaces.forEach(item => { const currentURL = new URL(item.browserWindow.getURL()) - fetch(getServer(currentURL.port) + '/api/system/exit', {method: 'POST'}) + fetch(getServer(currentURL.port) + '/api/system/exit', {method: 'POST'}) }) }) diff --git a/kernel/model/process.go b/kernel/model/process.go index 4c7f84d92..2e00c5e1d 100644 --- a/kernel/model/process.go +++ b/kernel/model/process.go @@ -42,6 +42,7 @@ func HookDesktopUIProc() { return } + time.Sleep(30 * time.Second) uiProcNames := []string{"siyuan", "electron"} existUIProc := false for range time.Tick(7 * time.Second) {