Skip to content

Commit

Permalink
🎨 fix #9087
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Sep 4, 2023
1 parent 9333f52 commit 225dfbf
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
8 changes: 8 additions & 0 deletions app/electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1024,3 +1024,11 @@ powerMonitor.on("shutdown", () => {
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"});
});
});
4 changes: 3 additions & 1 deletion app/src/config/about.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,9 @@ export const about = {
});
const lockScreenModeElement = about.element.querySelector("#lockScreenMode") as HTMLInputElement;
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;
googleAnalyticsElement.addEventListener("change", () => {
Expand Down
2 changes: 1 addition & 1 deletion app/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export abstract class Constants {
public static readonly SIYUAN_INIT: string = "siyuan-init";
public static readonly SIYUAN_OPENURL: string = "siyuan-openurl";
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_EXPORT_PDF: string = "siyuan-export-pdf";
public static readonly SIYUAN_EXPORT_CLOSE: string = "siyuan-export-close";
Expand Down
14 changes: 14 additions & 0 deletions app/src/window/onWindowsMsg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,19 @@ export const onWindowsMsg = (ipcData: IWebSocketData) => {
}
});
break;
case "lockscreenByMode":
if (window.siyuan.config.system.lockScreenMode === 1) {
exportLayout({
reload: false,
onlyData: false,
errorExit: false,
cb() {
fetchPost("/api/system/logoutAuth", {}, () => {
redirectToCheckAuth();
});
}
});
}
break;
}
};

0 comments on commit 225dfbf

Please sign in to comment.