interface.uts 13.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
/**
 * uni.setStorage成功回调参数
 */
export type SetStorageSuccess = {

}

/**
 * uni.setStorage成功回调函数定义
 */
export type SetStorageSuccessCallback = (res: SetStorageSuccess) => void
/**
 * uni.setStorage失败回调函数定义
 */
export type SetStorageFailCallback = (res: UniError) => void
/**
 * uni.setStorage完成回调函数定义
 */
export type SetStorageCompleteCallback = (res: any) => void
/**
 * uni.setStorage参数定义
 */
export type SetStorageOptions = {
  /**
   * 本地存储中的指定的 key
   */
  key: string,
  /**
DCloud-yyl's avatar
DCloud-yyl 已提交
29
   * 需要存储的内容,只支持原生类型、及能够通过 JSON.stringify 序列化的对象
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 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 221 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
   */
  data: any,
  /**
   * 接口调用成功的回调函数
   */
  success?: SetStorageSuccessCallback | null,
  /**
   * 接口调用失败的回调函数
   */
  fail?: SetStorageFailCallback | null,
  /**
   * 接口调用结束的回调函数(调用成功、失败都会执行)
   */
  complete?: SetStorageCompleteCallback | null
}

export type SetStorage = (options: SetStorageOptions) => void

export type SetStorageSync = (key: string, data: any) => void


/**
 * uni.getStorage成功回调参数
 */
export type GetStorageSuccess = {
  /**
   * key 对应的内容
   */
  data: any | null
}

/**
 * uni.getStorage成功回调函数定义
 */
export type GetStorageSuccessCallback = (res: GetStorageSuccess) => void
/**
 * uni.getStorage失败回调函数定义
 */
export type GetStorageFailCallback = (res: UniError) => void
/**
 * uni.getStorage完成回调函数定义
 */
export type GetStorageCompleteCallback = (res: any) => void
/**
 * uni.getStorage参数定义
 */
export type GetStorageOptions = {
  /**
   * 本地存储中的指定的 key
   */
  key: string,
  /**
   * 接口调用成功的回调函数
   */
  success?: GetStorageSuccessCallback | null,
  /**
   * 接口调用失败的回调函数
   */
  fail?: GetStorageFailCallback | null,
  /**
   * 接口调用结束的回调函数(调用成功、失败都会执行)
   */
  complete?: GetStorageCompleteCallback | null
}


export type GetStorage = (options: GetStorageOptions) => void


export type GetStorageSync = (key: string) => any | null


/**
 * uni.getStorageInfo成功回调参数
 */
export type GetStorageInfoSuccess = {
  /**
   * 当前 storage 中所有的 key
   */
  keys: Array<string>,
  /**
   * 当前占用的空间大小, 单位:kb
   */
  currentSize: number,
  /**
   * 限制的空间大小, 单位:kb
   */
  limitSize: number,
}

/**
 * uni.getStorageInfo成功回调函数定义
 */
export type GetStorageInfoSuccessCallback = (res: GetStorageInfoSuccess) => void
/**
 * uni.getStorageInfo失败回调函数定义
 */
export type GetStorageInfoFailCallback = (res: UniError) => void
/**
 * uni.getStorageInfo完成回调函数定义
 */
export type GetStorageInfoCompleteCallback = (res: any) => void
/**
 * uni.getStorageInfo参数定义
 */
export type GetStorageInfoOptions = {
  /**
   * 接口调用成功的回调函数
   */
  success?: GetStorageInfoSuccessCallback | null,
  /**
   * 接口调用失败的回调函数
   */
  fail?: GetStorageInfoFailCallback | null,
  /**
   * 接口调用结束的回调函数(调用成功、失败都会执行)
   */
  complete?: GetStorageInfoCompleteCallback | null
}


export type GetStorageInfo = (options: GetStorageInfoOptions) => void

export type GetStorageInfoSync = () => GetStorageInfoSuccess

/**
 * uni.removeStorage成功回调参数
 */
export type RemoveStorageSuccess = {
}

/**
 * uni.removeStorage成功回调函数定义
 */
export type RemoveStorageSuccessCallback = (res: RemoveStorageSuccess) => void
/**
 * uni.removeStorage失败回调函数定义
 */
export type RemoveStorageFailCallback = (res: UniError) => void
/**
 * uni.removeStorage完成回调函数定义
 */
export type RemoveStorageCompleteCallback = (res: any) => void
/**
 * uni.removeStorage参数定义
 */
export type RemoveStorageOptions = {
  /**
   * 本地存储中的指定的 key
   */
  key: string,
  /**
   * 接口调用的回调函数
   */
  success?: RemoveStorageSuccessCallback | null,
  /**
   * 接口调用失败的回调函数
   */
  fail?: RemoveStorageFailCallback | null,
  /**
   * 接口调用结束的回调函数(调用成功、失败都会执行)
   */
  complete?: RemoveStorageCompleteCallback | null
}


export type RemoveStorage = (options: RemoveStorageOptions) => void


export type RemoveStorageSync = (key: string) => void

/**
 * uni.clearStorage 成功返回数据结构
 */
export type ClearStorageSuccess = {

}

/**
 * uni.clearStorage 成功回调函数定义
 */
export type ClearStorageSuccessCallback = (res: ClearStorageSuccess) => void
/**
 * uni.clearStorage 失败回调函数定义
 */
export type ClearStorageFailCallback = (res: UniError) => void
/**
 * uni.clearStorage 完成回调函数定义
 */
export type ClearStorageCompleteCallback = (res: any) => void

/**
 * uni.removeStorage参数定义
 */
export type ClearStorageOptions = {
  /**
   * 接口调用的回调函数
   */
  success?: ClearStorageSuccessCallback | null,
  /**
   * 接口调用失败的回调函数
   */
  fail?: ClearStorageFailCallback | null,
  /**
   * 接口调用结束的回调函数(调用成功、失败都会执行)
   */
  complete?: ClearStorageCompleteCallback | null
}

export type ClearStorage = (option?: ClearStorageOptions | null) => void


export type ClearStorageSync = () => void

export interface Uni {
  /**
   * uni.setStorage函数定义
DCloud-yyl's avatar
DCloud-yyl 已提交
247 248 249
   * 将数据存储在本地storage存储中指定的 key 中,会覆盖掉原来该 key 对应的内容,这是一个异步接口。  
   * 
   * @param {SetStorageOptions} options 
250 251 252 253
   * @tutorial https://uniapp.dcloud.net.cn/api/storage/storage.html#setstorage
   * @uniPlatform {
   *    "app": {
   *        "android": {
DCloud-yyl's avatar
DCloud-yyl 已提交
254
   *            "osVer": "5.0",
255 256 257 258
   *            "uniVer": "2.0.3",
   *            "unixVer": "3.9.0"
   *        },
   *        "ios": {
DCloud-yyl's avatar
DCloud-yyl 已提交
259
   *            "osVer": "12.0",
260
   *            "uniVer": "2.0.3",
DCloud-yyl's avatar
DCloud-yyl 已提交
261
   *            "unixVer": "4.11"
262
   *   	  }
DCloud-yyl's avatar
DCloud-yyl 已提交
263 264 265 266
   *    },
   *    "web": {
   *        "uniVer": "√",
   *        "unixVer": "4.0"
267 268 269 270 271 272 273 274 275
   *    }
   * }
   * @uniVersion 2.0.3
   * @uniVueVersion 2,3  //支持的vue版本
   */
  setStorage(options: SetStorageOptions) :  void,
  /**
   * uni.setStorageSync函数定义
   * 将 data 存储在本地storage存储中指定的 key 中,会覆盖掉原来该 key 对应的内容,这是一个同步接口。
DCloud-yyl's avatar
DCloud-yyl 已提交
276
   * 
277
   * @param {string} key  本地storage存储中的指定的 key
DCloud-yyl's avatar
DCloud-yyl 已提交
278
   * @param {any} data  需要存储的内容,只支持原生类型、及能够通过 JSON.stringify 序列化的对象
279 280 281 282
   * @tutorial https://uniapp.dcloud.net.cn/api/storage/storage.html#setstoragesync
   * @uniPlatform {
   *    "app": {
   *        "android": {
DCloud-yyl's avatar
DCloud-yyl 已提交
283
   *            "osVer": "5.0",
284 285 286 287
   *            "uniVer": "2.0.3",
   *            "unixVer": "3.9.0"
   *        },
   *        "ios": {
DCloud-yyl's avatar
DCloud-yyl 已提交
288
   *            "osVer": "12.0",
289
   *            "uniVer": "2.0.3",
DCloud-yyl's avatar
DCloud-yyl 已提交
290
   *            "unixVer": "4.11"
291
   *   	  }
DCloud-yyl's avatar
DCloud-yyl 已提交
292 293 294 295
   *    },
   *    "web": {
   *        "uniVer": "√",
   *        "unixVer": "4.0"
296 297 298 299 300 301 302 303 304
   *    }
   * }
   * @uniVersion 2.0.3
   * @uniVueVersion 2,3  //支持的vue版本
   */
  setStorageSync(key: string, data: any) : void,
  /**
   * uni.getStorage函数定义
   * 从本地存储中异步获取指定 key 对应的内容。
DCloud-yyl's avatar
DCloud-yyl 已提交
305 306
   * 
   * @param {GetStorageOptions} options 
307 308 309 310
   * @tutorial https://uniapp.dcloud.net.cn/api/storage/storage.html#getstorage
   * @uniPlatform {
   *    "app": {
   *        "android": {
DCloud-yyl's avatar
DCloud-yyl 已提交
311
   *            "osVer": "5.0",
312
   *            "uniVer": "2.0.3",
DCloud-yyl's avatar
DCloud-yyl 已提交
313
   *            "unixVer": "3.9.0"
314 315
   *        },
   *        "ios": {
DCloud-yyl's avatar
DCloud-yyl 已提交
316
   *            "osVer": "12.0",
317
   *            "uniVer": "2.0.3",
DCloud-yyl's avatar
DCloud-yyl 已提交
318
   *            "unixVer": "4.11"
319
   *   	  }
DCloud-yyl's avatar
DCloud-yyl 已提交
320 321 322 323
   *    },
   *    "web": {
   *        "uniVer": "√",
   *        "unixVer": "4.0"
324 325 326 327 328 329 330 331 332
   *    }
   * }
   * @uniVersion 2.0.3
   * @uniVueVersion 2,3  //支持的vue版本
   */
  getStorage(options: GetStorageOptions) : void,
  /**
   * uni.getStorageSync函数定义
   * 从本地存储中同步获取指定 key 对应的内容。
DCloud-yyl's avatar
DCloud-yyl 已提交
333
   * 
334 335 336 337 338
   * @param {string} key  本地存储中的指定的 key
   * @tutorial https://uniapp.dcloud.net.cn/api/storage/storage.html#getstoragesync
   * @uniPlatform {
   *    "app": {
   *        "android": {
DCloud-yyl's avatar
DCloud-yyl 已提交
339
   *            "osVer": "5.0",
340 341 342 343
   *            "uniVer": "2.0.3",
   *            "unixVer": "3.9.0"
   *        },
   *        "ios": {
DCloud-yyl's avatar
DCloud-yyl 已提交
344
   *            "osVer": "12.0",
345
   *            "uniVer": "2.0.3",
DCloud-yyl's avatar
DCloud-yyl 已提交
346
   *            "unixVer": "4.11"
347
   *   	  }
DCloud-yyl's avatar
DCloud-yyl 已提交
348 349 350 351
   *    },
   *    "web": {
   *        "uniVer": "√",
   *        "unixVer": "4.0"
352 353 354 355 356 357 358 359 360
   *    }
   * }
   * @uniVersion 2.0.3
   * @uniVueVersion 2,3  //支持的vue版本
   */
  getStorageSync(key: string) : any | null,
  /**
   * uni.getStorageInfo函数定义
   * 异步获取当前 storage 的相关信息。
DCloud-yyl's avatar
DCloud-yyl 已提交
361 362
   * 
   * @param {GetStorageInfoOptions} options 
363 364 365 366
   * @tutorial https://uniapp.dcloud.net.cn/api/storage/storage.html#getstorageinfo
   * @uniPlatform {
   *    "app": {
   *        "android": {
DCloud-yyl's avatar
DCloud-yyl 已提交
367
   *            "osVer": "5.0",
368 369 370 371
   *            "uniVer": "2.0.3",
   *            "unixVer": "3.9.0"
   *        },
   *        "ios": {
DCloud-yyl's avatar
DCloud-yyl 已提交
372
   *            "osVer": "12.0",
373
   *            "uniVer": "2.0.3",
DCloud-yyl's avatar
DCloud-yyl 已提交
374
   *            "unixVer": "4.11"
375
   *   	  }
DCloud-yyl's avatar
DCloud-yyl 已提交
376 377 378 379
   *    },
   *    "web": {
   *        "uniVer": "√",
   *        "unixVer": "4.0"
380 381 382 383 384 385 386 387 388
   *    }
   * }
   * @uniVersion 2.0.3
   * @uniVueVersion 2,3  //支持的vue版本
   */
  getStorageInfo(options: GetStorageInfoOptions) : void,
  /**
   * uni.getStorageInfoSync函数定义
   * 同步获取当前 storage 的相关信息。
DCloud-yyl's avatar
DCloud-yyl 已提交
389 390
   * 
   * 
391
   * @tutorial https://uniapp.dcloud.net.cn/api/storage/storage.html#getstorageinfosync
DCloud-yyl's avatar
DCloud-yyl 已提交
392
   * 
393 394 395
   * @uniPlatform {
   *    "app": {
   *        "android": {
DCloud-yyl's avatar
DCloud-yyl 已提交
396
   *            "osVer": "5.0",
397 398 399 400
   *            "uniVer": "2.0.3",
   *            "unixVer": "3.9.0"
   *        },
   *        "ios": {
DCloud-yyl's avatar
DCloud-yyl 已提交
401
   *            "osVer": "12.0",
402
   *            "uniVer": "2.0.3",
DCloud-yyl's avatar
DCloud-yyl 已提交
403
   *            "unixVer": "4.11"
404
   *   	  }
DCloud-yyl's avatar
DCloud-yyl 已提交
405 406 407 408
   *    },
   *    "web": {
   *        "uniVer": "√",
   *        "unixVer": "4.0"
409 410 411 412 413 414 415 416 417
   *    }
   * }
   * @uniVersion 2.0.3
   * @uniVueVersion 2,3  //支持的vue版本
   */
  getStorageInfoSync() : GetStorageInfoSuccess,
  /**
   * uni.removeStorage函数定义
   * 从本地存储中异步移除指定 key。
DCloud-yyl's avatar
DCloud-yyl 已提交
418 419 420
   * 
   * @param {RemoveStorageOptions} options 
   * 
421
   * @tutorial hhttps://uniapp.dcloud.net.cn/api/storage/storage.html#removestorage
DCloud-yyl's avatar
DCloud-yyl 已提交
422
   * 
423 424 425
   * @uniPlatform {
   *    "app": {
   *        "android": {
DCloud-yyl's avatar
DCloud-yyl 已提交
426
   *            "osVer": "5.0",
427 428 429 430
   *            "uniVer": "2.0.3",
   *            "unixVer": "3.9.0"
   *        },
   *        "ios": {
DCloud-yyl's avatar
DCloud-yyl 已提交
431
   *            "osVer": "12.0",
432
   *            "uniVer": "2.0.3",
DCloud-yyl's avatar
DCloud-yyl 已提交
433
   *            "unixVer": "4.11"
434
   *   	  }
DCloud-yyl's avatar
DCloud-yyl 已提交
435 436 437 438
   *    },
   *    "web": {
   *        "uniVer": "√",
   *        "unixVer": "4.0"
439 440 441 442 443 444 445 446 447
   *    }
   * }
   * @uniVersion 2.0.3
   * @uniVueVersion 2,3  //支持的vue版本
   */
  removeStorage(options: RemoveStorageOptions) : void,
  /**
   * uni.removeStorageSync函数定义
   * 从本地存储中同步移除指定 key。
DCloud-yyl's avatar
DCloud-yyl 已提交
448
   * 
449
   * @param {string} key  本地存储中的指定的 key
DCloud-yyl's avatar
DCloud-yyl 已提交
450
   * 
451
   * @tutorial https://uniapp.dcloud.net.cn/api/storage/storage.html#removestoragesync
DCloud-yyl's avatar
DCloud-yyl 已提交
452
   * 
453 454 455
   * @uniPlatform {
   *    "app": {
   *        "android": {
DCloud-yyl's avatar
DCloud-yyl 已提交
456
   *            "osVer": "5.0",
457 458 459 460
   *            "uniVer": "2.0.3",
   *            "unixVer": "3.9.0"
   *        },
   *        "ios": {
DCloud-yyl's avatar
DCloud-yyl 已提交
461
   *            "osVer": "12.0",
462
   *            "uniVer": "2.0.3",
DCloud-yyl's avatar
DCloud-yyl 已提交
463
   *            "unixVer": "4.11"
464
   *   	  }
DCloud-yyl's avatar
DCloud-yyl 已提交
465 466 467 468
   *    },
   *    "web": {
   *        "uniVer": "√",
   *        "unixVer": "4.0"
469 470 471 472 473 474 475 476 477
   *    }
   * }
   * @uniVersion 2.0.3
   * @uniVueVersion 2,3  //支持的vue版本
   */
  removeStorageSync(key: string) : void,
  /**
   * uni.clearStorage函数定义
   * 清除本地数据存储。
DCloud-yyl's avatar
DCloud-yyl 已提交
478
   * 
479
   * @tutorial https://uniapp.dcloud.net.cn/api/storage/storage.html#clearstorage
DCloud-yyl's avatar
DCloud-yyl 已提交
480
   * 
481 482 483
   * @uniPlatform {
   *    "app": {
   *        "android": {
DCloud-yyl's avatar
DCloud-yyl 已提交
484
   *            "osVer": "5.0",
485 486 487 488
   *            "uniVer": "2.0.3",
   *            "unixVer": "3.9.0"
   *        },
   *        "ios": {
DCloud-yyl's avatar
DCloud-yyl 已提交
489
   *            "osVer": "12.0",
490
   *            "uniVer": "2.0.3",
DCloud-yyl's avatar
DCloud-yyl 已提交
491
   *            "unixVer": "4.11"
492
   *   	  }
DCloud-yyl's avatar
DCloud-yyl 已提交
493 494 495 496
   *    },
   *    "web": {
   *        "uniVer": "√",
   *        "unixVer": "4.0"
497 498 499 500 501 502 503 504 505
   *    }
   * }
   * @uniVersion 2.0.3
   * @uniVueVersion 2,3  //支持的vue版本
   */
  clearStorage(option?: ClearStorageOptions | null) : void,
  /**
   * uni.clearStorageSync函数定义
   * 清除本地数据存储。
DCloud-yyl's avatar
DCloud-yyl 已提交
506
   * 
507
   * @tutorial https://uniapp.dcloud.net.cn/api/storage/storage.html#clearstoragesync
DCloud-yyl's avatar
DCloud-yyl 已提交
508
   * 
509 510 511
   * @uniPlatform {
   *    "app": {
   *        "android": {
DCloud-yyl's avatar
DCloud-yyl 已提交
512
   *            "osVer": "5.0",
513 514 515 516
   *            "uniVer": "2.0.3",
   *            "unixVer": "3.9.0"
   *        },
   *        "ios": {
DCloud-yyl's avatar
DCloud-yyl 已提交
517
   *            "osVer": "12.0",
518
   *            "uniVer": "2.0.3",
DCloud-yyl's avatar
DCloud-yyl 已提交
519
   *            "unixVer": "4.11"
520
   *   	  }
DCloud-yyl's avatar
DCloud-yyl 已提交
521 522 523 524
   *    },
   *    "web": {
   *        "uniVer": "√",
   *        "unixVer": "4.0"
525 526 527 528 529 530 531
   *    }
   * }
   * @uniVersion 2.0.3
   * @uniVueVersion 2,3  //支持的vue版本
   */
  clearStorageSync() :  void
}