@spcsn/taro 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -0
- package/dist/index.js +147 -0
- package/dist/index.js.map +1 -0
- package/index.js +9 -0
- package/package.json +86 -0
- package/types/api/ad/index.d.ts +197 -0
- package/types/api/ai/face.d.ts +133 -0
- package/types/api/ai/inference.d.ts +129 -0
- package/types/api/ai/visionkit.d.ts +874 -0
- package/types/api/alipay/index.d.ts +69 -0
- package/types/api/base/crypto.d.ts +104 -0
- package/types/api/base/debug.d.ts +329 -0
- package/types/api/base/env.d.ts +19 -0
- package/types/api/base/index.d.ts +102 -0
- package/types/api/base/performance.d.ts +258 -0
- package/types/api/base/system.d.ts +742 -0
- package/types/api/base/update.d.ts +130 -0
- package/types/api/base/weapp/app-event.d.ts +265 -0
- package/types/api/base/weapp/life-cycle.d.ts +155 -0
- package/types/api/canvas/index.d.ts +2162 -0
- package/types/api/cloud/index.d.ts +2622 -0
- package/types/api/data-analysis/index.d.ts +122 -0
- package/types/api/device/accelerometer.d.ts +102 -0
- package/types/api/device/accessibility.d.ts +26 -0
- package/types/api/device/battery.d.ts +46 -0
- package/types/api/device/bluetooth-ble.d.ts +601 -0
- package/types/api/device/bluetooth-peripheral.d.ts +430 -0
- package/types/api/device/bluetooth.d.ts +463 -0
- package/types/api/device/calendar.d.ts +98 -0
- package/types/api/device/clipboard.d.ts +81 -0
- package/types/api/device/compass.d.ts +105 -0
- package/types/api/device/contact.d.ts +110 -0
- package/types/api/device/gyroscope.d.ts +85 -0
- package/types/api/device/iBeacon.d.ts +168 -0
- package/types/api/device/keyboard.d.ts +97 -0
- package/types/api/device/memory.d.ts +52 -0
- package/types/api/device/motion.d.ts +88 -0
- package/types/api/device/network.d.ts +172 -0
- package/types/api/device/nfc.d.ts +1238 -0
- package/types/api/device/phone.d.ts +30 -0
- package/types/api/device/scan.d.ts +111 -0
- package/types/api/device/screen.d.ts +217 -0
- package/types/api/device/sms.d.ts +26 -0
- package/types/api/device/vibrate.d.ts +51 -0
- package/types/api/device/wifi.d.ts +301 -0
- package/types/api/ext/index.d.ts +64 -0
- package/types/api/files/index.d.ts +1472 -0
- package/types/api/framework/index.d.ts +51 -0
- package/types/api/location/index.d.ts +517 -0
- package/types/api/media/audio.d.ts +1013 -0
- package/types/api/media/background-audio.d.ts +291 -0
- package/types/api/media/camera.d.ts +207 -0
- package/types/api/media/editor.d.ts +239 -0
- package/types/api/media/image.d.ts +469 -0
- package/types/api/media/live.d.ts +461 -0
- package/types/api/media/map.d.ts +638 -0
- package/types/api/media/media-recorder.d.ts +117 -0
- package/types/api/media/recorder.d.ts +317 -0
- package/types/api/media/video-decoder.d.ts +117 -0
- package/types/api/media/video-processing.d.ts +84 -0
- package/types/api/media/video.d.ts +527 -0
- package/types/api/media/voip.d.ts +393 -0
- package/types/api/navigate/index.d.ts +327 -0
- package/types/api/network/download.d.ts +173 -0
- package/types/api/network/mdns.d.ts +191 -0
- package/types/api/network/request.d.ts +480 -0
- package/types/api/network/tcp.d.ts +181 -0
- package/types/api/network/udp.d.ts +218 -0
- package/types/api/network/upload.d.ts +201 -0
- package/types/api/network/websocket.d.ts +383 -0
- package/types/api/open-api/account.d.ts +51 -0
- package/types/api/open-api/address.d.ts +68 -0
- package/types/api/open-api/authorize.d.ts +80 -0
- package/types/api/open-api/card.d.ts +110 -0
- package/types/api/open-api/channels.d.ts +225 -0
- package/types/api/open-api/customer-service.d.ts +45 -0
- package/types/api/open-api/device-voip.d.ts +103 -0
- package/types/api/open-api/facial.d.ts +98 -0
- package/types/api/open-api/favorites.d.ts +101 -0
- package/types/api/open-api/group.d.ts +59 -0
- package/types/api/open-api/invoice.d.ts +87 -0
- package/types/api/open-api/license-plate.d.ts +27 -0
- package/types/api/open-api/login.d.ts +115 -0
- package/types/api/open-api/my-miniprogram.d.ts +28 -0
- package/types/api/open-api/privacy.d.ts +107 -0
- package/types/api/open-api/redpackage.d.ts +24 -0
- package/types/api/open-api/settings.d.ts +174 -0
- package/types/api/open-api/soter.d.ts +184 -0
- package/types/api/open-api/sticker.d.ts +83 -0
- package/types/api/open-api/subscribe-message.d.ts +305 -0
- package/types/api/open-api/user-info.d.ts +182 -0
- package/types/api/open-api/werun.d.ts +101 -0
- package/types/api/payment/index.d.ts +119 -0
- package/types/api/qq/index.d.ts +354 -0
- package/types/api/route/index.d.ts +324 -0
- package/types/api/share/index.d.ts +354 -0
- package/types/api/skyline/index.d.ts +345 -0
- package/types/api/storage/background-fetch.d.ts +131 -0
- package/types/api/storage/cache-manager.d.ts +249 -0
- package/types/api/storage/index.d.ts +405 -0
- package/types/api/swan/bookshelf.d.ts +307 -0
- package/types/api/swan/download-package.d.ts +80 -0
- package/types/api/swan/index.d.ts +251 -0
- package/types/api/swan/pay.d.ts +139 -0
- package/types/api/taro.extend.d.ts +233 -0
- package/types/api/taro.hooks.d.ts +148 -0
- package/types/api/ui/animation.d.ts +427 -0
- package/types/api/ui/background.d.ts +69 -0
- package/types/api/ui/custom-component.d.ts +23 -0
- package/types/api/ui/fonts.d.ts +77 -0
- package/types/api/ui/interaction.d.ts +281 -0
- package/types/api/ui/menu.d.ts +29 -0
- package/types/api/ui/navigation-bar.d.ts +130 -0
- package/types/api/ui/pull-down-refresh.d.ts +50 -0
- package/types/api/ui/scroll.d.ts +114 -0
- package/types/api/ui/sticky.d.ts +32 -0
- package/types/api/ui/tab-bar.d.ts +196 -0
- package/types/api/ui/window.d.ts +71 -0
- package/types/api/worker/index.d.ts +83 -0
- package/types/api/wxml/index.d.ts +540 -0
- package/types/compile/compiler.d.ts +32 -0
- package/types/compile/config/h5.d.ts +134 -0
- package/types/compile/config/harmony.d.ts +118 -0
- package/types/compile/config/index.d.ts +8 -0
- package/types/compile/config/manifest.d.ts +155 -0
- package/types/compile/config/mini.d.ts +118 -0
- package/types/compile/config/plugin.d.ts +34 -0
- package/types/compile/config/project.d.ts +338 -0
- package/types/compile/config/rn.d.ts +85 -0
- package/types/compile/config/util.d.ts +179 -0
- package/types/compile/hooks.d.ts +13 -0
- package/types/compile/index.d.ts +11 -0
- package/types/compile/viteCompilerContext.d.ts +167 -0
- package/types/global.d.ts +428 -0
- package/types/index.d.ts +190 -0
- package/types/taro.api.d.ts +130 -0
- package/types/taro.component.d.ts +168 -0
- package/types/taro.config.d.ts +712 -0
- package/types/taro.lifecycle.d.ts +220 -0
- package/types/taro.runtime.d.ts +9 -0
|
@@ -0,0 +1,469 @@
|
|
|
1
|
+
import Taro from '../../index'
|
|
2
|
+
|
|
3
|
+
declare module '../../index' {
|
|
4
|
+
namespace saveImageToPhotosAlbum {
|
|
5
|
+
interface Option {
|
|
6
|
+
/** 图片文件路径,可以是临时文件路径或永久文件路径,不支持网络图片路径 */
|
|
7
|
+
filePath: string
|
|
8
|
+
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
9
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
10
|
+
/** 接口调用失败的回调函数 */
|
|
11
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
12
|
+
/** 接口调用成功的回调函数 */
|
|
13
|
+
success?: (res: TaroGeneral.CallbackResult) => void
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
namespace previewImage {
|
|
18
|
+
interface Option {
|
|
19
|
+
/** 需要预览的图片链接列表。 */
|
|
20
|
+
urls: string[]
|
|
21
|
+
/**
|
|
22
|
+
* 当前显示图片的http链接
|
|
23
|
+
*/
|
|
24
|
+
current?: string | number
|
|
25
|
+
/**
|
|
26
|
+
* 是否支持长按下载图片
|
|
27
|
+
* @supported alipay 基础库: 1.13.0
|
|
28
|
+
*/
|
|
29
|
+
enablesavephoto?: boolean
|
|
30
|
+
/**
|
|
31
|
+
* 是否在右下角显示下载入口
|
|
32
|
+
* @supported alipay 基础库: 1.13.0
|
|
33
|
+
*/
|
|
34
|
+
enableShowPhotoDownload?: boolean
|
|
35
|
+
/** @supported weapp 最低版本:2.13.0。是否显示长按菜单,默认值:true */
|
|
36
|
+
showmenu?: boolean
|
|
37
|
+
/** @supported weapp 最低版本:2.13.0。origin: 发送完整的referrer; no-referrer: 不发送。格式固定为 https://servicewechat.com/{appid}/{version}/page-frame.html,其中 {appid} 为小程序的 appid,{version} 为小程序的版本号,版本号为 0 表示为开发版、体验版以及审核版本,版本号为 devtools 表示为开发者工具,其余为正式版本;默认值:no-referrer */
|
|
38
|
+
referrerPolicy?: string
|
|
39
|
+
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
40
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
41
|
+
/** 接口调用失败的回调函数 */
|
|
42
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
43
|
+
/** 接口调用成功的回调函数 */
|
|
44
|
+
success?: (res: TaroGeneral.CallbackResult) => void
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
namespace previewMedia {
|
|
49
|
+
interface Sources {
|
|
50
|
+
/** 图片或视频的地址 */
|
|
51
|
+
url: string
|
|
52
|
+
/** 资源的类型(图片或视频),默认值:image */
|
|
53
|
+
type?: 'image' | 'video'
|
|
54
|
+
/** 视频的封面图片 */
|
|
55
|
+
poster?: string
|
|
56
|
+
}
|
|
57
|
+
interface Option {
|
|
58
|
+
/** 需要预览的资源列表 */
|
|
59
|
+
sources: Sources[]
|
|
60
|
+
/** 当前显示的资源序号,默认值:0 */
|
|
61
|
+
current?: number
|
|
62
|
+
/** 是否显示长按菜单 2.13.0,默认值:true */
|
|
63
|
+
showmenu?: boolean
|
|
64
|
+
/** origin: 发送完整的referrer; no-referrer: 不发送。格式固定为 https://servicewechat.com/{appid}/{version}/page-frame.html,其中 {appid} 为小程序的 appid,{version} 为小程序的版本号,版本号为 0 表示为开发版、体验版以及审核版本,版本号为 devtools 表示为开发者工具,其余为正式版本;默认值:no-referrer */
|
|
65
|
+
referrerPolicy?: string
|
|
66
|
+
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
67
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
68
|
+
/** 接口调用失败的回调函数 */
|
|
69
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
70
|
+
/** 接口调用成功的回调函数 */
|
|
71
|
+
success?: (res: TaroGeneral.CallbackResult) => void
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
namespace getImageInfo {
|
|
76
|
+
interface Option {
|
|
77
|
+
/** 图片的路径,可以是相对路径、临时文件路径、存储文件路径、网络图片路径 */
|
|
78
|
+
src: string
|
|
79
|
+
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
80
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
81
|
+
/** 接口调用失败的回调函数 */
|
|
82
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
83
|
+
/** 接口调用成功的回调函数 */
|
|
84
|
+
success?: (result: SuccessCallbackResult) => void
|
|
85
|
+
}
|
|
86
|
+
interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
|
|
87
|
+
/** 图片原始高度,单位px。不考虑旋转。 */
|
|
88
|
+
height: number
|
|
89
|
+
/** [拍照时设备方向](http://sylvana.net/jpegcrop/exif_orientation.html)
|
|
90
|
+
* @default "up"
|
|
91
|
+
*/
|
|
92
|
+
orientation: keyof Orientation
|
|
93
|
+
/** 图片的本地路径 */
|
|
94
|
+
path: string
|
|
95
|
+
/** 图片格式 */
|
|
96
|
+
type: string
|
|
97
|
+
/** 图片原始宽度,单位px。不考虑旋转。 */
|
|
98
|
+
width: number
|
|
99
|
+
/** 调用结果 */
|
|
100
|
+
errMsg: string
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
interface Orientation {
|
|
104
|
+
/** 默认方向(手机横持拍照),对应 Exif 中的 1。或无 orientation 信息。 */
|
|
105
|
+
'up'
|
|
106
|
+
/** 同 up,但镜像翻转,对应 Exif 中的 2 */
|
|
107
|
+
'up-mirrored'
|
|
108
|
+
/** 旋转180度,对应 Exif 中的 3 */
|
|
109
|
+
'down'
|
|
110
|
+
/** 同 down,但镜像翻转,对应 Exif 中的 4 */
|
|
111
|
+
'down-mirrored'
|
|
112
|
+
/** 同 left,但镜像翻转,对应 Exif 中的 5 */
|
|
113
|
+
'left-mirrored'
|
|
114
|
+
/** 顺时针旋转90度,对应 Exif 中的 6 */
|
|
115
|
+
'right'
|
|
116
|
+
/** 同 right,但镜像翻转,对应 Exif 中的 7 */
|
|
117
|
+
'right-mirrored'
|
|
118
|
+
/** 逆时针旋转90度,对应 Exif 中的 8 */
|
|
119
|
+
'left'
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
namespace editImage {
|
|
124
|
+
interface Option {
|
|
125
|
+
/** 图片路径,图片的路径,支持本地路径、代码包路径 */
|
|
126
|
+
src: string
|
|
127
|
+
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
128
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
129
|
+
/** 接口调用失败的回调函数 */
|
|
130
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
131
|
+
/** 接口调用成功的回调函数 */
|
|
132
|
+
success?: (result: SuccessCallbackResult) => void
|
|
133
|
+
}
|
|
134
|
+
interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
|
|
135
|
+
/** 编辑后图片的临时文件路径 (本地路径) */
|
|
136
|
+
tempFilePath: string
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
namespace chooseImage {
|
|
141
|
+
interface Option {
|
|
142
|
+
/** 最多可以选择的图片张数
|
|
143
|
+
* @default 9
|
|
144
|
+
* @supported weapp, alipay, swan, tt, h5, rn
|
|
145
|
+
*/
|
|
146
|
+
count?: number
|
|
147
|
+
/** 所选的图片的尺寸
|
|
148
|
+
* @default ['original', 'compressed']
|
|
149
|
+
* @supported weapp, alipay, swan, tt, rn
|
|
150
|
+
*/
|
|
151
|
+
sizeType?: Array<keyof sizeType>
|
|
152
|
+
/** 选择图片的来源
|
|
153
|
+
* @default ['album', 'camera']
|
|
154
|
+
* @supported weapp, alipay, swan, tt, h5, rn
|
|
155
|
+
*/
|
|
156
|
+
sourceType?: Array<keyof sourceType>
|
|
157
|
+
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
158
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
159
|
+
/** 接口调用失败的回调函数 */
|
|
160
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
161
|
+
/** 接口调用成功的回调函数 */
|
|
162
|
+
success?: (result: SuccessCallbackResult) => void
|
|
163
|
+
/** 用来上传的input元素ID(仅h5端
|
|
164
|
+
* @supported h5
|
|
165
|
+
*/
|
|
166
|
+
imageId?: string
|
|
167
|
+
}
|
|
168
|
+
/** 图片的尺寸 */
|
|
169
|
+
interface sizeType {
|
|
170
|
+
/** 原图 */
|
|
171
|
+
original
|
|
172
|
+
/** compressed */
|
|
173
|
+
compressed
|
|
174
|
+
}
|
|
175
|
+
/** 图片的来源 */
|
|
176
|
+
interface sourceType {
|
|
177
|
+
/** 从相册选图 */
|
|
178
|
+
album
|
|
179
|
+
/** 使用相机 */
|
|
180
|
+
camera
|
|
181
|
+
/** 使用前置摄像头(仅H5纯浏览器使用) */
|
|
182
|
+
user
|
|
183
|
+
/** 使用后置摄像头(仅H5纯浏览器) */
|
|
184
|
+
environment
|
|
185
|
+
}
|
|
186
|
+
interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
|
|
187
|
+
/** 图片的本地临时文件路径列表 */
|
|
188
|
+
tempFilePaths: string[]
|
|
189
|
+
/** 图片的本地临时文件列表 */
|
|
190
|
+
tempFiles: ImageFile[]
|
|
191
|
+
/** 调用结果 */
|
|
192
|
+
errMsg: string
|
|
193
|
+
}
|
|
194
|
+
/** 图片的本地临时文件列表 */
|
|
195
|
+
interface ImageFile {
|
|
196
|
+
/** 本地临时文件路径 */
|
|
197
|
+
path: string
|
|
198
|
+
/** 本地临时文件大小,单位 B */
|
|
199
|
+
size: number
|
|
200
|
+
/** 文件的 MIME 类型
|
|
201
|
+
* @supported h5
|
|
202
|
+
*/
|
|
203
|
+
type?: string
|
|
204
|
+
/** 原始的浏览器 File 对象
|
|
205
|
+
* @supported h5
|
|
206
|
+
*/
|
|
207
|
+
originalFileObj?: File
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
namespace compressImage {
|
|
212
|
+
interface Option {
|
|
213
|
+
/** 图片路径,图片的路径,可以是相对路径、临时文件路径、存储文件路径 */
|
|
214
|
+
src: string
|
|
215
|
+
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
216
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
217
|
+
/** 接口调用失败的回调函数 */
|
|
218
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
219
|
+
/** 压缩质量,范围0~100,数值越小,质量越低,压缩率越高(仅对jpg有效)。 */
|
|
220
|
+
quality?: number
|
|
221
|
+
/** 压缩后图片的宽度,单位为px,若不填写则默认以 compressedHeight 为准等比缩放。 */
|
|
222
|
+
compressedWidth?: number
|
|
223
|
+
/** 压缩后图片的高度,单位为px,若不填写则默认以 compressedWidth 为准等比缩放。 */
|
|
224
|
+
compressedHeight?: number
|
|
225
|
+
/** 接口调用成功的回调函数 */
|
|
226
|
+
success?: (result: SuccessCallbackResult) => void
|
|
227
|
+
}
|
|
228
|
+
interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
|
|
229
|
+
/** 压缩后图片的临时文件路径 */
|
|
230
|
+
tempFilePath: string
|
|
231
|
+
/** 调用结果 */
|
|
232
|
+
errMsg: string
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
namespace chooseMessageFile {
|
|
237
|
+
interface Option {
|
|
238
|
+
/** 最多可以选择的文件个数,可以 0~100 */
|
|
239
|
+
count: number
|
|
240
|
+
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
241
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
242
|
+
/** 根据文件拓展名过滤,仅 type==file 时有效。每一项都不能是空字符串。默认不过滤。 */
|
|
243
|
+
extension?: string[]
|
|
244
|
+
/** 接口调用失败的回调函数 */
|
|
245
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
246
|
+
/** 接口调用成功的回调函数 */
|
|
247
|
+
success?: (result: SuccessCallbackResult) => void
|
|
248
|
+
/** 所选的文件的类型 */
|
|
249
|
+
type?: keyof SelectType
|
|
250
|
+
}
|
|
251
|
+
interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
|
|
252
|
+
/** 返回选择的文件的本地临时文件对象数组 */
|
|
253
|
+
tempFiles: ChooseFile[]
|
|
254
|
+
/** 调用结果 */
|
|
255
|
+
errMsg: string
|
|
256
|
+
}
|
|
257
|
+
/** 返回选择的文件的本地临时文件对象数组 */
|
|
258
|
+
interface ChooseFile {
|
|
259
|
+
/** 选择的文件名称 */
|
|
260
|
+
name: string
|
|
261
|
+
/** 本地临时文件路径 */
|
|
262
|
+
path: string
|
|
263
|
+
/** 本地临时文件大小,单位 B */
|
|
264
|
+
size: number
|
|
265
|
+
/** 选择的文件的会话发送时间,Unix时间戳,工具暂不支持此属性 */
|
|
266
|
+
time: number
|
|
267
|
+
/** 选择的文件类型 */
|
|
268
|
+
type: keyof SelectedType
|
|
269
|
+
}
|
|
270
|
+
interface SelectType {
|
|
271
|
+
/** 从所有文件选择 */
|
|
272
|
+
all
|
|
273
|
+
/** 只能选择视频文件 */
|
|
274
|
+
video
|
|
275
|
+
/** 只能选择图片文件 */
|
|
276
|
+
image
|
|
277
|
+
/** 可以选择除了图片和视频之外的其它的文件 */
|
|
278
|
+
file
|
|
279
|
+
}
|
|
280
|
+
interface SelectedType {
|
|
281
|
+
/** 选择了视频文件 */
|
|
282
|
+
video
|
|
283
|
+
/** 选择了图片文件 */
|
|
284
|
+
image
|
|
285
|
+
/** 选择了除图片和视频的文件 */
|
|
286
|
+
file
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
namespace cropImage {
|
|
291
|
+
interface Option {
|
|
292
|
+
/** 图片路径,图片的路径,支持本地路径、代码包路径 */
|
|
293
|
+
src: string
|
|
294
|
+
/** 裁剪比例 */
|
|
295
|
+
cropScale: keyof CropScale
|
|
296
|
+
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
297
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
298
|
+
/** 接口调用失败的回调函数 */
|
|
299
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
300
|
+
/** 接口调用成功的回调函数 */
|
|
301
|
+
success?: (result: SuccessCallbackResult) => void
|
|
302
|
+
}
|
|
303
|
+
interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
|
|
304
|
+
/** 剪裁后图片的临时文件路径 (本地路径) */
|
|
305
|
+
tempFilePath: string
|
|
306
|
+
}
|
|
307
|
+
interface CropScale {
|
|
308
|
+
/** 宽高比为1比1 */
|
|
309
|
+
'1:1'
|
|
310
|
+
/** 宽高比为3比4 */
|
|
311
|
+
'3:4'
|
|
312
|
+
/** 宽高比为4比3 */
|
|
313
|
+
'4:3'
|
|
314
|
+
/** 宽高比为4比5 */
|
|
315
|
+
'4:5'
|
|
316
|
+
/** 宽高比为5比4 */
|
|
317
|
+
'5:4'
|
|
318
|
+
/** 宽高比为9比16 */
|
|
319
|
+
'9:16'
|
|
320
|
+
/** 宽高比为16比9 */
|
|
321
|
+
'16:9'
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
interface TaroStatic {
|
|
326
|
+
/** 保存图片到系统相册。需要[用户授权](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/authorize.html) scope.writePhotosAlbum
|
|
327
|
+
* @supported weapp, alipay, swan, tt, h5, rn, harmony_hybrid
|
|
328
|
+
* @example
|
|
329
|
+
* ```tsx
|
|
330
|
+
* Taro.saveImageToPhotosAlbum({
|
|
331
|
+
* success: function (res) { }
|
|
332
|
+
* })
|
|
333
|
+
* ```
|
|
334
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.saveImageToPhotosAlbum.html
|
|
335
|
+
*/
|
|
336
|
+
saveImageToPhotosAlbum(option: saveImageToPhotosAlbum.Option): Promise<TaroGeneral.CallbackResult>
|
|
337
|
+
|
|
338
|
+
/** 预览图片和视频。
|
|
339
|
+
* @supported weapp
|
|
340
|
+
* @example
|
|
341
|
+
* ```tsx
|
|
342
|
+
* Taro.previewMedia({
|
|
343
|
+
* sources: []
|
|
344
|
+
* })
|
|
345
|
+
* ```
|
|
346
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.previewMedia.html
|
|
347
|
+
*/
|
|
348
|
+
previewMedia(option: previewMedia.Option): Promise<TaroGeneral.CallbackResult>
|
|
349
|
+
|
|
350
|
+
/** 在新页面中全屏预览图片。预览的过程中用户可以进行保存图片、发送给朋友等操作。
|
|
351
|
+
* @supported weapp, alipay, swan, tt, h5, rn, harmony_hybrid
|
|
352
|
+
* @example
|
|
353
|
+
* ```tsx
|
|
354
|
+
* Taro.previewImage({
|
|
355
|
+
* current: '', // 当前显示图片的http链接
|
|
356
|
+
* urls: [] // 需要预览的图片http链接列表
|
|
357
|
+
* })
|
|
358
|
+
* ```
|
|
359
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.previewImage.html
|
|
360
|
+
*/
|
|
361
|
+
previewImage(option: previewImage.Option): Promise<TaroGeneral.CallbackResult>
|
|
362
|
+
|
|
363
|
+
/** 获取图片信息。网络图片需先配置download域名才能生效。
|
|
364
|
+
* @supported weapp, alipay, swan, tt, h5, rn, harmony, harmony_hybrid
|
|
365
|
+
* @example
|
|
366
|
+
* ```tsx
|
|
367
|
+
* Taro.getImageInfo({
|
|
368
|
+
* src: 'images/a.jpg',
|
|
369
|
+
* success: function (res) {
|
|
370
|
+
* console.log(res.width)
|
|
371
|
+
* console.log(res.height)
|
|
372
|
+
* }
|
|
373
|
+
* })
|
|
374
|
+
* Taro.chooseImage({
|
|
375
|
+
* success: function (res) {
|
|
376
|
+
* Taro.getImageInfo({
|
|
377
|
+
* src: res.tempFilePaths[0],
|
|
378
|
+
* success: function (res) {
|
|
379
|
+
* console.log(res.width)
|
|
380
|
+
* console.log(res.height)
|
|
381
|
+
* }
|
|
382
|
+
* })
|
|
383
|
+
* }
|
|
384
|
+
* })
|
|
385
|
+
* ```
|
|
386
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.getImageInfo.html
|
|
387
|
+
*/
|
|
388
|
+
getImageInfo(option: getImageInfo.Option): Promise<getImageInfo.SuccessCallbackResult>
|
|
389
|
+
|
|
390
|
+
/** 编辑图片接口
|
|
391
|
+
* @supported weapp
|
|
392
|
+
* @example
|
|
393
|
+
* ```tsx
|
|
394
|
+
* Taro.editImage({
|
|
395
|
+
* src: '', // 图片路径
|
|
396
|
+
* })
|
|
397
|
+
* ```
|
|
398
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.editImage.html
|
|
399
|
+
*/
|
|
400
|
+
editImage(option: editImage.Option): Promise<editImage.SuccessCallbackResult>
|
|
401
|
+
|
|
402
|
+
/** 压缩图片接口,可选压缩质量
|
|
403
|
+
* @supported weapp, tt, rn
|
|
404
|
+
* @example
|
|
405
|
+
* ```tsx
|
|
406
|
+
* Taro.compressImage({
|
|
407
|
+
* src: '', // 图片路径
|
|
408
|
+
* quality: 80 // 压缩质量
|
|
409
|
+
* })
|
|
410
|
+
* ```
|
|
411
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.compressImage.html
|
|
412
|
+
*/
|
|
413
|
+
compressImage(option: compressImage.Option): Promise<compressImage.SuccessCallbackResult>
|
|
414
|
+
|
|
415
|
+
/** 从客户端会话选择文件。
|
|
416
|
+
* @supported weapp
|
|
417
|
+
* @example
|
|
418
|
+
* ```tsx
|
|
419
|
+
* Taro.chooseMessageFile({
|
|
420
|
+
* count: 10,
|
|
421
|
+
* type: 'image',
|
|
422
|
+
* success: function (res) {
|
|
423
|
+
* // tempFilePath可以作为img标签的src属性显示图片
|
|
424
|
+
* const tempFilePaths = res.tempFiles
|
|
425
|
+
* }
|
|
426
|
+
* })
|
|
427
|
+
* ```
|
|
428
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.chooseMessageFile.html
|
|
429
|
+
*/
|
|
430
|
+
chooseMessageFile(option: chooseMessageFile.Option): Promise<chooseMessageFile.SuccessCallbackResult>
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* 从本地相册选择图片或使用相机拍照。
|
|
434
|
+
* @supported weapp, alipay, swan, tt, h5, rn, harmony_hybrid
|
|
435
|
+
* @example
|
|
436
|
+
* ```tsx
|
|
437
|
+
* Taro.chooseImage({
|
|
438
|
+
* count: 1, // 默认9
|
|
439
|
+
* sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
|
|
440
|
+
* sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有,在H5浏览器端支持使用 `user` 和 `environment`分别指定为前后摄像头
|
|
441
|
+
* success: function (res) {
|
|
442
|
+
* // 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片
|
|
443
|
+
* var tempFilePaths = res.tempFilePaths
|
|
444
|
+
* }
|
|
445
|
+
* })
|
|
446
|
+
* ```
|
|
447
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.chooseImage.html
|
|
448
|
+
*/
|
|
449
|
+
chooseImage(option: chooseImage.Option): Promise<chooseImage.SuccessCallbackResult>
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* 裁剪图片接口
|
|
453
|
+
* @supported weapp
|
|
454
|
+
* @example
|
|
455
|
+
* ```tsx
|
|
456
|
+
* Taro.cropImage({
|
|
457
|
+
* src: '', // 图片路径
|
|
458
|
+
* cropScale: '1:1', // 裁剪比例
|
|
459
|
+
* success: function (res) {
|
|
460
|
+
* // 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片
|
|
461
|
+
* var tempFilePaths = res.tempFilePaths
|
|
462
|
+
* }
|
|
463
|
+
* })
|
|
464
|
+
* ```
|
|
465
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.cropImage.html
|
|
466
|
+
*/
|
|
467
|
+
cropImage(option: cropImage.Option): Promise<cropImage.SuccessCallbackResult>
|
|
468
|
+
}
|
|
469
|
+
}
|