Jor*_*eer 3 javascript node.js electron
我真的知道如何在 Electron 应用程序中输出用户名。所以像这样:
const os = require('os')
const username = // the code or the username so that it can be displayed
document.write("The username is: " + username)
Run Code Online (Sandbox Code Playgroud)
那可能吗?
小智 6
开箱即用,用户名可通过以下方式获得:
const os = require ('os');
const username = os.userInfo ().username;
Run Code Online (Sandbox Code Playgroud)
此外(至少在 Mac OS X 和 Linux 上)它可以通过 LOGNAME 或 USER 环境变量获得:
username = process.env["LOGNAME"];
// or
username = process.env["USER"];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3299 次 |
| 最近记录: |