interface.uts 2.1 KB
Newer Older
lizhongyi_'s avatar
lizhongyi_ 已提交
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

export type ReadFileSuccessResult = {
  data: string
}


export type ReadFileSuccessCallback = (res: ReadFileSuccessResult) => void

export type ReadFileFailCallback = (res: UniError) => void

export type ReadFileCompleteCallback = (res: any) => void



export type ReadFileOptions = {
  /**
   * base64 / utf-8
   */
  encoding: string,
  /**
   * 文件路径,支持相对地址和绝对地址
   */
  filePath: string,
  /**
   * 接口调用的回调函数
   */
  success?: ReadFileSuccessCallback | null,
  /**
   * 接口调用失败的回调函数
   */
  fail?: ReadFileFailCallback | null,
  /**
   * 接口调用结束的回调函数(调用成功、失败都会执行)
   */
  complete?: ReadFileCompleteCallback | null
}


export type WriteFileSuccessResult = {
  filePath: string,
}


export type WriteFileSuccessCallback = (res: WriteFileSuccessResult) => void

export type WriteFileFailCallback = (res: UniError) => void

export type WriteFileCompleteCallback = (res: any) => void


export type WriteFileOptions = {
  /**
   * 文件路径,只支持绝对地址
   */
  filePath: string,
  /**
   * 写入的文本内容
   */
  data: string,
  /**
   * 接口调用的回调函数
   */
  success?: WriteFileSuccessCallback | null,
  /**
   * 接口调用失败的回调函数
   */
  fail?: WriteFileFailCallback | null,
  /**
   * 接口调用结束的回调函数(调用成功、失败都会执行)
   */
  complete?: WriteFileCompleteCallback | null
}


export interface FileSystemManager {
  readFile(config: ReadFileOptions): void;
  writeFile(config: WriteFileOptions): void;
}


export type GetFileSystemManager = () => FileSystemManager;


export interface Uni {
  /**
   * 获取文件管理器
   * @uniPlatform {
   *    "app": {
   *        "android": {
   *            "osVer": "4.4.4",
   *            "uniVer": "√",
   *            "unixVer": "3.9.0"
   *        },
   *        "ios": {
   *            "osVer": "x",
   *            "uniVer": "x",
   *            "unixVer": "x"
   *   	  }
   *    }
   * }
   * @uniVueVersion 2,3  //支持的vue版本
   */
  getFileSystemManager: GetFileSystemManager
}