This commit is contained in:
Vanessa 2023-09-04 10:06:15 +08:00
parent 9333f52edd
commit 225dfbf505
4 changed files with 26 additions and 2 deletions

View file

@ -1024,3 +1024,11 @@ powerMonitor.on("shutdown", () => {
net.fetch(getServer(currentURL.port) + "/api/system/exit", {method: "POST"}); net.fetch(getServer(currentURL.port) + "/api/system/exit", {method: "POST"});
}); });
}); });
powerMonitor.on("lock-screen", () => {
writeLog("system lock-screen");
BrowserWindow.getAllWindows().forEach(item => {
item.webContents.send("siyuan-send_windows", {cmd: "lockscreenByMode"});
});
});

View file

@ -312,7 +312,9 @@ export const about = {
}); });
const lockScreenModeElement = about.element.querySelector("#lockScreenMode") as HTMLInputElement; const lockScreenModeElement = about.element.querySelector("#lockScreenMode") as HTMLInputElement;
lockScreenModeElement.addEventListener("change", () => { lockScreenModeElement.addEventListener("change", () => {
fetchPost("/api/system/setFollowSystemLockScreen", {lockScreenMode: lockScreenModeElement.checked ? 1 : 0}); fetchPost("/api/system/setFollowSystemLockScreen", {lockScreenMode: lockScreenModeElement.checked ? 1 : 0}, () => {
window.siyuan.config.system.lockScreenMode = lockScreenModeElement.checked ? 1 : 0;
});
}); });
const googleAnalyticsElement = about.element.querySelector("#googleAnalytics") as HTMLInputElement; const googleAnalyticsElement = about.element.querySelector("#googleAnalytics") as HTMLInputElement;
googleAnalyticsElement.addEventListener("change", () => { googleAnalyticsElement.addEventListener("change", () => {

View file

@ -32,7 +32,7 @@ export abstract class Constants {
public static readonly SIYUAN_INIT: string = "siyuan-init"; public static readonly SIYUAN_INIT: string = "siyuan-init";
public static readonly SIYUAN_OPENURL: string = "siyuan-openurl"; public static readonly SIYUAN_OPENURL: string = "siyuan-openurl";
public static readonly SIYUAN_OPENWINDOW: string = "siyuan-openwindow"; public static readonly SIYUAN_OPENWINDOW: string = "siyuan-openwindow";
public static readonly SIYUAN_SEND_WINDOWS: string = "siyuan-send_windows"; // 主窗口和各新窗口之间的通信,{cmd: "closetab"|"lockscreen", data: {}}) public static readonly SIYUAN_SEND_WINDOWS: string = "siyuan-send_windows"; // 主窗口和各新窗口之间的通信,{cmd: "closetab"|"lockscreen"|"lockscreenByMode", data: {}})
public static readonly SIYUAN_SAVE_CLOSE: string = "siyuan-save-close"; public static readonly SIYUAN_SAVE_CLOSE: string = "siyuan-save-close";
public static readonly SIYUAN_EXPORT_PDF: string = "siyuan-export-pdf"; public static readonly SIYUAN_EXPORT_PDF: string = "siyuan-export-pdf";
public static readonly SIYUAN_EXPORT_CLOSE: string = "siyuan-export-close"; public static readonly SIYUAN_EXPORT_CLOSE: string = "siyuan-export-close";

View file

@ -26,5 +26,19 @@ export const onWindowsMsg = (ipcData: IWebSocketData) => {
} }
}); });
break; break;
case "lockscreenByMode":
if (window.siyuan.config.system.lockScreenMode === 1) {
exportLayout({
reload: false,
onlyData: false,
errorExit: false,
cb() {
fetchPost("/api/system/logoutAuth", {}, () => {
redirectToCheckAuth();
});
}
});
}
break;
} }
}; };