> For AI agents: the complete documentation index is available at /next/zh/llms.txt, the full documentation bundle is available at /next/zh/llms-full.txt.

# SystemInfo

APISummary
`SystemInfo` 是一个普通的 JavaScript 对象，其中含有当前系统和设备的相关信息。

## 语法

```ts
declare const SystemInfo: {
  /**
   * The version of the Lynx Engine.
   *
   * @example '3.2'
   */
  readonly engineVersion: string;

  /**
   * The version of the Lynx Engine.
   * @example '3.2'
   * @deprecated Use `SystemInfo.engineVersion` instead
   */
  readonly lynxSdkVersion: string;

  /**
   * The current operating system version.
   */
  readonly osVersion: string;

  /**
   * The physical pixel height of the real device.
   */
  readonly pixelHeight: number;

  /**
   * The physical pixel width of the real device.
   */
  readonly pixelWidth: number;

  /**
   * The physical pixel ratio of the main screen.
   */
  readonly pixelRatio: number;

  /**
   * The platform of the current device.
   */
  readonly platform: 'Android' | 'iOS' | 'macOS' | 'windows' | 'headless';

  /**
   * The JavaScript engine currently used.
   * @note Not available in lepus
   */
  readonly runtimeType: 'v8' | 'jsc' | 'quickjs';
};
```

### 属性

#### engineVersion

当前 Lynx Engine 版本号，格式为 `major.minor`。

例如：`3.2`。

#### ~~lynxSdkVersion~~

当前 Lynx Engine 版本号，格式为 `major.minor`。

例如：`3.2`。

#### osVersion

当前操作系统版本。

**iOS**

> [systemVersion | Apple Developer Documentation](https://developer.apple.com/documentation/uikit/uidevice/1620043-systemversion?language=objc)

```objc
[[UIDevice currentDevice].systemVersion UTF8String]
```

**Android**

等于 [`Build.VERSION.SDK_INT`](https://developer.android.com/reference/android/os/Build.VERSION#SDK_INT)。

> [API Levels | Android NDK | Android Developers](https://developer.android.com/ndk/reference/group/apilevels#android_get_device_api_level)

```cpp
std::to_string(android_get_device_api_level())
```

#### pixelHeight

当前设备屏幕的绝对高度，以物理像素为单位。

**iOS**

> [UIScreen | Apple Developer Documentation](https://developer.apple.com/documentation/uikit/uiscreen?language=objc)

```objc
CGSize screenSize;
if (!CGSizeEqualToSize(builder.screenSize, CGSizeZero)) {
  screenSize = builder.screenSize;
} else {
  screenSize = [UIScreen mainScreen].bounds.size;
}
const CGFloat scale = [UIScreen mainScreen].scale;
// highlight-next-line
const CGFloat pixelHeight = screenSize.height * scale;
```

**Android**

> [DisplayMetrics | Android Developers](https://developer.android.com/reference/android/util/DisplayMetrics)

```java
DisplayMetrics dm = context.getResources().getDisplayMetrics();
// highlight-next-line
int pixelHeight = dm.heightPixels;
```

#### pixelWidth

当前设备屏幕的绝对宽度，以物理像素为单位。

**iOS**

> [UIScreen | Apple Developer Documentation](https://developer.apple.com/documentation/uikit/uiscreen?language=objc)

```objc
CGSize screenSize;
if (!CGSizeEqualToSize(builder.screenSize, CGSizeZero)) {
  screenSize = builder.screenSize;
} else {
  screenSize = [UIScreen mainScreen].bounds.size;
}
const CGFloat scale = [UIScreen mainScreen].scale;
// highlight-next-line
const CGFloat pixelWidth = screenSize.width * scale;

```

**Android**

> [DisplayMetrics | Android Developers](https://developer.android.com/reference/android/util/DisplayMetrics)

```java
DisplayMetrics dm = context.getResources().getDisplayMetrics();
// highlight-next-line
int pixelWidth = dm.widthPixels;
```

#### pixelRatio

当前设备的像素比例。

**iOS**

> [UIScreen | Apple Developer Documentation](https://developer.apple.com/documentation/uikit/uiscreen?language=objc)

```objc
const CGFloat pixelRatio = [UIScreen mainScreen].scale;
```

**Android**

> [DisplayMetrics | Android Developers](https://developer.android.com/reference/android/util/DisplayMetrics#density)

```java
DisplayMetrics dm = context.getResources().getDisplayMetrics();
// highlight-next-line
float pixelRatio = dm.density;
```

#### platform

当前设备对应的平台。

可能的值：

1. `iOS`
2. `Android`
3. `macOS`
4. `windows`

#### runtimeType

目前使用的 JavaScript 引擎。

:::info
该值只能在后台线程获得，在主线程为 `undefined`。
:::

可能的值：

1. `quickjs`
2. `jsc`
3. `v8`

更对细节内容见 [JavaScript 环境](/next/zh/guide/scripting-runtime/index.md)。

## 兼容性

**Compatibility Table**

**Query:** `lynx-api.global.SystemInfo`

[Source](https://github.com/lynx-family/lynx-website/tree/main/packages/lynx-compat-data/lynx-api/global/SystemInfo.json)

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| SystemInfo | Yes (1.3) | Yes (3.4) | Yes (1.3) | Yes (3.5) | Yes (3.5) | Yes |
| SystemInfo.engineVersion | Yes (3.2) | Yes (3.4) | Yes (3.2) | Yes (3.5) | Yes (3.5) | No |
| SystemInfo.lynxSdkVersion | Yes (2.4) | Yes (3.4) | Yes (2.4) | Yes (3.5) | Yes (3.5) | Yes |

**`SystemInfo`**

Information of the current system

**Specifications:**

**`SystemInfo.engineVersion`**

**Specifications:**

**`SystemInfo.lynxSdkVersion`**

**Status:** Deprecated

**Specifications:**

- **Web — Supported (version unknown):** Implemented since `@lynx-js/web-core@0.13.0` (lynx-family/lynx-stack#628).

