Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:recycle: 内核退出

Vanessa73263ca12870
diff --git a/app/src/config/about.ts b/app/src/config/about.ts
index 165692734c..a4a68058c6 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 2e6fbe86fa..fcfd6b24e3 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 39dc0470c6..3ca126f39c 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 56f31f1868..c4e547aba5 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 6b3dab8d87..4715bcac31 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 191d476f94..b132f2f158 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;
}