🎨 工作空间多开

This commit is contained in:
Vanessa 2023-01-06 16:49:44 +08:00
parent f316c44d35
commit 2296b6dc63

View file

@ -53,8 +53,10 @@ try {
} }
} catch (e) { } catch (e) {
console.error(e) console.error(e)
require('electron').dialog.showErrorBox('创建配置目录失败 Failed to create config directory', require('electron').
'思源需要在用户家目录下创建配置文件夹(~/.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.') 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() app.exit()
} }
@ -834,9 +836,9 @@ app.whenReady().then(() => {
} }
} }
const workspace = getArg("--workspace") const workspace = getArg('--workspace')
if (workspace) { if (workspace) {
writeLog("got arg [--workspace=" + workspace + "]") writeLog('got arg [--workspace=' + workspace + ']')
} }
initKernel(workspace).then((isSucc) => { initKernel(workspace).then((isSucc) => {
if (isSucc) { if (isSucc) {
@ -933,12 +935,17 @@ powerMonitor.on('resume', async () => {
} }
writeLog('sync after system resume') writeLog('sync after system resume')
// TODO workspaces.forEach(item => {
fetch(getServer() + '/api/sync/performSync', {method: 'POST'}) const currentURL = new URL(item.browserWindow.getURL())
fetch(getServer(currentURL.port) + '/api/sync/performSync',
{method: 'POST'})
})
}) })
powerMonitor.on('shutdown', () => { powerMonitor.on('shutdown', () => {
writeLog('system shutdown') writeLog('system shutdown')
// TODO workspaces.forEach(item => {
fetch(getServer() + '/api/system/exit', {method: 'POST'}) const currentURL = new URL(item.browserWindow.getURL())
fetch(getServer(currentURL.port) + '/api/system/exit', {method: 'POST'})
})
}) })