简体   繁体   中英

Get windows username using typescript or javascript

In my angular 4 application I want to get windows username. Is it possible with typescript or java-script ? I am using the Chrome browser.

为了安全起见,我认为无法使用javascript / typescript从浏览器获取Windows OS用户信息。

Have you considered creating your application in Electron ?

Electron is an open source library developed by GitHub for building cross-platform desktop applications with HTML, CSS, and JavaScript. Electron accomplishes this by combining Chromium and Node.js into a single runtime and apps can be packaged for Mac, Windows, and Linux.

Electron does not have the same security restrictions and you can still use Angular 4

If you choose to use Electron you can get userinfo through node.js os module:

The os.userInfo() method returns information about the currently effective user

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM