mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-04 20:00:17 +01:00
This commit is contained in:
parent
b613bf3b34
commit
c089edf65f
4 changed files with 20 additions and 21 deletions
|
|
@ -202,7 +202,7 @@ export const initWindow = async (app: App) => {
|
|||
}
|
||||
});
|
||||
ipcRenderer.on(Constants.SIYUAN_SEND_WINDOWS, (e, ipcData: IWebSocketData) => {
|
||||
onWindowsMsg(ipcData);
|
||||
onWindowsMsg(ipcData, app);
|
||||
});
|
||||
ipcRenderer.on(Constants.SIYUAN_HOTKEY, (e, data) => {
|
||||
let matchCommand = false;
|
||||
|
|
|
|||
|
|
@ -233,14 +233,27 @@ export const setDefRefCount = (data: {
|
|||
}
|
||||
};
|
||||
|
||||
export const lockScreen = (app: App) => {
|
||||
export const lockScreen = async (app: App) => {
|
||||
if (window.siyuan.config.readonly) {
|
||||
return;
|
||||
}
|
||||
app.plugins.forEach(item => {
|
||||
item.eventBus.emit("lock-screen");
|
||||
});
|
||||
fetchPost("/api/system/logoutAuth");
|
||||
/// #if !MOBILE
|
||||
exportLayout({
|
||||
errorExit: false,
|
||||
cb() {
|
||||
fetchPost("/api/system/logoutAuth");
|
||||
}
|
||||
});
|
||||
/// #else
|
||||
if (window.siyuan.mobile.editor) {
|
||||
await saveScroll(window.siyuan.mobile.editor.protyle);
|
||||
fetchPost("/api/system/logoutAuth");
|
||||
}
|
||||
/// #endif
|
||||
|
||||
};
|
||||
|
||||
export const kernelError = () => {
|
||||
|
|
|
|||
|
|
@ -65,25 +65,10 @@ export const getIdFromSYProtocol = (url: string) => {
|
|||
|
||||
/* redirect to auth page */
|
||||
export const redirectToCheckAuth = async (to: string = window.location.href) => {
|
||||
/// #if !MOBILE
|
||||
exportLayout({
|
||||
errorExit: false,
|
||||
cb() {
|
||||
const url = new URL(window.location.origin);
|
||||
url.pathname = "/check-auth";
|
||||
url.searchParams.set("to", to);
|
||||
window.location.href = url.href;
|
||||
}
|
||||
});
|
||||
/// #else
|
||||
if (window.siyuan.mobile.editor) {
|
||||
await saveScroll(window.siyuan.mobile.editor.protyle);
|
||||
}
|
||||
const url = new URL(window.location.origin);
|
||||
url.pathname = "/check-auth";
|
||||
url.searchParams.set("to", to);
|
||||
window.location.href = url.href;
|
||||
/// #endif
|
||||
};
|
||||
|
||||
export const addBaseURL = () => {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import {getInstanceById} from "../layout/util";
|
||||
import {Tab} from "../layout/Tab";
|
||||
import {redirectToCheckAuth} from "../util/pathName";
|
||||
import {isWindow} from "../util/functions";
|
||||
import {lockScreen} from "../dialog/processSystem";
|
||||
import {App} from "../index";
|
||||
|
||||
const closeTab = (ipcData: IWebSocketData) => {
|
||||
const tab = getInstanceById(ipcData.data);
|
||||
|
|
@ -9,7 +10,7 @@ const closeTab = (ipcData: IWebSocketData) => {
|
|||
tab.parent.removeTab(ipcData.data);
|
||||
}
|
||||
};
|
||||
export const onWindowsMsg = (ipcData: IWebSocketData) => {
|
||||
export const onWindowsMsg = (ipcData: IWebSocketData, app: App) => {
|
||||
switch (ipcData.cmd) {
|
||||
case "closetab":
|
||||
closeTab(ipcData);
|
||||
|
|
@ -37,7 +38,7 @@ export const onWindowsMsg = (ipcData: IWebSocketData) => {
|
|||
break;
|
||||
case "lockscreenByMode":
|
||||
if (window.siyuan.config.system.lockScreenMode === 1) {
|
||||
redirectToCheckAuth();
|
||||
lockScreen(app);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue