mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-07-03 14:09:06 +02:00
🎨 Improve kernel disconnection error messages
Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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} <small>v${Constants.SIYUAN_VERSION}</small>`;
|
||||
let body = `<div>${window.siyuan.languages.kernelFault1}</div>
|
||||
<div class="fn__hr"></div>
|
||||
<div>${window.siyuan.languages.kernelFault3}</div>
|
||||
<div>${isKernelInContainer() ? window.siyuan.languages.kernelFault4 : window.siyuan.languages.kernelFault5}</div>
|
||||
<div class="fn__hr"></div>
|
||||
<div>${window.siyuan.languages.kernelFault2}</div>
|
||||
<div class="b3-dialog__action">
|
||||
let body = `<div style="line-height:1.7;margin-bottom:16px">${window.siyuan.languages.kernelFault1}</div>
|
||||
<div style="font-size:15px;font-weight:600;margin-bottom:8px">${window.siyuan.languages.kernelFault3}</div>
|
||||
<div class="b3-typography" style="font-size:14px;padding:12px 16px;margin-bottom:16px;background-color:var(--b3-theme-surface);border-radius:var(--b3-border-radius-b)">${isKernelInContainer() ? window.siyuan.languages.kernelFault4 : window.siyuan.languages.kernelFault5}</div>
|
||||
<div style="line-height:1.7;margin-bottom:24px">${window.siyuan.languages.kernelFault2}</div>
|
||||
<div class="b3-dialog__action" style="border-top:none;padding:0">
|
||||
<div class="fn__flex-1"></div>
|
||||
<button class="b3-button">${window.siyuan.languages.kernelFault6}</button>
|
||||
</div>`;
|
||||
@@ -25,8 +24,8 @@ export const kernelError = () => {
|
||||
const dialog = new Dialog({
|
||||
disableClose: true,
|
||||
title: title,
|
||||
width: isMobile() ? "92vw" : "520px",
|
||||
content: `<div class="b3-dialog__content">
|
||||
width: isMobile() ? "92vw" : "560px",
|
||||
content: `<div class="b3-dialog__content" style="padding:24px">
|
||||
<div class="ft__breakword">
|
||||
${body}
|
||||
</div>
|
||||
@@ -43,7 +42,7 @@ export const kernelError = () => {
|
||||
} else {
|
||||
btnsElement[0].addEventListener("click", () => {
|
||||
dialog.destroy();
|
||||
window.location.reload();
|
||||
forceQuit();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user