global.d.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /// <reference types="@tarojs/taro" />
  2. declare module '*.png';
  3. declare module '*.gif';
  4. declare module '*.jpg';
  5. declare module '*.jpeg';
  6. declare module '*.svg';
  7. declare module '*.css';
  8. declare module '*.less';
  9. declare module '*.scss';
  10. declare module '*.sass';
  11. declare module '*.styl';
  12. declare namespace NodeJS {
  13. interface ProcessEnv {
  14. /** NODE 内置环境变量, 会影响到最终构建生成产物 */
  15. NODE_ENV: 'development' | 'production',
  16. /** 当前构建的平台 */
  17. TARO_ENV: 'weapp' | 'swan' | 'alipay' | 'h5' | 'rn' | 'tt' | 'quickapp' | 'qq' | 'jd'
  18. /**
  19. * 当前构建的小程序 appid
  20. * @description 若不同环境有不同的小程序,可通过在 env 文件中配置环境变量`TARO_APP_ID`来方便快速切换 appid, 而不必手动去修改 dist/project.config.json 文件
  21. * @see https://taro-docs.jd.com/docs/next/env-mode-config#特殊环境变量-taro_app_id
  22. */
  23. TARO_APP_ID: string
  24. }
  25. }
  26. interface RequestType {
  27. code: number,
  28. data: any,
  29. msg: string
  30. }
  31. interface AbGroupContextType {
  32. listen(evt: Function): this
  33. emit(): this
  34. loop(time?: number): this
  35. cleanLoop(): this
  36. cleanStack(): this
  37. get(): object
  38. storeGroup(config: object): void
  39. getExperimentConfigByName(name: string|number): object | undefined
  40. validExperiment(name: string|number): boolean
  41. }
  42. type ConfigType = {
  43. header?: {},
  44. method?: 'GET' | 'POST',
  45. timeout?: number
  46. }
  47. type DataType = {
  48. [key: string]: any
  49. baseInfo?: object
  50. }
  51. type HttpInstanceType = {
  52. get(url: string, data?: {}, config?: ConfigType): Promise<any>
  53. post(url: string, data?: {}, config?: ConfigType): Promise<any>
  54. }
  55. type RoughCardType = {
  56. title: string
  57. shareTitle: string
  58. coverImg: any
  59. playCount: number
  60. totalTime: number
  61. user: any
  62. id: number
  63. videoPath: string
  64. videoCoverSnapshotPath: string
  65. shareImgPath: string
  66. favorited: boolean
  67. recomTraceId: number
  68. flowPool: string
  69. measure: number
  70. measureType: number
  71. recommendLogVO: string
  72. recommendSource: number
  73. }
  74. type CardType = {
  75. title: string
  76. coverImgPath: string
  77. playCount: number
  78. totalTime: number
  79. avatarUrl: string
  80. nickName: string
  81. id: number
  82. videoPath: string
  83. videoCoverSnapshotPath: string
  84. shareImgPath: string
  85. favorited: boolean
  86. }
  87. declare namespace Taro {
  88. // eslint-disable-next-line @typescript-eslint/no-empty-interface
  89. interface TaroStatic {
  90. $app: Taro.getApp.Instance<TaroGeneral.IAnyObject>
  91. $global: any
  92. $wx: any
  93. $http: HttpInstanceType
  94. $abGroupInstance: AbGroupContextType
  95. $network: any
  96. loginSync(): Promise<TaroGeneral.CallbackResult>
  97. }
  98. }
  99. declare const wx