diff --git a/app/src/config/about.ts b/app/src/config/about.ts index 165692734..a4a68058c 100644 --- a/app/src/config/about.ts +++ b/app/src/config/about.ts @@ -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; diff --git a/app/src/dialog/processSystem.ts b/app/src/dialog/processSystem.ts index 2e6fbe86f..fcfd6b24e 100644 --- a/app/src/dialog/processSystem.ts +++ b/app/src/dialog/processSystem.ts @@ -187,7 +187,7 @@ export const transactionError = (data: { code: number, data: string }) => { /// #else exportLayout(false, () => { exitSiYuan(); - }); + }, false, true); /// #endif }); btnsElement[1].addEventListener("click", () => { diff --git a/app/src/layout/util.ts b/app/src/layout/util.ts index 39dc0470c..3ca126f39 100644 --- a/app/src/layout/util.ts +++ b/app/src/layout/util.ts @@ -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) { diff --git a/app/src/util/fetch.ts b/app/src/util/fetch.ts index 56f31f186..c4e547aba 100644 --- a/app/src/util/fetch.ts +++ b/app/src/util/fetch.ts @@ -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); } diff --git a/app/src/util/onGetConfig.ts b/app/src/util/onGetConfig.ts index 6b3dab8d8..4715bcac3 100644 --- a/app/src/util/onGetConfig.ts +++ b/app/src/util/onGetConfig.ts @@ -209,7 +209,7 @@ const winOnClose = (currentWindow: Electron.BrowserWindow, close = false) => { } else { exitSiYuan(); } - }); + }, false, true); /// #endif }; diff --git a/app/src/window/onWindowsMsg.ts b/app/src/window/onWindowsMsg.ts index 191d476f9..b132f2f15 100644 --- a/app/src/window/onWindowsMsg.ts +++ b/app/src/window/onWindowsMsg.ts @@ -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; }