System API
System API
查询设备及系统信息。
getSystemInfoSync()
同步查询完整系统信息。
返回值:
| 字段 | 类型 | 说明 |
|---|---|---|
platform | string | 平台 ('ios' | 'android') |
brand | string | 设备品牌 |
model | string | 设备型号 |
system | string | 操作系统及版本 |
pixelRatio | number | 设备像素比 |
screenWidth | number | 屏幕宽度 (px) |
screenHeight | number | 屏幕高度 (px) |
windowWidth | number | 可用窗口宽度 (px) |
windowHeight | number | 可用窗口高度 (px) |
safeArea | SafeArea | 安全区域信息 |
language | string | 语言设置 |
theme | string | 主题 ('light' | 'dark') |
deviceOrientation | string | 屏幕方向 ('portrait' | 'landscape') |
SDKVersion | string | SDK 版本 |
version | string | 服务版本 |
environment | string | 访问环境 ('prod' | 'dev')。可用于资源 CDN 地址切换等 |
benchmarkLevel | number | 性能等级 (Android) |
wifiEnabled | boolean | Wi-Fi 启用状态 |
const info = TudadaSDK.getSystemInfoSync();
console.log('平台:', info.platform);
console.log('屏幕:', info.windowWidth, 'x', info.windowHeight);
console.log('SafeArea:', info.safeArea);
getSystemInfo(options?)
异步查询完整系统信息。
选项:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
success | function | - | 成功回调 |
fail | function | - | 失败回调 |
complete | function | - | 完成回调 |
成功响应:
与 getSystemInfoSync() 的返回值相同。
TudadaSDK.getSystemInfo({
success: (res) => console.log('系统信息:', res),
});
使用提示: 使用
environment字段可以按环境切换资源 CDN 地址。const info = TudadaSDK.getSystemInfoSync();
const cdnBase = info.environment === 'prod'
? 'https://cdn.example.com/prod'
: 'https://cdn.example.com/dev';
getWindowInfo()
同步查询窗口/屏幕尺寸及安全区域信息。
返回值:
| 字段 | 类型 | 说明 |
|---|---|---|
pixelRatio | number | 设备像素比 |
screenWidth | number | 屏幕宽度 (px) |
screenHeight | number | 屏幕高度 (px) |
windowWidth | number | 可用窗口宽度 (px) |
windowHeight | number | 可用窗口高度 (px) |
safeArea | SafeArea | 安全区域信息 |
const windowInfo = TudadaSDK.getWindowInfo();
console.log('SafeArea:', windowInfo.safeArea);
console.log('像素比:', windowInfo.pixelRatio);
getWindowInfoAsync(options?)
异步查询窗口/屏幕尺寸及安全区域信息。
选项:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
success | function | - | 成功回调 |
fail | function | - | 失败回调 |
complete | function | - | 完成回调 |
成功响应:
与 getWindowInfo() 的返回值相同。
SafeArea 结构:
| 字段 | 类型 | 说明 |
|---|---|---|
left | number | 左上角 X 坐标 |
top | number | 左上角 Y 坐标 |
right | number | 右下角 X 坐标 |
bottom | number | 右下角 Y 坐标 |
width | number | 安全区域宽度 |
height | number | 安全区域高度 |
getAppBaseInfo()
同步查询应用/SDK 基本信息。
返回值:
| 字段 | 类型 | 说明 |
|---|---|---|
SDKVersion | string | SDK 版本 |
version | string | 服务版本 |
theme | string | 主题 ('light' | 'dark') |
language | string | 语言设置 |
environment | string | 访问环境 ('prod' | 'dev') |
const appInfo = TudadaSDK.getAppBaseInfo();
console.log('SDK 版本:', appInfo.SDKVersion);
console.log('主题:', appInfo.theme);
console.log('环境:', appInfo.environment); // 'prod' 或 'dev'
getAppBaseInfoAsync(options?)
异步查询应用/SDK 基本信息。
选项:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
success | function | - | 成功回调 |
fail | function | - | 失败回调 |
complete | function | - | 完成回调 |
成功响应:
与 getAppBaseInfo() 的返回值相同。
getDeviceInfo()
同步查询设备硬件信息。
返回值:
| 字段 | 类型 | 说明 |
|---|---|---|
brand | string | 设备品牌 |
model | string | 设备型号 |
system | string | 操作系统及版本 |
platform | string | 平台 ('ios' | 'android') |
benchmarkLevel | number | 性能等级 (Android) |
const deviceInfo = TudadaSDK.getDeviceInfo();
console.log('品牌:', deviceInfo.brand);
console.log('型号:', deviceInfo.model);
console.log('性能等级:', deviceInfo.benchmarkLevel);
getDeviceInfoAsync(options?)
异步查询设备硬件信息。
选项:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
success | function | - | 成功回调 |
fail | function | - | 失败回调 |
complete | function | - | 完成回调 |
成功响应:
与 getDeviceInfo() 的返回值相同。