♻️ 内核退出

This commit is contained in:
Vanessa 2023-03-17 23:25:01 +08:00
parent 91786010d3
commit 73263ca128
6 changed files with 11 additions and 8 deletions

View file

@ -310,7 +310,7 @@ export const about = {
fetchPost("/api/system/setNetworkServe", {networkServe: networkServeElement.checked}, () => {
exportLayout(false, () => {
exitSiYuan();
});
}, false, true);
});
});
const googleAnalyticsElement = about.element.querySelector("#googleAnalytics") as HTMLInputElement;
@ -324,7 +324,7 @@ export const about = {
fetchPost("/api/system/setUploadErrLog", {uploadErrLog: uploadErrLogElement.checked}, () => {
exportLayout(false, () => {
exitSiYuan();
});
}, false, true);
});
});
const downloadInstallPkgElement = about.element.querySelector("#downloadInstallPkg") as HTMLInputElement;

View file

@ -187,7 +187,7 @@ export const transactionError = (data: { code: number, data: string }) => {
/// #else
exportLayout(false, () => {
exitSiYuan();
});
}, false, true);
/// #endif
});
btnsElement[1].addEventListener("click", () => {

View file

@ -145,7 +145,7 @@ export const resetLayout = () => {
});
};
export const exportLayout = (reload: boolean, cb?: () => void, onlyData = false) => {
export const exportLayout = (reload: boolean, cb?: () => void, onlyData = false, errorExit = false) => {
const useElement = document.querySelector("#barDock use");
if (!useElement) {
return;
@ -161,7 +161,10 @@ export const exportLayout = (reload: boolean, cb?: () => void, onlyData = false)
if (onlyData) {
return layoutJSON;
}
fetchPost("/api/system/setUILayout", {layout: layoutJSON}, () => {
fetchPost("/api/system/setUILayout", {
layout: layoutJSON,
errorExit // 后台不接受该参数,用于请求发生错误时退出程序
}, () => {
if (reload) {
window.location.reload();
} else if (cb) {

View file

@ -47,7 +47,7 @@ export const fetchPost = (url: string, data?: any, cb?: (response: IWebSocketDat
}
/// #if !BROWSER
if (url === "/api/system/exit" || url === "/api/system/setWorkspaceDir" || (
["/api/system/setUILayout"].includes(url) && data.exit // 内核中断,点关闭处理
["/api/system/setUILayout"].includes(url) && data.errorExit // 内核中断,点关闭处理
)) {
ipcRenderer.send(Constants.SIYUAN_QUIT, getCurrentWindow().id);
}

View file

@ -209,7 +209,7 @@ const winOnClose = (currentWindow: Electron.BrowserWindow, close = false) => {
} else {
exitSiYuan();
}
});
}, false, true);
/// #endif
};

View file

@ -22,7 +22,7 @@ export const onWindowsMsg = (ipcData: IWebSocketData) => {
fetchPost("/api/system/logoutAuth", {}, () => {
window.location.href = `/check-auth?url=${window.location.href}`;
});
});
}, false, false);
}
break;
}