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