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, and this page is available as Markdown at /apps-plugin/docs/js-api/basic/system/getWindowInfo.md.

getWindowInfo

获取窗口信息。

扫码预览

扫码预览 getWindowInfo

支持版本

前端库版本不低于 0.0.18。

支持平台

平台支持情况
Android支持
iOS支持
PC不支持
HarmonyOS不支持

支持场景

场景支持情况
页面支持
卡片不支持

使用说明

  • 该接口封装 getWindowInfoSync 的结果;无需 Promise 形式时可直接使用 getWindowInfoSync。

调用方式

异步 API

getWindowInfo(_params?: object): Promise<GetWindowInfoResult>

入参

无。

调用示例

import { getWindowInfo } from '@doubao-dev/framework/api';

const result = await getWindowInfo();

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

成功返回

名称类型必返说明
pixelRationumber是设备像素比
safeAreaWindowSafeArea否安全区域
safeArea.bottomnumber否安全区域右下角纵坐标
safeArea.heightnumber否安全区域高度
safeArea.leftnumber否安全区域左上角横坐标
safeArea.rightnumber否安全区域右下角横坐标
safeArea.topnumber否安全区域左上角纵坐标
safeArea.widthnumber否安全区域宽度
screenHeightnumber是屏幕高度
screenTopnumber是窗口上边缘的 y 值
screenWidthnumber是屏幕宽度
statusBarHeightnumber是状态栏高度
windowHeightnumber是可使用窗口高度
windowWidthnumber是可使用窗口宽度

返回示例

{
  "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
}