diff --git a/app/src/layout/Model.ts b/app/src/layout/Model.ts index 4ed999427..9050f3507 100644 --- a/app/src/layout/Model.ts +++ b/app/src/layout/Model.ts @@ -1,10 +1,9 @@ import {Constants} from "../constants"; /// #if !MOBILE import {Tab} from "./Tab"; -import {exportLayout} from "./util"; /// #endif import {processMessage} from "../util/processMessage"; -import {kernelError} from "../dialog/processSystem"; +import {kernelError, reloadSync} from "../dialog/processSystem"; export class Model { public ws: WebSocket; @@ -17,13 +16,23 @@ export class Model { /// #endif - constructor(options: { id: string, type?: TWS, callback?: () => void, msgCallback?: (data: IWebSocketData) => void }) { + constructor(options: { + id: string, + type?: TWS, + callback?: () => void, + msgCallback?: (data: IWebSocketData) => void + }) { if (options.msgCallback) { this.connect(options); } } - private connect(options: { id: string, type?: TWS, callback?: () => void, msgCallback?: (data: IWebSocketData) => void }) { + private connect(options: { + id: string, + type?: TWS, + callback?: () => void, + msgCallback?: (data: IWebSocketData) => void + }) { const websocketURL = `${window.location.protocol === "https:" ? "wss" : "ws"}://${window.location.host}/ws`; const ws = new WebSocket(`${websocketURL}?app=${Constants.SIYUAN_APPID}&id=${options.id}${options.type ? "&type=" + options.type : ""}`); ws.onopen = () => { @@ -33,11 +42,13 @@ export class Model { const logElement = document.getElementById("errorLog"); if (logElement) { // 内核中断后无法 catch fetch 请求错误,重连会导致无法执行 transactionsTimeout - /// #if MOBILE - window.location.reload(); - /// #else - exportLayout(true); - /// #endif + reloadSync({upsertRootIDs: [], removeRootIDs: []}); + window.siyuan.dialogs.find(item =>{ + if (item.element.id === "errorLog") { + item.destroy(); + return true; + } + }); } }; ws.onmessage = (event) => {