index.d.ts 10.1 KB
Newer Older
杜庆泉's avatar
杜庆泉 已提交
1 2 3 4 5 6 7 8
declare namespace UniNamespace {

  type UniWifiComplete = any
  type WifiSuccessCallback = (res : UniWifiResult) => void
  type WifiFailCallback = (err : UniWifiFail) => void
  type WifiCompleteCallback = (res : UniWifiComplete) => void
  type UniWifiCallback = () => void

lizhongyi_'s avatar
lizhongyi_ 已提交
9

杜庆泉's avatar
杜庆泉 已提交
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
  type WifiErrorCode = 1300002

  interface UniWifiInfo {
    SSID : string;
    BSSID ?: string;
    secure ?: boolean;
    signalStrength ?: number;
    frequency ?: number;
  }

  interface UniWifiResult {
    errCode : number,
    errSubject : string,
    errMsg : string,
    wifi : UniWifiInfo | null
  }

  interface UniWifiFail {
    errCode : WifiErrorCode
  }

lizhongyi_'s avatar
lizhongyi_ 已提交
31
  interface WifiConnectOption {
杜庆泉's avatar
杜庆泉 已提交
32 33 34 35 36
    SSID : string | null;
    BSSID : string | null;
    password : string | null;
    maunal : boolean | null;
    partialInfo : boolean | null; //ios不生效
lizhongyi_'s avatar
lizhongyi_ 已提交
37 38 39
    success : WifiSuccessCallback | null;
    fail : WifiFailCallback | null;
    complete : WifiCompleteCallback | null;
杜庆泉's avatar
杜庆泉 已提交
40 41 42 43
  }

  interface GetConnectedWifiOptions {
    partialInfo : boolean | null;
lizhongyi_'s avatar
lizhongyi_ 已提交
44 45
    success : WifiSuccessCallback | null;
    fail : WifiFailCallback | null;
杜庆泉's avatar
杜庆泉 已提交
46 47 48 49 50
    complete ?: WifiCompleteCallback | null;
  }


  interface WifiOption {
lizhongyi_'s avatar
lizhongyi_ 已提交
51 52 53 54 55 56 57
    success : WifiSuccessCallback | null,
    fail : WifiFailCallback | null,
    complete : InstallApkCompleteCallback | null
  }

  interface UniWifiInfoWithPartialInfo  {
  	SSID : string;
杜庆泉's avatar
杜庆泉 已提交
58 59
  }

lizhongyi_'s avatar
lizhongyi_ 已提交
60 61 62 63 64 65
  type UniGetWifiListCallback = (wifiInfo:UTSJSONObject) => void

  type UniWifiResultCallback = (wifiInfo:UniWifiResult) => void

  type UniWifiResultCallbackWithPartialInfo = (wifiInfo:UniWifiInfoWithPartialInfo) => void

杜庆泉's avatar
杜庆泉 已提交
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220
}

declare interface Uni {

  /**
   * 初始化Wi-Fi模块
   *
   * @param {WifiOption} option
   * @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#startwifi
   * @uniPlatform {
   *    "app": {
   *        "android": {
   *            "osVer": "4.4.4",
   *            "uniVer": "3.7.0",
   *            "unixVer": "3.9.0"
   *        },
   *        "ios": {
   *            "osVer": "9.0",
   *            "uniVer": "3.7.7",
   *            "unixVer": "3.9.0"
   *   	  }
   *    }
   * }
   * @uniVersion 3.7.7
   * @uniVueVersion 2,3  //支持的vue版本
   * @autotest { after: 'stopWifi' }
   */
  startWifi(option : UniNamespace.WifiOption): void,

  /**
   * 关闭 Wi-Fi 模块
   *
   * @param {WifiOption} option
   * @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#stopwifi
   * @uniPlatform {
   *    "app": {
   *        "android": {
   *            "osVer": "4.4.4",
   *            "uniVer": "3.7.0",
   *            "unixVer": "3.9.0"
   *        },
   *        "ios": {
   *            "osVer": "9.0",
   *            "uniVer": "3.7.7",
   *            "unixVer": "3.9.0"
   *   	  }
   *    }
   * }
   * @uniVersion 3.7.7
   * @uniVueVersion 2,3  //支持的vue版本
   * @autotest { before: 'startWifi' }
   */
  stopWifi(option : UniNamespace.WifiOption) : void,
  /**
   * @param {WifiConnectOption} option
   * @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#connectWifi
   * @uniPlatform {
   *    "app": {
   *        "android": {
   *            "osVer": ">=4.4 && <10.0",
   *            "uniVer": "3.7.0",
   *            "unixVer": "3.9.0"
   *        },
   *        "ios": {
   *            "osVer": "9.0",
   *            "uniVer": "3.7.7",
   *            "unixVer": "3.9.0"
   *   	  }
   *    }
   * }
   * @uniVersion 3.7.7
   * @uniVueVersion 2,3  //支持的vue版本
   * @autotest {
  	generated: false,
  	pollution: false,
  	cases:[
  		{
  			before: 'startWifi',
  			after: 'stopWifi',
  			input: [{
  				maunal:false,
  				SSID:"Xiaomi_20D0",
  				password:"streamApp!2016",
  			}],
  			output:{
  					callbackType: 'success',
  					value: { errCode: 12013 ,errMsg: "connectWifi:wifi config may be expired",errSubject: "uni-connectWifi"}
  				}
  		}
  	]
  }
  */
  connectWifi(option : UniNamespace.WifiConnectOption) : void,
  /**
   * 请求获取 Wi-Fi 列表。wifiList 数据会在 onGetWifiList 注册的回调中返回。
   * @param {WifiOption} option
   * @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#getWifiList
   * @uniPlatform {
   *    "app": {
   *        "android": {
   *            "osVer": "4.4.4",
   *            "uniVer": "3.7.0",
   *            "unixVer": "3.9.0"
   *        },
   *        "ios": {
   *            "osVer": "9.0",
   *            "uniVer": "3.7.7",
   *            "unixVer": "3.9.0"
   *   	  }
   *    }
   * }
   * @uniVersion 3.7.7
   * @uniVueVersion 2,3  //支持的vue版本
   * @autotest { before: 'startWifi', after: 'stopWifi' }
  */
  getWifiList(option : UniNamespace.WifiOption) : void,
  /**
   * 监听获取到 Wi-Fi 列表数据事件。
   *
   * @param {UniWifiCallback} callback
   * @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#onGetWifiList
   * @uniPlatform {
   *    "app": {
   *        "android": {
   *            "osVer": "4.4.4",
   *            "uniVer": "3.7.0",
   *            "unixVer": "3.9.0"
   *        },
   *        "ios": {
   *            "osVer": "9.0",
   *            "uniVer": "3.7.7",
   *            "unixVer": "3.9.0"
   *   	  }
   *    }
   * }
   * @uniVersion 3.7.7
   * @uniVueVersion 2,3  //支持的vue版本
   * @autotest  { expectCallback: true }
   * @autotest {
  	 generated: false,
  	 pollution: false,
  	 expectCallback: true,
  	 before: 'startWifi',
  	 after: 'onGetWifiListAfter',
  	 cases: [
  		 {
  			 output: {
  				 value: 0,
  				 returnKey: '.wifiList.length',
  				 jestExpectSyntax: 'toBeGreaterThan'
  			 },
  		 }
  	 ]
  }
   */
lizhongyi_'s avatar
lizhongyi_ 已提交
221
  onGetWifiList(callback : UniNamespace.UniGetWifiListCallback) : void,
杜庆泉's avatar
杜庆泉 已提交
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292
  /**
   * 移除获取到 Wi-Fi 列表数据事件的监听函数。
   *
   * @param {UniWifiCallback} callback
   * @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#offGetWifiList
   * @uniPlatform {
   *    "app": {
   *        "android": {
   *            "osVer": "4.4.4",
   *            "uniVer": "3.7.0",
   *            "unixVer": "3.9.0"
   *        },
   *        "ios": {
   *            "osVer": "9.0",
   *            "uniVer": "3.7.7",
   *            "unixVer": "3.9.0"
   *   	  }
   *    }
   * }
   * @uniVersion 3.7.7
   * @uniVueVersion 2,3  //支持的vue版本
   * @autotest { expectCallback: true }
   */
  offGetWifiList(callback : UniNamespace.UniWifiCallback) : void,
  /**
   * 获取已连接的 Wi-Fi 信息
   *
   * @param {GetConnectedWifiOptions} option
   * @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#getConnectedWifi
   * @uniPlatform {
   *    "app": {
   *        "android": {
   *            "osVer": "4.4.4",
   *            "uniVer": "3.7.0",
   *            "unixVer": "3.9.0"
   *        },
   *        "ios": {
   *            "osVer": "9.0",
   *            "uniVer": "3.7.7",
   *            "unixVer": "3.9.0"
   *   	  }
   *    }
   * }
   * @uniVersion 3.7.7
   * @uniVueVersion 2,3  //支持的vue版本
   * @autotest { before: 'startWifi', after: 'stopWifi' }
   */
  getConnectedWifi(option : UniNamespace.GetConnectedWifiOptions) : void,
  /**
   * 监听连接上 Wi-Fi 的事件
   *
   * @param {UniWifiCallback} callback
   * @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#onWifiConnected
   * @uniPlatform {
   *    "app": {
   *        "android": {
   *            "osVer": "4.4.4",
   *            "uniVer": "3.7.0",
   *            "unixVer": "3.9.0"
   *        },
   *        "ios": {
   *            "osVer": "9.0",
   *            "uniVer": "3.7.7",
   *            "unixVer": "3.9.0"
   *   	  }
   *    }
   * }
   * @uniVersion 3.7.7
   * @uniVueVersion 2,3  //支持的vue版本
   * @autotest { expectCallback: true }
   */
lizhongyi_'s avatar
lizhongyi_ 已提交
293
  onWifiConnected(callback : UniNamespace.UniWifiResultCallback) : void,
杜庆泉's avatar
杜庆泉 已提交
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316
  /**
   * 监听连接上 Wi-Fi 的事件。
   *
   * @param {UniWifiCallback} callback
   * @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#onWifiConnectedWithPartialInfo
   * @uniPlatform {
   *    "app": {
   *        "android": {
   *            "osVer": "4.4.4",
   *            "uniVer": "3.7.0",
   *            "unixVer": "3.9.0"
   *        },
   *        "ios": {
   *            "osVer": "9.0",
   *            "uniVer": "3.7.7",
   *            "unixVer": "3.9.0"
   *   	  }
   *    }
   * }
   * @uniVersion 3.7.7
   * @uniVueVersion 2,3  //支持的vue版本
   * @autotest { expectCallback: true }
   */
lizhongyi_'s avatar
lizhongyi_ 已提交
317
  onWifiConnectedWithPartialInfo(callback : UniNamespace.UniWifiResultCallbackWithPartialInfo) : void,
杜庆泉's avatar
杜庆泉 已提交
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346
  /**
   * 移除连接上 Wi-Fi 的事件的监听函数。
   *
   * @param {UniWifiCallback} callback
   * @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#offWifiConnected
   * @uniPlatform {
   *    "app": {
   *        "android": {
   *            "osVer": "4.4.4",
   *            "uniVer": "3.7.0",
   *            "unixVer": "3.9.0"
   *        },
   *        "ios": {
   *            "osVer": "9.0",
   *            "uniVer": "3.7.7",
   *            "unixVer": "3.9.0"
   *   	  }
   *    }
   * }
   * @uniVersion 3.7.7
   * @uniVueVersion 2,3  //支持的vue版本
   * @autotest { expectCallback: true }
   */
  offWifiConnected(callback ?: UniNamespace.UniWifiCallback) : void,

  /**
   * 移除连接上 Wi-Fi 的事件的监听函数。
   *
   * @param {UniWifiCallback} callback
lizhongyi_'s avatar
lizhongyi_ 已提交
347
   * @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#offWifiConnectedWithPartialInfo
杜庆泉's avatar
杜庆泉 已提交
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365
   * @uniPlatform {
   *    "app": {
   *        "android": {
   *            "osVer": "x",
   *            "uniVer": "x",
   *            "unixVer": "x"
   *        },
   *        "ios": {
   *            "osVer": "x",
   *            "uniVer": "x",
   *            "unixVer": "x"
   *   	  }
   *    }
   * }
   * @uniVersion 3.7.7
   * @uniVueVersion 2,3  //支持的vue版本
   * @autotest { expectCallback: true }
   */
lizhongyi_'s avatar
lizhongyi_ 已提交
366
  offWifiConnectedWithPartialInfo(callback ?: UniNamespace.UniWifiResultCallbackWithPartialInfo) : void,
杜庆泉's avatar
杜庆泉 已提交
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388
  /**
   * SetWifiList  暂未实现
   *
   * @uniPlatform {
   *    "app": {
   *        "android": {
   *            "osVer": "x",
   *            "uniVer": "x",
   *            "unixVer": "x"
   *        },
   *        "ios": {
   *            "osVer": "x",
   *            "uniVer": "x",
   *            "unixVer": "x"
   *   	  }
   *    }
   * }
   */
  setWifiList(option : UniNamespace.WifiOption) : void,


}