diff --git a/app/src/dialog/confirmDialog.ts b/app/src/dialog/confirmDialog.ts
index d58701784..b242e2897 100644
--- a/app/src/dialog/confirmDialog.ts
+++ b/app/src/dialog/confirmDialog.ts
@@ -1,7 +1,7 @@
import {isMobile} from "../util/functions";
import {Dialog} from "./index";
-export const confirmDialog = (title: string, text: string, confirm?: () => void) => {
+export const confirmDialog = (title: string, text: string, confirm?: () => void, cancel?: () => void) => {
const dialog = new Dialog({
title,
content: `
${text}
@@ -13,6 +13,9 @@ export const confirmDialog = (title: string, text: string, confirm?: () => void)
});
const btnsElement = dialog.element.querySelectorAll(".b3-button");
btnsElement[0].addEventListener("click", () => {
+ if (cancel) {
+ cancel();
+ }
dialog.destroy();
});
btnsElement[1].addEventListener("click", () => {
diff --git a/app/src/dialog/processSystem.ts b/app/src/dialog/processSystem.ts
index 37dba8479..5c6d0467d 100644
--- a/app/src/dialog/processSystem.ts
+++ b/app/src/dialog/processSystem.ts
@@ -8,6 +8,7 @@ import {exportLayout} from "../layout/util";
import {showMessage} from "./message";
import {Dialog} from "./index";
import {isMobile} from "../util/functions";
+import {confirmDialog} from "./confirmDialog";
export const lockFile = (id: string) => {
const html = `
@@ -101,18 +102,27 @@ export const exitSiYuan = () => {
});
}
} else if (response.code === 2) { // 提示新安装包
- const msgId = showMessage(response.msg, response.data.closeTimeout, "info");
- const buttonElement = document.querySelector(`#message [data-id="${msgId}"] button`);
- if (buttonElement) {
- buttonElement.addEventListener("click", () => {
- fetchPost("/api/system/exit", {force: true}, () => {
- /// #if !BROWSER
- ipcRenderer.send(Constants.SIYUAN_CONFIG_CLOSETRAY);
- ipcRenderer.send(Constants.SIYUAN_QUIT);
- /// #endif
- });
+ confirmDialog(window.siyuan.languages.tip, response.msg, () => {
+ fetchPost("/api/system/exit", {
+ force: true,
+ execInstallPkg: 2 // 0:默认检查新版本,1:不执行新版本安装,2:执行新版本安装
+ }, () => {
+ /// #if !BROWSER
+ ipcRenderer.send(Constants.SIYUAN_CONFIG_CLOSETRAY);
+ ipcRenderer.send(Constants.SIYUAN_QUIT);
+ /// #endif
});
- }
+ }, () => {
+ fetchPost("/api/system/exit", {
+ force: true,
+ execInstallPkg: 1 // 0:默认检查新版本,1:不执行新版本安装,2:执行新版本安装
+ }, () => {
+ /// #if !BROWSER
+ ipcRenderer.send(Constants.SIYUAN_CONFIG_CLOSETRAY);
+ ipcRenderer.send(Constants.SIYUAN_QUIT);
+ /// #endif
+ });
+ })
} else { // 正常退出
/// #if !BROWSER
ipcRenderer.send(Constants.SIYUAN_CONFIG_CLOSETRAY);