os-info-sdk-xxy
v1.0.1
Published
A simple SDK to get current operating system information
Readme
OS Info SDK
一个简单易用的操作系统信息获取 SDK,支持跨平台检测。
安装
npm install os-info-sdk基本使用
import { getOSInfo } from 'os-info-sdk';
const osInfo = getOSInfo();
console.log(osInfo);
// 输出示例:
// {
// platform: 'darwin',
// arch: 'arm64',
// release: '22.1.0',
// type: 'Darwin',
// name: 'macOS',
// codename: 'Ventura'
// }平台检测
import { isMacOS, isLinux } from 'os-info-sdk';
if (isMacOS()) {
console.log('运行在 macOS 系统上');
} else if (isLinux()) {
console.log('运行在 Linux 系统上');
}其他功能
import { getArchitecture, getPlatform } from 'os-info-sdk';
console.log(`系统架构: ${getArchitecture()}`);
console.log(`平台: ${getPlatform()}`);API 文档
getOSInfo(): OSInfo 返回包含操作系统详细信息的对象。
isMacOS(): boolean 检查当前是否为 macOS 系统。
isLinux(): boolean 检查当前是否为 Linux 系统。
getArchitecture(): string 返回系统架构(如 'x64', 'arm64')。
getPlatform(): string 返回平台名称(如 'win32', 'darwin', 'linux')。
