This commit is contained in:
parent
df89ad3cbf
commit
db6932c157
6 changed files with 26 additions and 15 deletions
|
@ -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) {
|
||||
const firstOpenWindow = new BrowserWindow({
|
||||
width: screen.getPrimaryDisplay().size.width / 2,
|
||||
|
|
|
@ -21,6 +21,7 @@ export abstract class Constants {
|
|||
|
||||
// 渲染进程调主进程
|
||||
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_OPEN_WORKSPACE: string = "siyuan-open-workspace";
|
||||
public static readonly SIYUAN_QUIT: string = "siyuan-quit";
|
||||
|
|
|
@ -10,7 +10,17 @@ import {Dialog} from "./index";
|
|||
import {isMobile} from "../util/functions";
|
||||
import {confirmDialog} from "./confirmDialog";
|
||||
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) => {
|
||||
const html = `<div class="b3-dialog__scrim"></div>
|
||||
|
|
|
@ -10,6 +10,7 @@ import {getCurrentWindow} from "@electron/remote";
|
|||
/// #endif
|
||||
/// #endif
|
||||
import {isBrowser} from "../util/functions";
|
||||
import {lockScreen} from "../dialog/processSystem";
|
||||
|
||||
export const initStatus = () => {
|
||||
/// #if !MOBILE
|
||||
|
@ -83,11 +84,7 @@ export const initStatus = () => {
|
|||
event.stopPropagation();
|
||||
break;
|
||||
} else if (target.id === "barLock") {
|
||||
exportLayout(false, () => {
|
||||
fetchPost("/api/system/logoutAuth", {}, () => {
|
||||
window.location.href = "/";
|
||||
});
|
||||
});
|
||||
lockScreen()
|
||||
event.stopPropagation();
|
||||
break;
|
||||
} else if (target.id === "barHelp") {
|
||||
|
|
|
@ -9,7 +9,7 @@ import {mountHelp, newDailyNote, newNotebook} from "../../util/mount";
|
|||
import {repos} from "../../config/repos";
|
||||
import * as md5 from "blueimp-md5";
|
||||
import {showMessage} from "../../dialog/message";
|
||||
import {exitSiYuan} from "../../dialog/processSystem";
|
||||
import {exitSiYuan, lockScreen} from "../../dialog/processSystem";
|
||||
import {confirmDialog} from "../../dialog/confirmDialog";
|
||||
import {openHistory} from "../../history/history";
|
||||
import {Dialog} from "../../dialog";
|
||||
|
@ -535,9 +535,7 @@ ${accountHTML}
|
|||
event.stopPropagation();
|
||||
break;
|
||||
} else if (target.id === "menuLock") {
|
||||
fetchPost("/api/system/logoutAuth", {}, () => {
|
||||
window.location.href = "/";
|
||||
});
|
||||
lockScreen();
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
break;
|
||||
|
|
|
@ -47,6 +47,7 @@ import {webFrame} from "electron";
|
|||
/// #endif
|
||||
import {openHistory} from "../history/history";
|
||||
import {openCard} from "../card/openCard";
|
||||
import {lockScreen} from "../dialog/processSystem";
|
||||
|
||||
const getRightBlock = (element: HTMLElement, x: number, y: number) => {
|
||||
let index = 1;
|
||||
|
@ -534,11 +535,7 @@ export const globalShortcut = () => {
|
|||
return;
|
||||
}
|
||||
if (matchHotKey(window.siyuan.config.keymap.general.lockScreen.custom, event)) {
|
||||
exportLayout(false, () => {
|
||||
fetchPost("/api/system/logoutAuth", {}, () => {
|
||||
window.location.href = "/";
|
||||
});
|
||||
});
|
||||
lockScreen()
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue