Electron App:如何 'lock' 一台电脑?

Electron App: How to 'lock' a computer?

我正在构建一个 Electron 应用程序,它需要在完成长时间的任务后锁定用户的 PC(出于安全考虑)。

我找不到实现此目的的方法。

有没有办法将击键 (WinKey + L) 发送到 OS?

在 Windows 你需要调用 LockWorkStation function. You can either write a native Node module to invoke this function, or just execute rundll32.exe user32.dll, LockWorkStation on the command line (which is what the lockpc 包。