os模块在electron中的使用兼ip地址获取

os模块在electron中的使用兼IP地址获取

直接看代码吧

const os = window.require("os");
let interfaces = os.networkInterfaces()
var ips = [];
//console.log(interfaces)
for (let key in interfaces) {
//console.log(interfaces[key]);
interfaces[key].forEach(element => {
    if(element.family == "IPv4" && element.mac != "00:00:00:00:00:00"){
        console.log(element);
        ips.push(element);
        }
    });
}

注意,这里就要说一下,引入os,即不是import,也不是require,就是window.require。

posted @   陆敏技  阅读(874)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· SQL Server 2025 AI相关能力初探
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
历史上的今天:
2017-06-06 简单实用UML关系图解
2017-06-06 从零开始理解JAVA事件处理机制(2)
2011-06-06 使用MVVM模式开发自定义UserControl
2011-06-06 让WPF和SL控件同时支持绑定和赋值
Web Counter
Coupon for Contacts
点击右上角即可分享
微信分享提示