Vanessa 2023-01-12 15:53:57 +08:00
parent df89ad3cbf
commit db6932c157
6 changed files with 26 additions and 15 deletions

View file

@ -779,6 +779,14 @@ app.whenReady().then(() => {
}) })
}) })
ipcMain.on('siyuan-lock-screen', () => {
workspaces.forEach(item => {
const currentURL = new URL(item.browserWindow.getURL())
const server = getServer(currentURL.port)
fetch(server + '/api/system/logoutAuth', {method: 'POST'})
})
})
if (firstOpen) { if (firstOpen) {
const firstOpenWindow = new BrowserWindow({ const firstOpenWindow = new BrowserWindow({
width: screen.getPrimaryDisplay().size.width / 2, width: screen.getPrimaryDisplay().size.width / 2,

View file

@ -21,6 +21,7 @@ export abstract class Constants {
// 渲染进程调主进程 // 渲染进程调主进程
public static readonly SIYUAN_SHOW: string = "siyuan-show"; public static readonly SIYUAN_SHOW: string = "siyuan-show";
public static readonly SIYUAN_LOCK_SCREEN: string = "siyuan-lock-screen";
public static readonly SIYUAN_CONFIG_TRAY: string = "siyuan-config-tray"; public static readonly SIYUAN_CONFIG_TRAY: string = "siyuan-config-tray";
public static readonly SIYUAN_OPEN_WORKSPACE: string = "siyuan-open-workspace"; public static readonly SIYUAN_OPEN_WORKSPACE: string = "siyuan-open-workspace";
public static readonly SIYUAN_QUIT: string = "siyuan-quit"; public static readonly SIYUAN_QUIT: string = "siyuan-quit";

View file

@ -12,6 +12,16 @@ import {confirmDialog} from "./confirmDialog";
import {getCurrentWindow} from "@electron/remote"; import {getCurrentWindow} from "@electron/remote";
import {getWorkspaceName} from "../menus/workspace"; import {getWorkspaceName} from "../menus/workspace";
export const lockScreen = () => {
/// #if BROWSER
fetchPost("/api/system/logoutAuth", {}, () => {
window.location.href = "/";
});
/// #else
ipcRenderer.send(Constants.SIYUAN_LOCK_SCREEN);
/// #endif
}
export const lockFile = (id: string) => { export const lockFile = (id: string) => {
const html = `<div class="b3-dialog__scrim"></div> const html = `<div class="b3-dialog__scrim"></div>
<div class="b3-dialog__container"> <div class="b3-dialog__container">

View file

@ -10,6 +10,7 @@ import {getCurrentWindow} from "@electron/remote";
/// #endif /// #endif
/// #endif /// #endif
import {isBrowser} from "../util/functions"; import {isBrowser} from "../util/functions";
import {lockScreen} from "../dialog/processSystem";
export const initStatus = () => { export const initStatus = () => {
/// #if !MOBILE /// #if !MOBILE
@ -83,11 +84,7 @@ export const initStatus = () => {
event.stopPropagation(); event.stopPropagation();
break; break;
} else if (target.id === "barLock") { } else if (target.id === "barLock") {
exportLayout(false, () => { lockScreen()
fetchPost("/api/system/logoutAuth", {}, () => {
window.location.href = "/";
});
});
event.stopPropagation(); event.stopPropagation();
break; break;
} else if (target.id === "barHelp") { } else if (target.id === "barHelp") {

View file

@ -9,7 +9,7 @@ import {mountHelp, newDailyNote, newNotebook} from "../../util/mount";
import {repos} from "../../config/repos"; import {repos} from "../../config/repos";
import * as md5 from "blueimp-md5"; import * as md5 from "blueimp-md5";
import {showMessage} from "../../dialog/message"; import {showMessage} from "../../dialog/message";
import {exitSiYuan} from "../../dialog/processSystem"; import {exitSiYuan, lockScreen} from "../../dialog/processSystem";
import {confirmDialog} from "../../dialog/confirmDialog"; import {confirmDialog} from "../../dialog/confirmDialog";
import {openHistory} from "../../history/history"; import {openHistory} from "../../history/history";
import {Dialog} from "../../dialog"; import {Dialog} from "../../dialog";
@ -535,9 +535,7 @@ ${accountHTML}
event.stopPropagation(); event.stopPropagation();
break; break;
} else if (target.id === "menuLock") { } else if (target.id === "menuLock") {
fetchPost("/api/system/logoutAuth", {}, () => { lockScreen();
window.location.href = "/";
});
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
break; break;

View file

@ -47,6 +47,7 @@ import {webFrame} from "electron";
/// #endif /// #endif
import {openHistory} from "../history/history"; import {openHistory} from "../history/history";
import {openCard} from "../card/openCard"; import {openCard} from "../card/openCard";
import {lockScreen} from "../dialog/processSystem";
const getRightBlock = (element: HTMLElement, x: number, y: number) => { const getRightBlock = (element: HTMLElement, x: number, y: number) => {
let index = 1; let index = 1;
@ -534,11 +535,7 @@ export const globalShortcut = () => {
return; return;
} }
if (matchHotKey(window.siyuan.config.keymap.general.lockScreen.custom, event)) { if (matchHotKey(window.siyuan.config.keymap.general.lockScreen.custom, event)) {
exportLayout(false, () => { lockScreen()
fetchPost("/api/system/logoutAuth", {}, () => {
window.location.href = "/";
});
});
event.preventDefault(); event.preventDefault();
return; return;
} }