🎨 工作空间多开
This commit is contained in:
parent
aabc1d4a85
commit
f316c44d35
2 changed files with 8 additions and 4 deletions
|
@ -58,8 +58,8 @@ try {
|
|||
app.exit()
|
||||
}
|
||||
|
||||
const getServer = () => {
|
||||
return 'http://127.0.0.1:' + kernelPort
|
||||
const getServer = (port = kernelPort) => {
|
||||
return 'http://127.0.0.1:' + port
|
||||
}
|
||||
|
||||
const sleep = (ms) => {
|
||||
|
@ -338,7 +338,8 @@ const boot = () => {
|
|||
Menu.setApplicationMenu(menu)
|
||||
// 当前页面链接使用浏览器打开
|
||||
currentWindow.webContents.on('will-navigate', (event, url) => {
|
||||
if (url.startsWith(getServer())) {
|
||||
const currentURL = new URL(event.sender.getURL())
|
||||
if (url.startsWith(getServer(currentURL.port))) {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -750,7 +751,7 @@ app.whenReady().then(() => {
|
|||
return true
|
||||
}
|
||||
})
|
||||
await fetch(getServer() + '/api/system/uiproc?pid=' + process.pid,
|
||||
await fetch(getServer(data.port) + '/api/system/uiproc?pid=' + process.pid,
|
||||
{method: 'POST'})
|
||||
})
|
||||
ipcMain.on('siyuan-hotkey', (event, data) => {
|
||||
|
@ -932,10 +933,12 @@ powerMonitor.on('resume', async () => {
|
|||
}
|
||||
|
||||
writeLog('sync after system resume')
|
||||
// TODO
|
||||
fetch(getServer() + '/api/sync/performSync', {method: 'POST'})
|
||||
})
|
||||
|
||||
powerMonitor.on('shutdown', () => {
|
||||
writeLog('system shutdown')
|
||||
// TODO
|
||||
fetch(getServer() + '/api/system/exit', {method: 'POST'})
|
||||
})
|
||||
|
|
|
@ -139,6 +139,7 @@ export const onGetConfig = (isStart: boolean) => {
|
|||
languages: window.siyuan.languages["_trayMenu"],
|
||||
workspaceDir: window.siyuan.config.system.workspaceDir,
|
||||
id: getCurrentWindow().id,
|
||||
port: location.port
|
||||
});
|
||||
ipcRenderer.send(Constants.SIYUAN_HOTKEY, {
|
||||
languages: window.siyuan.languages["_trayMenu"],
|
||||
|
|
Loading…
Add table
Reference in a new issue