@tarojs/taro-h5 3.5.0-alpha.13 → 3.5.0-alpha.16
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/dist/api/ad/index.d.ts +6 -0
- package/dist/api/ai/facial.d.ts +9 -0
- package/dist/api/ai/index.d.ts +2 -0
- package/dist/api/ai/visual.d.ts +6 -0
- package/dist/api/alipay/index.d.ts +3 -0
- package/dist/api/base/crypto.d.ts +3 -0
- package/dist/api/base/debug.d.ts +9 -0
- package/dist/api/base/index.d.ts +12 -0
- package/dist/api/base/performance.d.ts +6 -0
- package/dist/api/base/system.d.ts +27 -0
- package/dist/api/base/system.js +2 -2
- package/dist/api/base/update.d.ts +6 -0
- package/dist/api/base/weapp/app-event.d.ts +41 -0
- package/dist/api/base/weapp/app-event.js +55 -4
- package/dist/api/base/weapp/life-cycle.d.ts +6 -0
- package/dist/api/canvas/CanvasContext.d.ts +104 -0
- package/dist/api/canvas/canvasGetImageData.d.ts +5 -0
- package/dist/api/canvas/canvasPutImageData.d.ts +6 -0
- package/dist/api/canvas/canvasToTempFilePath.d.ts +6 -0
- package/dist/api/canvas/canvasToTempFilePath.js +1 -1
- package/dist/api/canvas/createCanvasContext.d.ts +5 -0
- package/dist/api/canvas/index.d.ts +12 -0
- package/dist/api/cloud/index.d.ts +31 -0
- package/dist/api/data-analysis/index.d.ts +12 -0
- package/dist/api/device/accelerometer.d.ts +17 -0
- package/dist/api/device/accessibility.d.ts +3 -0
- package/dist/api/device/battery.d.ts +5 -0
- package/dist/api/device/bluetooth-ble.d.ts +48 -0
- package/dist/api/device/bluetooth-peripheral.d.ts +9 -0
- package/dist/api/device/bluetooth.d.ts +39 -0
- package/dist/api/device/calendar.d.ts +6 -0
- package/dist/api/device/clipboard.d.ts +15 -0
- package/dist/api/device/compass.d.ts +17 -0
- package/dist/api/device/contact.d.ts +6 -0
- package/dist/api/device/crypto.d.ts +3 -0
- package/dist/api/device/gyroscope.d.ts +12 -0
- package/dist/api/device/iBeacon.d.ts +21 -0
- package/dist/api/device/index.d.ts +23 -0
- package/dist/api/device/keyboard.d.ts +12 -0
- package/dist/api/device/memory.d.ts +6 -0
- package/dist/api/device/motion.d.ts +17 -0
- package/dist/api/device/network.d.ts +20 -0
- package/dist/api/device/nfc.d.ts +21 -0
- package/dist/api/device/phone.d.ts +2 -0
- package/dist/api/device/scan.d.ts +3 -0
- package/dist/api/device/screen.d.ts +18 -0
- package/dist/api/device/vibrate.d.ts +9 -0
- package/dist/api/device/vibrate.js +5 -7
- package/dist/api/device/wifi.d.ts +33 -0
- package/dist/api/ext/index.d.ts +6 -0
- package/dist/api/files/index.d.ts +24 -0
- package/dist/api/framework/index.d.ts +4 -0
- package/dist/api/index.d.ts +24 -0
- package/dist/api/location/chooseLocation.d.ts +6 -0
- package/dist/api/location/getLocation.d.ts +2 -0
- package/dist/api/location/index.d.ts +32 -0
- package/dist/api/location/index.js +1 -0
- package/dist/api/media/EditorContext.d.ts +42 -0
- package/dist/api/media/audio/InnerAudioContext.d.ts +58 -0
- package/dist/api/media/audio/InnerAudioContext.js +1 -1
- package/dist/api/media/audio/index.d.ts +29 -0
- package/dist/api/media/background-audio/BackgroundAudioManager.d.ts +71 -0
- package/dist/api/media/background-audio/index.d.ts +29 -0
- package/dist/api/media/camera.d.ts +3 -0
- package/dist/api/media/image/chooseImage.d.ts +5 -0
- package/dist/api/media/image/getImageInfo.d.ts +5 -0
- package/dist/api/media/image/index.d.ts +15 -0
- package/dist/api/media/image/previewImage.d.ts +8 -0
- package/dist/api/media/index.d.ts +12 -0
- package/dist/api/media/live.d.ts +6 -0
- package/dist/api/media/map.d.ts +3 -0
- package/dist/api/media/media-recorder.d.ts +3 -0
- package/dist/api/media/recorder.d.ts +9 -0
- package/dist/api/media/video/index.d.ts +24 -0
- package/dist/api/media/video-decoder.d.ts +3 -0
- package/dist/api/media/video-processing.d.ts +3 -0
- package/dist/api/media/voip.d.ts +42 -0
- package/dist/api/navigate/index.d.ts +12 -0
- package/dist/api/network/download.d.ts +6 -0
- package/dist/api/network/download.js +1 -0
- package/dist/api/network/index.d.ts +7 -0
- package/dist/api/network/mdns.d.ts +30 -0
- package/dist/api/network/request/index.d.ts +4 -0
- package/dist/api/network/tcp.d.ts +3 -0
- package/dist/api/network/udp.d.ts +3 -0
- package/dist/api/network/upload.d.ts +5 -0
- package/dist/api/network/upload.js +2 -1
- package/{src/api/network/utils.ts → dist/api/network/utils.d.ts} +44 -71
- package/dist/api/network/utils.js +1 -0
- package/dist/api/network/websocket/index.d.ts +7 -0
- package/dist/api/network/websocket/socketTask.d.ts +25 -0
- package/dist/api/open-api/account.d.ts +3 -0
- package/dist/api/open-api/address.d.ts +3 -0
- package/dist/api/open-api/authorize.d.ts +6 -0
- package/dist/api/open-api/card.d.ts +6 -0
- package/dist/api/open-api/channels-live.d.ts +18 -0
- package/dist/api/open-api/customer-service.d.ts +3 -0
- package/dist/api/open-api/facial.d.ts +12 -0
- package/dist/api/open-api/favorites.d.ts +6 -0
- package/dist/api/open-api/group.d.ts +3 -0
- package/dist/api/open-api/index.d.ts +18 -0
- package/dist/api/open-api/invoice.d.ts +6 -0
- package/dist/api/open-api/license-plate.d.ts +3 -0
- package/dist/api/open-api/login.d.ts +9 -0
- package/dist/api/open-api/red-package.d.ts +3 -0
- package/dist/api/open-api/settings.d.ts +6 -0
- package/dist/api/open-api/soter.d.ts +9 -0
- package/dist/api/open-api/subscribe-message.d.ts +3 -0
- package/dist/api/open-api/user-info.d.ts +6 -0
- package/dist/api/open-api/werun.d.ts +6 -0
- package/dist/api/payment/index.d.ts +6 -0
- package/dist/api/route/index.d.ts +1 -0
- package/dist/api/share/index.d.ts +30 -0
- package/dist/api/storage/background-fetch.d.ts +12 -0
- package/dist/api/storage/index.d.ts +18 -0
- package/dist/api/swan/index.d.ts +63 -0
- package/dist/api/taro.d.ts +12 -0
- package/dist/api/ui/animation/index.d.ts +2 -0
- package/dist/api/ui/background.d.ts +6 -0
- package/dist/api/ui/custom-component.d.ts +1 -0
- package/dist/api/ui/fonts.d.ts +2 -0
- package/dist/api/ui/index.d.ts +12 -0
- package/dist/api/ui/interaction/actionSheet.d.ts +61 -0
- package/dist/api/ui/interaction/index.d.ts +14 -0
- package/dist/api/ui/interaction/modal.d.ts +69 -0
- package/dist/api/ui/interaction/modal.js +1 -0
- package/dist/api/ui/interaction/toast.d.ts +85 -0
- package/dist/api/ui/menu.d.ts +3 -0
- package/dist/api/ui/navigation-bar/index.d.ts +15 -0
- package/dist/api/ui/navigation-bar/index.js +2 -3
- package/dist/api/ui/pull-down-refresh.d.ts +9 -0
- package/dist/api/ui/scroll/index.d.ts +5 -0
- package/dist/api/ui/sticky.d.ts +3 -0
- package/dist/api/ui/tab-bar.d.ts +34 -0
- package/dist/api/ui/window.d.ts +15 -0
- package/dist/api/worker/index.d.ts +3 -0
- package/dist/api/wxml/index.d.ts +5 -0
- package/dist/api/wxml/nodesRef.d.ts +13 -0
- package/dist/api/wxml/selectorQuery.d.ts +24 -0
- package/dist/api/wxml/selectorQuery.js +1 -1
- package/dist/index.cjs.d.ts +1373 -0
- package/dist/index.cjs.js +105 -81
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.esm.d.ts +1373 -0
- package/dist/index.esm.js +93 -69
- package/dist/index.esm.js.map +1 -1
- package/dist/taroApis.d.ts +1364 -0
- package/dist/taroApis.js +1 -1
- package/dist/utils/animation.d.ts +6 -0
- package/dist/utils/handler.d.ts +48 -0
- package/dist/utils/index.d.ts +39 -0
- package/dist/utils/index.js +3 -7
- package/dist/utils/lodash.d.ts +2 -0
- package/dist/utils/valid.d.ts +2 -0
- package/package.json +17 -19
- package/types/api.d.ts +4 -0
- package/types/define.d.ts +2 -0
- package/types/index.d.ts +33 -0
- package/types/overlay.d.ts +9 -0
- package/LICENSE +0 -21
- package/src/api/ad/index.ts +0 -5
- package/src/api/ai/facial.ts +0 -6
- package/src/api/ai/index.ts +0 -2
- package/src/api/ai/visual.ts +0 -7
- package/src/api/alipay/index.ts +0 -4
- package/src/api/base/crypto.ts +0 -4
- package/src/api/base/debug.ts +0 -5
- package/src/api/base/index.ts +0 -23
- package/src/api/base/performance.ts +0 -5
- package/src/api/base/system.ts +0 -207
- package/src/api/base/update.ts +0 -5
- package/src/api/base/weapp/app-event.ts +0 -19
- package/src/api/base/weapp/life-cycle.ts +0 -5
- package/src/api/canvas/CanvasContext.ts +0 -233
- package/src/api/canvas/canvasGetImageData.ts +0 -28
- package/src/api/canvas/canvasPutImageData.ts +0 -25
- package/src/api/canvas/canvasToTempFilePath.ts +0 -25
- package/src/api/canvas/createCanvasContext.ts +0 -19
- package/src/api/canvas/index.ts +0 -18
- package/src/api/cloud/index.ts +0 -32
- package/src/api/data-analysis/index.ts +0 -6
- package/src/api/device/accelerometer.ts +0 -79
- package/src/api/device/accessibility.ts +0 -4
- package/src/api/device/battery.ts +0 -23
- package/src/api/device/bluetooth-ble.ts +0 -19
- package/src/api/device/bluetooth-peripheral.ts +0 -6
- package/src/api/device/bluetooth.ts +0 -16
- package/src/api/device/calendar.ts +0 -5
- package/src/api/device/clipboard.ts +0 -68
- package/src/api/device/compass.ts +0 -83
- package/src/api/device/contact.ts +0 -5
- package/src/api/device/crypto.ts +0 -4
- package/src/api/device/gyroscope.ts +0 -7
- package/src/api/device/iBeacon.ts +0 -10
- package/src/api/device/index.ts +0 -23
- package/src/api/device/keyboard.ts +0 -7
- package/src/api/device/memory.ts +0 -5
- package/src/api/device/motion.ts +0 -77
- package/src/api/device/network.ts +0 -90
- package/src/api/device/nfc.ts +0 -10
- package/src/api/device/phone.ts +0 -31
- package/src/api/device/scan.ts +0 -11
- package/src/api/device/screen.ts +0 -9
- package/src/api/device/vibrate.ts +0 -37
- package/src/api/device/wifi.ts +0 -14
- package/src/api/ext/index.ts +0 -5
- package/src/api/files/index.ts +0 -11
- package/src/api/framework/index.ts +0 -10
- package/src/api/index.ts +0 -24
- package/src/api/location/chooseLocation.ts +0 -117
- package/src/api/location/getLocation.ts +0 -81
- package/src/api/location/index.ts +0 -22
- package/src/api/location/style.css +0 -79
- package/src/api/media/EditorContext.ts +0 -32
- package/src/api/media/audio/InnerAudioContext.ts +0 -99
- package/src/api/media/audio/index.ts +0 -21
- package/src/api/media/background-audio/BackgroundAudioManager.ts +0 -104
- package/src/api/media/background-audio/index.ts +0 -17
- package/src/api/media/camera.ts +0 -4
- package/src/api/media/image/chooseImage.ts +0 -95
- package/src/api/media/image/getImageInfo.ts +0 -50
- package/src/api/media/image/index.ts +0 -13
- package/src/api/media/image/previewImage.ts +0 -80
- package/src/api/media/index.ts +0 -12
- package/src/api/media/live.ts +0 -5
- package/src/api/media/map.ts +0 -4
- package/src/api/media/media-recorder.ts +0 -4
- package/src/api/media/recorder.ts +0 -6
- package/src/api/media/video/index.ts +0 -82
- package/src/api/media/video-decoder.ts +0 -4
- package/src/api/media/video-processing.ts +0 -4
- package/src/api/media/voip.ts +0 -17
- package/src/api/navigate/index.ts +0 -7
- package/src/api/network/download.ts +0 -141
- package/src/api/network/index.ts +0 -7
- package/src/api/network/mdns.ts +0 -13
- package/src/api/network/request/index.ts +0 -135
- package/src/api/network/tcp.ts +0 -4
- package/src/api/network/udp.ts +0 -4
- package/src/api/network/upload.ts +0 -169
- package/src/api/network/websocket/index.ts +0 -88
- package/src/api/network/websocket/socketTask.ts +0 -89
- package/src/api/open-api/account.ts +0 -4
- package/src/api/open-api/address.ts +0 -4
- package/src/api/open-api/authorize.ts +0 -5
- package/src/api/open-api/card.ts +0 -5
- package/src/api/open-api/channels-live.ts +0 -9
- package/src/api/open-api/customer-service.ts +0 -4
- package/src/api/open-api/facial.ts +0 -7
- package/src/api/open-api/favorites.ts +0 -5
- package/src/api/open-api/group.ts +0 -4
- package/src/api/open-api/index.ts +0 -18
- package/src/api/open-api/invoice.ts +0 -5
- package/src/api/open-api/license-plate.ts +0 -4
- package/src/api/open-api/login.ts +0 -6
- package/src/api/open-api/red-package.ts +0 -4
- package/src/api/open-api/settings.ts +0 -5
- package/src/api/open-api/soter.ts +0 -6
- package/src/api/open-api/subscribe-message.ts +0 -4
- package/src/api/open-api/user-info.ts +0 -5
- package/src/api/open-api/werun.ts +0 -5
- package/src/api/payment/index.ts +0 -5
- package/src/api/route/index.ts +0 -10
- package/src/api/share/index.ts +0 -13
- package/src/api/storage/background-fetch.ts +0 -7
- package/src/api/storage/index.ts +0 -182
- package/src/api/swan/index.ts +0 -31
- package/src/api/taro.ts +0 -84
- package/src/api/ui/animation/index.ts +0 -356
- package/src/api/ui/background.ts +0 -5
- package/src/api/ui/custom-component.ts +0 -4
- package/src/api/ui/fonts.ts +0 -64
- package/src/api/ui/index.ts +0 -12
- package/src/api/ui/interaction/actionSheet.ts +0 -212
- package/src/api/ui/interaction/index.ts +0 -302
- package/src/api/ui/interaction/modal.ts +0 -237
- package/src/api/ui/interaction/toast.ts +0 -220
- package/src/api/ui/menu.ts +0 -4
- package/src/api/ui/navigation-bar/index.ts +0 -52
- package/src/api/ui/pull-down-refresh.ts +0 -28
- package/src/api/ui/scroll/index.ts +0 -85
- package/src/api/ui/sticky.ts +0 -4
- package/src/api/ui/tab-bar.ts +0 -327
- package/src/api/ui/window.ts +0 -38
- package/src/api/worker/index.ts +0 -4
- package/src/api/wxml/index.ts +0 -10
- package/src/api/wxml/nodesRef.ts +0 -56
- package/src/api/wxml/selectorQuery.ts +0 -220
- package/src/index.ts +0 -6
- package/src/utils/animation.ts +0 -15
- package/src/utils/handler.ts +0 -105
- package/src/utils/index.ts +0 -184
- package/src/utils/lodash.ts +0 -30
- package/src/utils/valid.ts +0 -8
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import Taro from '@tarojs/api'
|
|
2
|
-
|
|
3
|
-
import { processOpenApi, shouldBeObject } from '../../utils'
|
|
4
|
-
import { MethodHandler } from '../../utils/handler'
|
|
5
|
-
|
|
6
|
-
const getLocationByW3CApi: (options: Taro.getLocation.Option) => Promise<Taro.getLocation.SuccessCallbackResult> = (options: Taro.getLocation.Option): Promise<Taro.getLocation.SuccessCallbackResult> => {
|
|
7
|
-
// 断言 options 必须是 Object
|
|
8
|
-
const isObject = shouldBeObject(options)
|
|
9
|
-
if (!isObject.flag) {
|
|
10
|
-
const res = { errMsg: `getLocation:fail ${isObject.msg}` }
|
|
11
|
-
console.error(res.errMsg)
|
|
12
|
-
return Promise.reject(res)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// 解构回调函数
|
|
16
|
-
const { success, fail, complete } = options
|
|
17
|
-
|
|
18
|
-
const handle = new MethodHandler({ name: 'getLocation', success, fail, complete })
|
|
19
|
-
|
|
20
|
-
// const defaultMaximumAge = 5 * 1000
|
|
21
|
-
|
|
22
|
-
const positionOptions: PositionOptions = {
|
|
23
|
-
enableHighAccuracy: options.isHighAccuracy || (options.altitude != null), // 海拔定位需要高精度
|
|
24
|
-
// maximumAge: defaultMaximumAge, // 允许取多久以内的缓存位置
|
|
25
|
-
timeout: options.highAccuracyExpireTime // 高精度定位超时时间
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Web端API实现暂时仅支持GPS坐标系
|
|
29
|
-
if (options.type?.toUpperCase() !== 'WGS84') {
|
|
30
|
-
return handle.fail({
|
|
31
|
-
errMsg: 'This coordinate system type is not temporarily supported'
|
|
32
|
-
})
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// 判断当前浏览器是否支持位置API
|
|
36
|
-
const geolocationSupported = navigator.geolocation
|
|
37
|
-
|
|
38
|
-
if (!geolocationSupported) {
|
|
39
|
-
return handle.fail({
|
|
40
|
-
errMsg: 'The current browser does not support this feature'
|
|
41
|
-
})
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// 开始获取位置
|
|
45
|
-
return new Promise<Taro.getLocation.SuccessCallbackResult>(
|
|
46
|
-
(resolve, reject) => {
|
|
47
|
-
navigator.geolocation.getCurrentPosition(
|
|
48
|
-
(position) => {
|
|
49
|
-
const result: Taro.getLocation.SuccessCallbackResult = {
|
|
50
|
-
/** 位置的精确度 */
|
|
51
|
-
accuracy: position.coords.accuracy,
|
|
52
|
-
/** 高度,单位 m */
|
|
53
|
-
altitude: position.coords.altitude!,
|
|
54
|
-
/** 水平精度,单位 m */
|
|
55
|
-
horizontalAccuracy: position.coords.accuracy,
|
|
56
|
-
/** 纬度,范围为 -90~90,负数表示南纬 */
|
|
57
|
-
latitude: position.coords.latitude,
|
|
58
|
-
/** 经度,范围为 -180~180,负数表示西经 */
|
|
59
|
-
longitude: position.coords.longitude,
|
|
60
|
-
/** 速度,单位 m/s */
|
|
61
|
-
speed: position.coords.speed!,
|
|
62
|
-
/** 垂直精度,单位 m(Android 无法获取,返回 0) */
|
|
63
|
-
verticalAccuracy: position.coords.altitudeAccuracy || 0,
|
|
64
|
-
/** 调用结果,自动补充 */
|
|
65
|
-
errMsg: ''
|
|
66
|
-
}
|
|
67
|
-
handle.success(result, resolve)
|
|
68
|
-
},
|
|
69
|
-
(error) => {
|
|
70
|
-
handle.fail({ errMsg: error.message }, reject)
|
|
71
|
-
},
|
|
72
|
-
positionOptions
|
|
73
|
-
)
|
|
74
|
-
}
|
|
75
|
-
)
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export const getLocation = processOpenApi({
|
|
79
|
-
name: 'getLocation',
|
|
80
|
-
standardMethod: getLocationByW3CApi
|
|
81
|
-
})
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { processOpenApi, temporarilyNotSupport } from '../../utils/index'
|
|
2
|
-
|
|
3
|
-
// 位置
|
|
4
|
-
export const stopLocationUpdate = temporarilyNotSupport('stopLocationUpdate')
|
|
5
|
-
export const startLocationUpdateBackground = temporarilyNotSupport('startLocationUpdateBackground')
|
|
6
|
-
export const startLocationUpdate = temporarilyNotSupport('startLocationUpdate')
|
|
7
|
-
|
|
8
|
-
export const openLocation = processOpenApi({
|
|
9
|
-
name: 'openLocation',
|
|
10
|
-
defaultOptions: { scale: 18 }
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
export const onLocationChangeError = temporarilyNotSupport('onLocationChangeError')
|
|
14
|
-
export const onLocationChange = temporarilyNotSupport('onLocationChange')
|
|
15
|
-
export const offLocationChangeError = temporarilyNotSupport('offLocationChangeError')
|
|
16
|
-
export const offLocationChange = temporarilyNotSupport('offLocationChange')
|
|
17
|
-
|
|
18
|
-
export { getLocation } from './getLocation'
|
|
19
|
-
|
|
20
|
-
export const choosePoi = temporarilyNotSupport('choosePoi')
|
|
21
|
-
|
|
22
|
-
export { chooseLocation } from './chooseLocation'
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
.taro_choose_location {
|
|
2
|
-
position: fixed;
|
|
3
|
-
display: flex;
|
|
4
|
-
flex-direction: column;
|
|
5
|
-
width: 100%;
|
|
6
|
-
height: 100%;
|
|
7
|
-
top: 100%;
|
|
8
|
-
background-color: #fff;
|
|
9
|
-
transition: ease top .3s;
|
|
10
|
-
z-index: 1;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.taro_choose_location_bar {
|
|
14
|
-
display: flex;
|
|
15
|
-
flex: 0 95px;
|
|
16
|
-
height: 95px;
|
|
17
|
-
background-color: #ededed;
|
|
18
|
-
color: #090909;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.taro_choose_location_back {
|
|
22
|
-
flex: 0 45px;
|
|
23
|
-
position: relative;
|
|
24
|
-
width: 33px;
|
|
25
|
-
height: 30px;
|
|
26
|
-
margin-top: 30px;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.taro_choose_location_back::before {
|
|
30
|
-
content: '';
|
|
31
|
-
position: absolute;
|
|
32
|
-
top: 0;
|
|
33
|
-
left: 0;
|
|
34
|
-
display: block;
|
|
35
|
-
width: 0;
|
|
36
|
-
height: 0;
|
|
37
|
-
border: solid 15px;
|
|
38
|
-
border-top-color: transparent;
|
|
39
|
-
border-right-color: #090909;
|
|
40
|
-
border-bottom-color: transparent;
|
|
41
|
-
border-left-color: transparent;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.taro_choose_location_back::after {
|
|
45
|
-
content: '';
|
|
46
|
-
position: absolute;
|
|
47
|
-
display: block;
|
|
48
|
-
width: 0;
|
|
49
|
-
height: 0;
|
|
50
|
-
top: 0;
|
|
51
|
-
left: 3px;
|
|
52
|
-
border: solid 15px;
|
|
53
|
-
border-top-color: transparent;
|
|
54
|
-
border-right-color: #ededed;
|
|
55
|
-
border-bottom-color: transparent;
|
|
56
|
-
border-left-color: transparent;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.taro_choose_location_title {
|
|
60
|
-
flex: 1;
|
|
61
|
-
line-height: 95px;
|
|
62
|
-
padding-left: 30px;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.taro_choose_location_submit {
|
|
66
|
-
width: 110px;
|
|
67
|
-
height: 60px;
|
|
68
|
-
color: #fff;
|
|
69
|
-
background-color: #08bf62;
|
|
70
|
-
border: none;
|
|
71
|
-
font-size: 28px;
|
|
72
|
-
line-height: 60px;
|
|
73
|
-
padding: 0;
|
|
74
|
-
margin: 18px 30px 0 0;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
.taro_choose_location_frame {
|
|
78
|
-
flex: 1;
|
|
79
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import Taro from '@tarojs/api'
|
|
2
|
-
|
|
3
|
-
import { temporarilyNotSupport } from '../../utils'
|
|
4
|
-
|
|
5
|
-
// 富文本
|
|
6
|
-
export class EditorContext implements Taro.EditorContext {
|
|
7
|
-
blur = temporarilyNotSupport('EditorContext.blur')
|
|
8
|
-
|
|
9
|
-
clear = temporarilyNotSupport('EditorContext.clear')
|
|
10
|
-
|
|
11
|
-
format = temporarilyNotSupport('EditorContext.format')
|
|
12
|
-
|
|
13
|
-
getContents = temporarilyNotSupport('EditorContext.getContents')
|
|
14
|
-
|
|
15
|
-
getSelectionText = temporarilyNotSupport('EditorContext.getSelectionText')
|
|
16
|
-
|
|
17
|
-
insertDivider = temporarilyNotSupport('EditorContext.insertDivider')
|
|
18
|
-
|
|
19
|
-
insertImage = temporarilyNotSupport('EditorContext.insertImage')
|
|
20
|
-
|
|
21
|
-
insertText = temporarilyNotSupport('EditorContext.insertText')
|
|
22
|
-
|
|
23
|
-
redo = temporarilyNotSupport('EditorContext.redo')
|
|
24
|
-
|
|
25
|
-
removeFormat = temporarilyNotSupport('EditorContext.removeFormat')
|
|
26
|
-
|
|
27
|
-
scrollIntoView = temporarilyNotSupport('EditorContext.scrollIntoView')
|
|
28
|
-
|
|
29
|
-
setContents = temporarilyNotSupport('EditorContext.setContents')
|
|
30
|
-
|
|
31
|
-
undo = temporarilyNotSupport('EditorContext.undo')
|
|
32
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import Taro from '@tarojs/api'
|
|
2
|
-
|
|
3
|
-
import { permanentlyNotSupport } from '../../../utils'
|
|
4
|
-
import { CallbackManager } from '../../../utils/handler'
|
|
5
|
-
|
|
6
|
-
export class InnerAudioContext implements Taro.InnerAudioContext {
|
|
7
|
-
Instance?: HTMLAudioElement
|
|
8
|
-
errorStack: CallbackManager
|
|
9
|
-
stopStack: CallbackManager
|
|
10
|
-
__startTime = 0
|
|
11
|
-
|
|
12
|
-
constructor () {
|
|
13
|
-
this.Instance = new Audio()
|
|
14
|
-
this.errorStack = new CallbackManager()
|
|
15
|
-
this.stopStack = new CallbackManager()
|
|
16
|
-
|
|
17
|
-
Taro.eventCenter.on('__taroRouterChange', () => { this.stop() })
|
|
18
|
-
this.onPlay(() => {
|
|
19
|
-
if (this.currentTime !== this.startTime) {
|
|
20
|
-
this.seek(this.startTime)
|
|
21
|
-
}
|
|
22
|
-
})
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
set autoplay (e) { this.setProperty('autoplay', e) }
|
|
26
|
-
get autoplay () { return this.Instance?.autoplay || false }
|
|
27
|
-
get buffered () { return this.Instance?.buffered.length || 0 }
|
|
28
|
-
get currentTime () { return this.Instance?.currentTime || 0 }
|
|
29
|
-
get duration () { return this.Instance?.duration || 0 }
|
|
30
|
-
set loop (e) { this.setProperty('loop', e) }
|
|
31
|
-
get loop () { return this.Instance?.loop || false }
|
|
32
|
-
get paused () { return this.Instance?.paused || true }
|
|
33
|
-
set src (e) { this.setProperty('src', e) }
|
|
34
|
-
get src () { return this.Instance?.src || '' }
|
|
35
|
-
set volume (e) { this.setProperty('volume', e) }
|
|
36
|
-
get volume () { return this.Instance?.volume || 0 }
|
|
37
|
-
set playbackRate (e) { this.setProperty('playbackRate', e) }
|
|
38
|
-
get playbackRate () { return this.Instance?.playbackRate || 0 }
|
|
39
|
-
set obeyMuteSwitch (_e) { permanentlyNotSupport('InnerAudioContext.obeyMuteSwitch')() }
|
|
40
|
-
get obeyMuteSwitch () { return true }
|
|
41
|
-
set startTime (e) { this.__startTime = e }
|
|
42
|
-
get startTime () { return this.__startTime || 0 }
|
|
43
|
-
set referrerPolicy (e) { this.Instance?.setAttribute('referrerpolicy', e) }
|
|
44
|
-
get referrerPolicy () { return this.Instance?.getAttribute('referrerpolicy') || 'origin' }
|
|
45
|
-
|
|
46
|
-
private setProperty (key: string, value: unknown) {
|
|
47
|
-
if (this.Instance) {
|
|
48
|
-
this.Instance[key] = value
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
play = () => this.Instance?.play()
|
|
53
|
-
|
|
54
|
-
pause = () => this.Instance?.pause()
|
|
55
|
-
|
|
56
|
-
stop = () => {
|
|
57
|
-
this.pause()
|
|
58
|
-
this.seek(0)
|
|
59
|
-
this.stopStack.trigger()
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
seek = (position: number) => {
|
|
63
|
-
if (this.Instance) {
|
|
64
|
-
this.Instance.currentTime = position
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* @TODO destroy得并不干净
|
|
70
|
-
*/
|
|
71
|
-
destroy = () => {
|
|
72
|
-
this.stop()
|
|
73
|
-
if (this.Instance) {
|
|
74
|
-
document.body.removeChild(this.Instance)
|
|
75
|
-
this.Instance = undefined
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
onCanplay = (callback = () => {}) => this.Instance?.addEventListener('canplay', callback)
|
|
80
|
-
onPlay = (callback = () => {}) => this.Instance?.addEventListener('play', callback)
|
|
81
|
-
onPause = (callback = () => {}) => this.Instance?.addEventListener('pause', callback)
|
|
82
|
-
onStop = (callback = () => {}) => this.stopStack.add(callback)
|
|
83
|
-
onEnded = (callback = () => {}) => this.Instance?.addEventListener('ended', callback)
|
|
84
|
-
onTimeUpdate = (callback = () => {}) => this.Instance?.addEventListener('timeupdate', callback)
|
|
85
|
-
onError = (callback?: ((res: Taro.InnerAudioContext.onErrorDetail) => void)) => this.errorStack.add(callback)
|
|
86
|
-
onWaiting = (callback = () => {}) => this.Instance?.addEventListener('waiting', callback)
|
|
87
|
-
onSeeking = (callback = () => {}) => this.Instance?.addEventListener('seeking', callback)
|
|
88
|
-
onSeeked = (callback = () => {}) => this.Instance?.addEventListener('seeked', callback)
|
|
89
|
-
offCanplay = (callback = () => {}) => this.Instance?.removeEventListener('canplay', callback)
|
|
90
|
-
offPlay = (callback = () => {}) => this.Instance?.removeEventListener('play', callback)
|
|
91
|
-
offPause = (callback = () => {}) => this.Instance?.removeEventListener('pause', callback)
|
|
92
|
-
offStop = (callback = () => {}) => this.stopStack.remove(callback)
|
|
93
|
-
offEnded = (callback = () => {}) => this.Instance?.removeEventListener('ended', callback)
|
|
94
|
-
offTimeUpdate = (callback = () => {}) => this.Instance?.removeEventListener('timeupdate', callback)
|
|
95
|
-
offError = (callback = () => {}) => this.errorStack.remove(callback)
|
|
96
|
-
offWaiting = (callback = () => {}) => this.Instance?.removeEventListener('waiting', callback)
|
|
97
|
-
offSeeking = (callback = () => {}) => this.Instance?.removeEventListener('seeking', callback)
|
|
98
|
-
offSeeked = (callback = () => {}) => this.Instance?.removeEventListener('seeked', callback)
|
|
99
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import Taro from '@tarojs/api'
|
|
2
|
-
|
|
3
|
-
import { temporarilyNotSupport } from '../../../utils'
|
|
4
|
-
import { InnerAudioContext } from './InnerAudioContext'
|
|
5
|
-
|
|
6
|
-
// 音频
|
|
7
|
-
|
|
8
|
-
export const stopVoice = temporarilyNotSupport('stopVoice')
|
|
9
|
-
export const setInnerAudioOption = temporarilyNotSupport('setInnerAudioOption')
|
|
10
|
-
export const playVoice = temporarilyNotSupport('playVoice')
|
|
11
|
-
export const pauseVoice = temporarilyNotSupport('pauseVoice')
|
|
12
|
-
export const getAvailableAudioSources = temporarilyNotSupport('getAvailableAudioSources')
|
|
13
|
-
export const createWebAudioContext = temporarilyNotSupport('createWebAudioContext')
|
|
14
|
-
export const createMediaAudioPlayer = temporarilyNotSupport('createMediaAudioPlayer')
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* 创建内部 audio 上下文 InnerAudioContext 对象。
|
|
18
|
-
*/
|
|
19
|
-
export const createInnerAudioContext: typeof Taro.createInnerAudioContext = () => new InnerAudioContext()
|
|
20
|
-
|
|
21
|
-
export const createAudioContext = temporarilyNotSupport('createAudioContext')
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import Taro from '@tarojs/api'
|
|
2
|
-
|
|
3
|
-
import { permanentlyNotSupport } from '../../../utils'
|
|
4
|
-
import { CallbackManager } from '../../../utils/handler'
|
|
5
|
-
|
|
6
|
-
export class BackgroundAudioManager implements Taro.BackgroundAudioManager {
|
|
7
|
-
Instance?: HTMLAudioElement
|
|
8
|
-
errorStack: CallbackManager
|
|
9
|
-
stopStack: CallbackManager
|
|
10
|
-
__startTime = 0
|
|
11
|
-
|
|
12
|
-
constructor () {
|
|
13
|
-
this.Instance = new Audio()
|
|
14
|
-
this.errorStack = new CallbackManager()
|
|
15
|
-
this.stopStack = new CallbackManager()
|
|
16
|
-
this.Instance.autoplay = true
|
|
17
|
-
this.onPlay(() => {
|
|
18
|
-
if (this.currentTime !== this.startTime) {
|
|
19
|
-
this.seek(this.startTime)
|
|
20
|
-
}
|
|
21
|
-
})
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
set src (e) { this.setProperty('src', e) }
|
|
25
|
-
get src () { return this.Instance?.src || '' }
|
|
26
|
-
set startTime (e) { this.__startTime = e }
|
|
27
|
-
get startTime () { return this.__startTime || 0 }
|
|
28
|
-
set title (e) { this.dataset('title', e) }
|
|
29
|
-
get title () { return this.Instance?.dataset.title || '' }
|
|
30
|
-
set epname (e) { this.dataset('epname', e) }
|
|
31
|
-
get epname () { return this.Instance?.dataset.epname || '' }
|
|
32
|
-
set singer (e) { this.dataset('singer', e) }
|
|
33
|
-
get singer () { return this.Instance?.dataset.singer || '' }
|
|
34
|
-
set coverImgUrl (e) { this.dataset('coverImgUrl', e) }
|
|
35
|
-
get coverImgUrl () { return this.Instance?.dataset.coverImgUrl || '' }
|
|
36
|
-
set webUrl (e) { this.dataset('webUrl', e) }
|
|
37
|
-
get webUrl () { return this.Instance?.dataset.webUrl || '' }
|
|
38
|
-
set protocol (e) { this.dataset('protocol', e) }
|
|
39
|
-
get protocol () { return this.Instance?.dataset.protocol || '' }
|
|
40
|
-
set playbackRate (e) { this.setProperty('playbackRate', e) }
|
|
41
|
-
get playbackRate () { return this.Instance?.playbackRate || 0 }
|
|
42
|
-
get duration () { return this.Instance?.duration || 0 }
|
|
43
|
-
get currentTime () { return this.Instance?.currentTime || 0 }
|
|
44
|
-
get paused () { return this.Instance?.paused || false }
|
|
45
|
-
get buffered () { return this.Instance?.buffered.length || 0 }
|
|
46
|
-
set referrerPolicy (e) { this.Instance?.setAttribute('referrerpolicy', e) }
|
|
47
|
-
get referrerPolicy () { return this.Instance?.getAttribute('referrerpolicy') || 'origin' }
|
|
48
|
-
|
|
49
|
-
private setProperty (key: string, value: unknown) {
|
|
50
|
-
if (this.Instance) {
|
|
51
|
-
this.Instance[key] = value
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
private dataset (key: string, value: string) {
|
|
56
|
-
if (this.Instance) {
|
|
57
|
-
this.Instance.dataset[key] = value
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
play = () => this.Instance?.play()
|
|
62
|
-
|
|
63
|
-
pause = () => this.Instance?.pause()
|
|
64
|
-
|
|
65
|
-
seek = (position: number) => {
|
|
66
|
-
if (this.Instance) {
|
|
67
|
-
this.Instance.currentTime = position
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
stop = () => {
|
|
72
|
-
this.pause()
|
|
73
|
-
this.seek(0)
|
|
74
|
-
this.stopStack.trigger()
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
onCanplay = (callback = () => {}) => this.Instance?.addEventListener('canplay', callback)
|
|
78
|
-
onWaiting = (callback = () => {}) => this.Instance?.addEventListener('waiting', callback)
|
|
79
|
-
onError = (callback?: ((res: Taro.InnerAudioContext.onErrorDetail) => void)) => this.errorStack.add(callback)
|
|
80
|
-
onPlay = (callback = () => {}) => this.Instance?.addEventListener('play', callback)
|
|
81
|
-
onPause = (callback = () => {}) => this.Instance?.addEventListener('pause', callback)
|
|
82
|
-
onSeeking = (callback = () => {}) => this.Instance?.addEventListener('seeking', callback)
|
|
83
|
-
onSeeked = (callback = () => {}) => this.Instance?.addEventListener('seeked', callback)
|
|
84
|
-
|
|
85
|
-
onEnded = (callback = () => {}) => this.Instance?.addEventListener('ended', callback)
|
|
86
|
-
onStop = (callback = () => {}) => this.stopStack.add(callback)
|
|
87
|
-
onTimeUpdate = (callback = () => {}) => this.Instance?.addEventListener('timeupdate', callback)
|
|
88
|
-
onPrev = permanentlyNotSupport('BackgroundAudioManager.onPrev')
|
|
89
|
-
onNext = permanentlyNotSupport('BackgroundAudioManager.onNext')
|
|
90
|
-
|
|
91
|
-
offCanplay = (callback = () => {}) => this.Instance?.removeEventListener('canplay', callback)
|
|
92
|
-
offWaiting = (callback = () => {}) => this.Instance?.removeEventListener('waiting', callback)
|
|
93
|
-
offError = (callback = () => {}) => this.errorStack.remove(callback)
|
|
94
|
-
offPlay = (callback = () => {}) => this.Instance?.removeEventListener('play', callback)
|
|
95
|
-
offPause = (callback = () => {}) => this.Instance?.removeEventListener('pause', callback)
|
|
96
|
-
offSeeking = (callback = () => {}) => this.Instance?.removeEventListener('seeking', callback)
|
|
97
|
-
offSeeked = (callback = () => {}) => this.Instance?.removeEventListener('seeked', callback)
|
|
98
|
-
|
|
99
|
-
offEnded = (callback = () => {}) => this.Instance?.removeEventListener('ended', callback)
|
|
100
|
-
offStop = (callback = () => {}) => this.stopStack.remove(callback)
|
|
101
|
-
offTimeUpdate = (callback = () => {}) => this.Instance?.removeEventListener('timeupdate', callback)
|
|
102
|
-
offPrev = permanentlyNotSupport('BackgroundAudioManager.offPrev')
|
|
103
|
-
offNext = permanentlyNotSupport('BackgroundAudioManager.offNext')
|
|
104
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { temporarilyNotSupport } from '../../../utils'
|
|
2
|
-
import { BackgroundAudioManager } from './BackgroundAudioManager'
|
|
3
|
-
|
|
4
|
-
// 背景音频
|
|
5
|
-
export const stopBackgroundAudio = temporarilyNotSupport('stopBackgroundAudio')
|
|
6
|
-
export const seekBackgroundAudio = temporarilyNotSupport('seekBackgroundAudio')
|
|
7
|
-
export const playBackgroundAudio = temporarilyNotSupport('playBackgroundAudio')
|
|
8
|
-
export const pauseBackgroundAudio = temporarilyNotSupport('pauseBackgroundAudio')
|
|
9
|
-
export const onBackgroundAudioStop = temporarilyNotSupport('onBackgroundAudioStop')
|
|
10
|
-
export const onBackgroundAudioPlay = temporarilyNotSupport('onBackgroundAudioPlay')
|
|
11
|
-
export const onBackgroundAudioPause = temporarilyNotSupport('onBackgroundAudioPause')
|
|
12
|
-
export const getBackgroundAudioPlayerState = temporarilyNotSupport('getBackgroundAudioPlayerState')
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* 获取全局唯一的背景音频管理器
|
|
16
|
-
*/
|
|
17
|
-
export const getBackgroundAudioManager = () => new BackgroundAudioManager()
|
package/src/api/media/camera.ts
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import Taro from '@tarojs/api'
|
|
2
|
-
|
|
3
|
-
import { getParameterError, shouldBeObject } from '../../../utils'
|
|
4
|
-
import { MethodHandler } from '../../../utils/handler'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* 从本地相册选择图片或使用相机拍照。
|
|
8
|
-
*/
|
|
9
|
-
export const chooseImage: typeof Taro.chooseImage = function (options) {
|
|
10
|
-
// options must be an Object
|
|
11
|
-
const isObject = shouldBeObject(options)
|
|
12
|
-
if (!isObject.flag) {
|
|
13
|
-
const res = { errMsg: `chooseImage:fail ${isObject.msg}` }
|
|
14
|
-
console.error(res.errMsg)
|
|
15
|
-
return Promise.reject(res)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const {
|
|
19
|
-
count = 1,
|
|
20
|
-
success,
|
|
21
|
-
fail,
|
|
22
|
-
complete,
|
|
23
|
-
imageId = 'taroChooseImage',
|
|
24
|
-
sourceType = ['album', 'camera']
|
|
25
|
-
} = options
|
|
26
|
-
const handle = new MethodHandler({ name: 'chooseImage', success, fail, complete })
|
|
27
|
-
const res: Partial<Taro.chooseImage.SuccessCallbackResult> = {
|
|
28
|
-
tempFilePaths: [],
|
|
29
|
-
tempFiles: []
|
|
30
|
-
}
|
|
31
|
-
const sourceTypeString = sourceType && sourceType.toString()
|
|
32
|
-
const acceptableSourceType = ['user', 'environment', 'camera']
|
|
33
|
-
|
|
34
|
-
if (count && typeof count !== 'number') {
|
|
35
|
-
res.errMsg = getParameterError({
|
|
36
|
-
para: 'count',
|
|
37
|
-
correct: 'Number',
|
|
38
|
-
wrong: count
|
|
39
|
-
})
|
|
40
|
-
return handle.fail(res)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
let el = document.getElementById(imageId)
|
|
44
|
-
if (!el) {
|
|
45
|
-
const obj = document.createElement('input')
|
|
46
|
-
obj.setAttribute('type', 'file')
|
|
47
|
-
obj.setAttribute('id', imageId)
|
|
48
|
-
if (count > 1) {
|
|
49
|
-
obj.setAttribute('multiple', 'multiple')
|
|
50
|
-
}
|
|
51
|
-
if (acceptableSourceType.indexOf(sourceTypeString) > -1) {
|
|
52
|
-
obj.setAttribute('capture', sourceTypeString)
|
|
53
|
-
}
|
|
54
|
-
obj.setAttribute('accept', 'image/*')
|
|
55
|
-
obj.setAttribute('style', 'position: fixed; top: -4000px; left: -3000px; z-index: -300;')
|
|
56
|
-
document.body.appendChild(obj)
|
|
57
|
-
el = document.getElementById(imageId)
|
|
58
|
-
} else {
|
|
59
|
-
if (count > 1) {
|
|
60
|
-
el.setAttribute('multiple', 'multiple')
|
|
61
|
-
} else {
|
|
62
|
-
el.removeAttribute('multiple')
|
|
63
|
-
}
|
|
64
|
-
if (acceptableSourceType.indexOf(sourceTypeString) > -1) {
|
|
65
|
-
el.setAttribute('capture', sourceTypeString)
|
|
66
|
-
} else {
|
|
67
|
-
el.removeAttribute('capture')
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return new Promise(resolve => {
|
|
72
|
-
const TaroMouseEvents = document.createEvent('MouseEvents')
|
|
73
|
-
TaroMouseEvents.initEvent('click', true, true)
|
|
74
|
-
if (el) {
|
|
75
|
-
el.dispatchEvent(TaroMouseEvents)
|
|
76
|
-
el.onchange = function (e) {
|
|
77
|
-
const target = e.target as HTMLInputElement
|
|
78
|
-
if (target) {
|
|
79
|
-
const files = target.files || []
|
|
80
|
-
const arr = [...files]
|
|
81
|
-
arr && arr.forEach(item => {
|
|
82
|
-
const blob = new Blob([item], {
|
|
83
|
-
type: item.type
|
|
84
|
-
})
|
|
85
|
-
const url = URL.createObjectURL(blob)
|
|
86
|
-
res.tempFilePaths?.push(url)
|
|
87
|
-
res.tempFiles?.push({ path: url, size: item.size, type: item.type, originalFileObj: item })
|
|
88
|
-
})
|
|
89
|
-
handle.success(res, resolve)
|
|
90
|
-
target.value = ''
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
})
|
|
95
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import Taro from '@tarojs/api'
|
|
2
|
-
|
|
3
|
-
import { shouldBeObject } from '../../../utils'
|
|
4
|
-
import { MethodHandler } from '../../../utils/handler'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* 获取图片信息。网络图片需先配置download域名才能生效。
|
|
8
|
-
*/
|
|
9
|
-
export const getImageInfo: typeof Taro.getImageInfo = (options) => {
|
|
10
|
-
// options must be an Object
|
|
11
|
-
const isObject = shouldBeObject(options)
|
|
12
|
-
if (!isObject.flag) {
|
|
13
|
-
const res = { errMsg: `getImageInfo:fail ${isObject.msg}` }
|
|
14
|
-
console.error(res.errMsg)
|
|
15
|
-
return Promise.reject(res)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const getBase64Image = (image: HTMLImageElement) => {
|
|
19
|
-
try {
|
|
20
|
-
const canvas = document.createElement('canvas')
|
|
21
|
-
canvas.width = image.width
|
|
22
|
-
canvas.height = image.height
|
|
23
|
-
const ctx = canvas.getContext('2d')
|
|
24
|
-
ctx?.drawImage(image, 0, 0, image.width, image.height)
|
|
25
|
-
return canvas.toDataURL('image/png')
|
|
26
|
-
} catch (e) {
|
|
27
|
-
console.error('getImageInfo:get base64 fail', e)
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const { src, success, fail, complete } = options
|
|
32
|
-
const handle = new MethodHandler({ name: 'getImageInfo', success, fail, complete })
|
|
33
|
-
return new Promise((resolve, reject) => {
|
|
34
|
-
const image = new Image()
|
|
35
|
-
image.crossOrigin = ''
|
|
36
|
-
image.onload = () => {
|
|
37
|
-
handle.success({
|
|
38
|
-
width: image.naturalWidth,
|
|
39
|
-
height: image.naturalHeight,
|
|
40
|
-
path: getBase64Image(image) || src
|
|
41
|
-
}, resolve)
|
|
42
|
-
}
|
|
43
|
-
image.onerror = (e: any) => {
|
|
44
|
-
handle.fail({
|
|
45
|
-
errMsg: e.message
|
|
46
|
-
}, reject)
|
|
47
|
-
}
|
|
48
|
-
image.src = src
|
|
49
|
-
})
|
|
50
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { temporarilyNotSupport } from '../../../utils'
|
|
2
|
-
|
|
3
|
-
// 图片
|
|
4
|
-
export const saveImageToPhotosAlbum = temporarilyNotSupport('saveImageToPhotosAlbum')
|
|
5
|
-
export const previewMedia = temporarilyNotSupport('previewMedia')
|
|
6
|
-
|
|
7
|
-
export * from './getImageInfo'
|
|
8
|
-
export * from './previewImage'
|
|
9
|
-
|
|
10
|
-
export const compressImage = temporarilyNotSupport('compressImage')
|
|
11
|
-
export const chooseMessageFile = temporarilyNotSupport('chooseMessageFile')
|
|
12
|
-
|
|
13
|
-
export * from './chooseImage'
|