interface.uts 2.4 KB
Newer Older
DCloud-yyl's avatar
DCloud-yyl 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
export type GetDeviceInfoOptions = {
  /**
   * @description 过滤字段的字符串数组,假如要获取指定字段,传入此数组。
   */
  filter: Array<string>
}

export type GetDeviceInfoResult = {
  /**
   * 设备品牌
   */
  brand?: string
  /**
   * 设备品牌
   */
  deviceBrand?: string,
  /**
   * 设备 id 。由 uni-app 框架生成并存储,清空 Storage 会导致改变
   */
  deviceId?: string,
  /**
DCloud-yyl's avatar
DCloud-yyl 已提交
22
   * 设备型号	
DCloud-yyl's avatar
DCloud-yyl 已提交
23 24 25
   */
  model?: string,
  /**
DCloud-yyl's avatar
DCloud-yyl 已提交
26
   * 设备型号	
DCloud-yyl's avatar
DCloud-yyl 已提交
27 28 29
   */
  deviceModel?: string,
  /**
DCloud-yyl's avatar
DCloud-yyl 已提交
30
   * 设备类型phone、pad、pc	
DCloud-yyl's avatar
DCloud-yyl 已提交
31 32 33
   */
  deviceType?: string,
  /**
DCloud-yyl's avatar
DCloud-yyl 已提交
34
   * 设备方向 竖屏 portrait、横屏 landscape	
DCloud-yyl's avatar
DCloud-yyl 已提交
35 36 37
   */
  deviceOrientation?: string,
  /**
DCloud-yyl's avatar
DCloud-yyl 已提交
38
   * 设备像素比	
DCloud-yyl's avatar
DCloud-yyl 已提交
39 40 41
   */
  devicePixelRatio?: string,
  /**
DCloud-yyl's avatar
DCloud-yyl 已提交
42
   * 操作系统及版本	
DCloud-yyl's avatar
DCloud-yyl 已提交
43 44 45
   */
  system?: string,
  /**
DCloud-yyl's avatar
DCloud-yyl 已提交
46
   * 客户端平台	
DCloud-yyl's avatar
DCloud-yyl 已提交
47 48 49 50 51 52 53 54 55 56 57 58
   */
  platform?: string,
  /**
   * 是否root
   */
  isRoot?: boolean,
  /**
   * 是否是模拟器
   */
  isSimulator?: boolean,
  /**
   * adb是否开启
DCloud-yyl's avatar
DCloud-yyl 已提交
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
   * 
   * @uniPlatform
   * {
   * 	"app": {
   * 		"android": {
   * 			"osVer": "5.0",
   * 			"uniVer": "x",
   * 			"unixVer": "√"
   * 		},
   * 		"ios": {
   * 			"osVer": "x",
   * 			"uniVer": "x",
   * 			"unixVer": "x"
   * 		}
   * 	}
DCloud-yyl's avatar
DCloud-yyl 已提交
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
   * }
   */
  isUSBDebugging?: boolean,
}


/**
 * @param [options=包含所有字段的过滤对象] 过滤的字段对象, 不传参数默认为获取全部字段。
 */
export type GetDeviceInfo = (options?: GetDeviceInfoOptions | null) => GetDeviceInfoResult;


export interface Uni {
  /**
    * GetDeviceInfo(Object object)
DCloud-yyl's avatar
DCloud-yyl 已提交
89
    * @description 
DCloud-yyl's avatar
DCloud-yyl 已提交
90 91 92 93
    * 获取设备信息
    * @param {GetDeviceInfoOptions} options [options=包含所有字段的过滤对象] 过滤的字段对象, 不传参数默认为获取全部字段。
    * @return {object}
    * @tutorial https://uniapp.dcloud.net.cn/api/system/getDeviceInfo.html
DCloud-yyl's avatar
DCloud-yyl 已提交
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
    * @uniPlatform
	* {
	* 	"app": {
	* 		"android": {
	* 			"osVer": "5.0",
	* 			"uniVer": "√",
	* 			"unixVer": "3.9+"
	* 		},
	* 		"ios": {
	* 			"osVer": "9.0",
	* 			"uniVer": "√",
	* 			"unixVer": "x"
	* 		}
	* 	},
  *   "web": {
  *     "uniVer": "√",
  *     "unixVer": "4.0"
  *   }
	* }
  * @example
DCloud-yyl's avatar
DCloud-yyl 已提交
114 115 116 117 118 119 120 121
     ```typescript
      uni.getDeviceInfo({
        filter:[]
      })
     ```
    */
  getDeviceInfo(options?: GetDeviceInfoOptions | null): GetDeviceInfoResult;
}