From 7e286a65903454310fa18ccd46b41ccbd0e50625 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Wed, 24 Jun 2026 10:38:20 +0800 Subject: [PATCH] :art: Improve kernel disconnection error messages Signed-off-by: Daniel <845765@qq.com> --- app/src/dialog/processSystem.ts | 22 ++++++++++++++++++++++ app/src/util/kernelFault.ts | 19 +++++++++---------- 2 files changed, 31 insertions(+), 10 deletions(-) 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 = `