根据https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation,navigator.connection
应该具有type
属性。但是,当我在 Electron 应用程序中输出navigator.connection
时,我得到:
{
downlink: 10,
effectiveType: "4g",
onchange: null,
rtt: 0,
saveData: false
}
我需要知道用户是否连接到
ethernet
或wifi
。还有其他方法吗?我安装了 Electron
3.0.4
。
最佳答案
我最终使用节点包来检测网络类型。
const network = require('network');
network.get_active_interface(function(err, obj) {
// obj.type is the network type
// 'Wireless' for wifi
// 'Wired' for ethernet
});
关于electron - Electron 获取互联网连接类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52789124/