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

# getWindowInfoSync

获取窗口信息。

## 扫码预览

![扫码预览 getWindowInfoSync](https://api.qrserver.com/v1/create-qr-code/?size=200x200\&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fbasic%252Fget-window-info%252Findex)

## 支持版本

前端库版本不低于 `0.0.18`。

## 支持平台

<table>
<thead>
<tr><th>平台</th><th>支持情况</th></tr>
</thead>
<tbody>
<tr><td>Android</td><td>支持</td></tr>
<tr><td>iOS</td><td>支持</td></tr>
<tr><td>PC</td><td>不支持</td></tr>
<tr><td>HarmonyOS</td><td>不支持</td></tr>
</tbody>
</table>

## 支持场景

<table>
<thead>
<tr><th>场景</th><th>支持情况</th></tr>
</thead>
<tbody>
<tr><td>页面</td><td>支持</td></tr>
<tr><td>卡片</td><td>不支持</td></tr>
</tbody>
</table>

## 调用方式

### 同步 API

```typescript
getWindowInfoSync(_params?: object): GetWindowInfoResult
```

## 入参

无。

## 调用示例

```typescript
import { getWindowInfoSync } from '@doubao-dev/framework/api';

const result = getWindowInfoSync();

console.log(result.windowWidth, result.windowHeight);
console.log(result.safeArea?.top, result.screenTop);
```

## 返回值

<table>
<thead>
<tr><th>名称</th><th>类型</th><th>必返</th><th>说明</th></tr>
</thead>
<tbody>
<tr><td><code>pixelRatio</code></td><td><code>number</code></td><td>是</td><td>设备像素比</td></tr>
<tr><td><code>safeArea</code></td><td><code>WindowSafeArea</code></td><td>否</td><td>安全区域</td></tr>
<tr><td><code>safeArea.bottom</code></td><td><code>number</code></td><td>否</td><td>安全区域右下角纵坐标</td></tr>
<tr><td><code>safeArea.height</code></td><td><code>number</code></td><td>否</td><td>安全区域高度</td></tr>
<tr><td><code>safeArea.left</code></td><td><code>number</code></td><td>否</td><td>安全区域左上角横坐标</td></tr>
<tr><td><code>safeArea.right</code></td><td><code>number</code></td><td>否</td><td>安全区域右下角横坐标</td></tr>
<tr><td><code>safeArea.top</code></td><td><code>number</code></td><td>否</td><td>安全区域左上角纵坐标</td></tr>
<tr><td><code>safeArea.width</code></td><td><code>number</code></td><td>否</td><td>安全区域宽度</td></tr>
<tr><td><code>screenHeight</code></td><td><code>number</code></td><td>是</td><td>屏幕高度</td></tr>
<tr><td><code>screenTop</code></td><td><code>number</code></td><td>是</td><td>窗口上边缘的 y 值</td></tr>
<tr><td><code>screenWidth</code></td><td><code>number</code></td><td>是</td><td>屏幕宽度</td></tr>
<tr><td><code>statusBarHeight</code></td><td><code>number</code></td><td>是</td><td>状态栏高度</td></tr>
<tr><td><code>windowHeight</code></td><td><code>number</code></td><td>是</td><td>可使用窗口高度</td></tr>
<tr><td><code>windowWidth</code></td><td><code>number</code></td><td>是</td><td>可使用窗口宽度</td></tr>
</tbody>
</table>

### 返回示例

```json
{
  "pixelRatio": 3,
  "screenWidth": 393,
  "screenHeight": 852,
  "windowWidth": 393,
  "windowHeight": 852,
  "statusBarHeight": 59,
  "safeArea": {
    "left": 0,
    "right": 393,
    "top": 59,
    "bottom": 818,
    "width": 393,
    "height": 759
  },
  "screenTop": 0
}
```
