mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 09:30:14 +01:00
This commit is contained in:
parent
7987c2417a
commit
efc4b81933
2 changed files with 25 additions and 12 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
import {isMobile} from "../util/functions";
|
import {isMobile} from "../util/functions";
|
||||||
import {Dialog} from "./index";
|
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({
|
const dialog = new Dialog({
|
||||||
title,
|
title,
|
||||||
content: `<div class="b3-dialog__content">${text}</div>
|
content: `<div class="b3-dialog__content">${text}</div>
|
||||||
|
|
@ -13,6 +13,9 @@ export const confirmDialog = (title: string, text: string, confirm?: () => void)
|
||||||
});
|
});
|
||||||
const btnsElement = dialog.element.querySelectorAll(".b3-button");
|
const btnsElement = dialog.element.querySelectorAll(".b3-button");
|
||||||
btnsElement[0].addEventListener("click", () => {
|
btnsElement[0].addEventListener("click", () => {
|
||||||
|
if (cancel) {
|
||||||
|
cancel();
|
||||||
|
}
|
||||||
dialog.destroy();
|
dialog.destroy();
|
||||||
});
|
});
|
||||||
btnsElement[1].addEventListener("click", () => {
|
btnsElement[1].addEventListener("click", () => {
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import {exportLayout} from "../layout/util";
|
||||||
import {showMessage} from "./message";
|
import {showMessage} from "./message";
|
||||||
import {Dialog} from "./index";
|
import {Dialog} from "./index";
|
||||||
import {isMobile} from "../util/functions";
|
import {isMobile} from "../util/functions";
|
||||||
|
import {confirmDialog} from "./confirmDialog";
|
||||||
|
|
||||||
export const lockFile = (id: string) => {
|
export const lockFile = (id: string) => {
|
||||||
const html = `<div class="b3-dialog__scrim"></div>
|
const html = `<div class="b3-dialog__scrim"></div>
|
||||||
|
|
@ -101,18 +102,27 @@ export const exitSiYuan = () => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if (response.code === 2) { // 提示新安装包
|
} else if (response.code === 2) { // 提示新安装包
|
||||||
const msgId = showMessage(response.msg, response.data.closeTimeout, "info");
|
confirmDialog(window.siyuan.languages.tip, response.msg, () => {
|
||||||
const buttonElement = document.querySelector(`#message [data-id="${msgId}"] button`);
|
fetchPost("/api/system/exit", {
|
||||||
if (buttonElement) {
|
force: true,
|
||||||
buttonElement.addEventListener("click", () => {
|
execInstallPkg: 2 // 0:默认检查新版本,1:不执行新版本安装,2:执行新版本安装
|
||||||
fetchPost("/api/system/exit", {force: true}, () => {
|
}, () => {
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
ipcRenderer.send(Constants.SIYUAN_CONFIG_CLOSETRAY);
|
ipcRenderer.send(Constants.SIYUAN_CONFIG_CLOSETRAY);
|
||||||
ipcRenderer.send(Constants.SIYUAN_QUIT);
|
ipcRenderer.send(Constants.SIYUAN_QUIT);
|
||||||
/// #endif
|
/// #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 { // 正常退出
|
} else { // 正常退出
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
ipcRenderer.send(Constants.SIYUAN_CONFIG_CLOSETRAY);
|
ipcRenderer.send(Constants.SIYUAN_CONFIG_CLOSETRAY);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue