From 9ca1f2792da2cf36ac3a8d0f72e5b639e7659a22 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Mon, 27 Feb 2023 11:00:08 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/7500 --- app/src/window/onWindowsMsg.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 app/src/window/onWindowsMsg.ts diff --git a/app/src/window/onWindowsMsg.ts b/app/src/window/onWindowsMsg.ts new file mode 100644 index 000000000..28d940bc8 --- /dev/null +++ b/app/src/window/onWindowsMsg.ts @@ -0,0 +1,29 @@ +import {exportLayout, getInstanceById} from "../layout/util"; +import {Tab} from "../layout/Tab"; +import {fetchPost} from "../util/fetch"; +import {isWindow} from "../util/functions"; + +const closeTab = (ipcData:IWebSocketData) => { + const tab = getInstanceById(ipcData.data); + if (tab && tab instanceof Tab) { + tab.parent.removeTab(ipcData.data); + } +} +export const onWindowsMsg = (ipcData:IWebSocketData) => { + switch (ipcData.cmd) { + case "closetab": + closeTab(ipcData) + break; + case "lockscreen": + if (isWindow()) { + window.location.href = `/check-auth?url=${window.location.href}`; + } else { + exportLayout(false, () => { + fetchPost("/api/system/logoutAuth", {}, () => { + window.location.href = `/check-auth?url=${window.location.href}`; + }); + }); + } + break; + } +}