This commit is contained in:
parent
25b8f08470
commit
77bd2634e1
4 changed files with 16 additions and 10 deletions
|
@ -657,12 +657,14 @@ app.whenReady().then(() => {
|
|||
ipcMain.on('siyuan-export-close', (event, id) => {
|
||||
BrowserWindow.fromId(id).webContents.send('siyuan-export-close', data)
|
||||
})
|
||||
ipcMain.on('siyuan-quit', (id) => {
|
||||
ipcMain.on('siyuan-quit', (event, id) => {
|
||||
const mainWindow = BrowserWindow.fromId(id)
|
||||
let tray
|
||||
workspaces.find((item, index) => {
|
||||
if (item.id === id) {
|
||||
mainWindow.destroy()
|
||||
if (workspaces.length > 1) {
|
||||
mainWindow.destroy()
|
||||
}
|
||||
tray = item.tray
|
||||
workspaces.splice(index, 1)
|
||||
return true
|
||||
|
@ -830,9 +832,11 @@ app.on('second-instance', (event, commandLine) => {
|
|||
})
|
||||
|
||||
app.on('activate', () => {
|
||||
const mainWindow = workspaces[0].browserWindow
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.show()
|
||||
if (workspaces.length > 0) {
|
||||
const mainWindow = workspaces[0].browserWindow
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.show()
|
||||
}
|
||||
}
|
||||
if (BrowserWindow.getAllWindows().length === 0) {
|
||||
boot()
|
||||
|
|
|
@ -93,7 +93,7 @@ export const exitSiYuan = () => {
|
|||
buttonElement.addEventListener("click", () => {
|
||||
fetchPost("/api/system/exit", {force: true}, () => {
|
||||
/// #if !BROWSER
|
||||
ipcRenderer.send(Constants.SIYUAN_QUIT);
|
||||
ipcRenderer.send(Constants.SIYUAN_QUIT, getCurrentWindow().id);
|
||||
/// #else
|
||||
if (["ios", "android"].includes(window.siyuan.config.system.container) && (window.webkit?.messageHandlers || window.JSAndroid)) {
|
||||
window.location.href = "siyuan://api/system/exit";
|
||||
|
@ -117,7 +117,7 @@ export const exitSiYuan = () => {
|
|||
}, 2000);
|
||||
// 然后等待一段时间后再退出,避免界面主进程退出以后内核子进程被杀死
|
||||
setTimeout(() => {
|
||||
ipcRenderer.send(Constants.SIYUAN_QUIT);
|
||||
ipcRenderer.send(Constants.SIYUAN_QUIT, getCurrentWindow().id);
|
||||
}, 4000);
|
||||
/// #endif
|
||||
});
|
||||
|
@ -127,13 +127,13 @@ export const exitSiYuan = () => {
|
|||
execInstallPkg: 1 // 0:默认检查新版本,1:不执行新版本安装,2:执行新版本安装
|
||||
}, () => {
|
||||
/// #if !BROWSER
|
||||
ipcRenderer.send(Constants.SIYUAN_QUIT);
|
||||
ipcRenderer.send(Constants.SIYUAN_QUIT, getCurrentWindow().id);
|
||||
/// #endif
|
||||
});
|
||||
});
|
||||
} else { // 正常退出
|
||||
/// #if !BROWSER
|
||||
ipcRenderer.send(Constants.SIYUAN_QUIT);
|
||||
ipcRenderer.send(Constants.SIYUAN_QUIT, getCurrentWindow().id);
|
||||
/// #else
|
||||
if (["ios", "android"].includes(window.siyuan.config.system.container) && (window.webkit?.messageHandlers || window.JSAndroid)) {
|
||||
window.location.href = "siyuan://api/system/exit";
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import {Constants} from "../constants";
|
||||
/// #if !BROWSER
|
||||
import {ipcRenderer} from "electron";
|
||||
import {getCurrentWindow} from "@electron/remote";
|
||||
/// #endif
|
||||
import {processMessage} from "./processMessage";
|
||||
import {kernelError} from "../dialog/processSystem";
|
||||
|
@ -48,7 +49,7 @@ export const fetchPost = (url: string, data?: any, cb?: (response: IWebSocketDat
|
|||
if (url === "/api/system/exit" || url === "/api/system/setWorkspaceDir" || (
|
||||
["/api/system/setUILayout"].includes(url) && data.exit // 内核中断,点关闭处理
|
||||
)) {
|
||||
ipcRenderer.send(Constants.SIYUAN_QUIT);
|
||||
ipcRenderer.send(Constants.SIYUAN_QUIT, getCurrentWindow().id);
|
||||
}
|
||||
/// #endif
|
||||
});
|
||||
|
|
|
@ -367,6 +367,7 @@ const initWindow = () => {
|
|||
document.body.classList.add("body--blur");
|
||||
});
|
||||
ipcRenderer.on(Constants.SIYUAN_OPENURL, (event, url) => {
|
||||
console.log(event, url)
|
||||
if (!/^siyuan:\/\/blocks\/\d{14}-\w{7}/.test(url)) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue