diff --git a/app/src/dialog/processSystem.ts b/app/src/dialog/processSystem.ts index b52ad5e33..abcb991f1 100644 --- a/app/src/dialog/processSystem.ts +++ b/app/src/dialog/processSystem.ts @@ -127,6 +127,28 @@ export const lockScreen = async (app: App) => { }; +// forceQuit 用于内核已断连、无法走 /api/system/exit 的场景:绕过内核 HTTP,直接通知宿主(Electron 主进程 / +// 移动端原生容器)退出。浏览器/Docker 等纯 Web 环境无宿主可调,只能关闭当前页。 +export const forceQuit = () => { + /// #if !BROWSER + ipcRenderer.send(Constants.SIYUAN_QUIT, location.port); + /// #else + if (isInAndroid()) { + window.JSAndroid.exit(); + return; + } + if (isInIOS()) { + window.webkit.messageHandlers.exit.postMessage(""); + return; + } + if (isInHarmony()) { + window.JSHarmony.exit(); + return; + } + window.close(); + /// #endif +}; + export const exitSiYuan = async (setCurrentWorkspace = true) => { hideAllElements(["util"]); /// #if MOBILE diff --git a/app/src/util/kernelFault.ts b/app/src/util/kernelFault.ts index b6f36fdb0..99042bec5 100644 --- a/app/src/util/kernelFault.ts +++ b/app/src/util/kernelFault.ts @@ -1,5 +1,6 @@ import {Constants} from "../constants"; import {Dialog} from "../dialog"; +import {forceQuit} from "../dialog/processSystem"; import {isKernelInContainer, isMobile} from "./functions"; import {isInIOS} from "../protyle/util/compatibility"; @@ -8,13 +9,11 @@ export const kernelError = () => { return; } let title = `💔 ${window.siyuan.languages.kernelFault0} v${Constants.SIYUAN_VERSION}`; - let body = `
${window.siyuan.languages.kernelFault1}
-
-
${window.siyuan.languages.kernelFault3}
-
${isKernelInContainer() ? window.siyuan.languages.kernelFault4 : window.siyuan.languages.kernelFault5}
-
-
${window.siyuan.languages.kernelFault2}
-
+ let body = `
${window.siyuan.languages.kernelFault1}
+
${window.siyuan.languages.kernelFault3}
+
${isKernelInContainer() ? window.siyuan.languages.kernelFault4 : window.siyuan.languages.kernelFault5}
+
${window.siyuan.languages.kernelFault2}
+
`; @@ -25,8 +24,8 @@ export const kernelError = () => { const dialog = new Dialog({ disableClose: true, title: title, - width: isMobile() ? "92vw" : "520px", - content: `
+ width: isMobile() ? "92vw" : "560px", + content: `
${body}
@@ -43,7 +42,7 @@ export const kernelError = () => { } else { btnsElement[0].addEventListener("click", () => { dialog.destroy(); - window.location.reload(); + forceQuit(); }); } };