@tarojs/taro-h5 3.4.0-beta.2 → 3.4.2
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.js +4 -0
- package/dist/api/ai/facial.js +5 -0
- package/dist/api/ai/index.js +2 -0
- package/dist/api/ai/visual.js +5 -0
- package/dist/api/alipay/index.js +3 -0
- package/dist/api/base/crypto.js +3 -0
- package/dist/api/base/debug.js +4 -0
- package/dist/api/base/index.js +17 -0
- package/dist/api/base/performance.js +4 -0
- package/dist/api/base/system.js +187 -0
- package/dist/api/base/update.js +4 -0
- package/dist/api/base/weapp/app-event.js +18 -0
- package/dist/api/base/weapp/life-cycle.js +4 -0
- package/dist/api/canvas/CanvasContext.js +191 -0
- package/dist/api/canvas/canvasGetImageData.js +25 -0
- package/dist/api/canvas/canvasPutImageData.js +22 -0
- package/dist/api/canvas/canvasToTempFilePath.js +22 -0
- package/dist/api/canvas/createCanvasContext.js +16 -0
- package/dist/api/canvas/index.js +12 -0
- package/dist/api/cloud/index.js +21 -0
- package/dist/api/data-analysis/index.js +5 -0
- package/dist/api/device/accelerometer.js +83 -0
- package/dist/api/device/accessibility.js +3 -0
- package/dist/api/device/battery.js +21 -0
- package/dist/api/device/bluetooth-ble.js +18 -0
- package/dist/api/device/bluetooth-peripheral.js +5 -0
- package/dist/api/device/bluetooth.js +15 -0
- package/dist/api/device/calendar.js +4 -0
- package/dist/api/device/clipboard.js +65 -0
- package/dist/api/device/compass.js +64 -0
- package/dist/api/device/contact.js +4 -0
- package/dist/api/device/crypto.js +3 -0
- package/dist/api/device/gyroscope.js +6 -0
- package/dist/api/device/iBeacon.js +9 -0
- package/dist/api/device/index.js +23 -0
- package/dist/api/device/keyboard.js +6 -0
- package/dist/api/device/memory.js +4 -0
- package/dist/api/device/motion.js +81 -0
- package/dist/api/device/network.js +78 -0
- package/dist/api/device/nfc.js +9 -0
- package/dist/api/device/phone.js +24 -0
- package/dist/api/device/scan.js +6 -0
- package/dist/api/device/screen.js +8 -0
- package/dist/api/device/vibrate.js +35 -0
- package/dist/api/device/wifi.js +13 -0
- package/dist/api/ext/index.js +4 -0
- package/dist/api/files/index.js +10 -0
- package/dist/api/framework/index.js +7 -0
- package/dist/api/index.js +24 -0
- package/dist/api/location/chooseLocation.js +93 -0
- package/dist/api/location/index.js +13 -0
- package/dist/api/location/style.css +79 -0
- package/dist/api/media/EditorContext.js +19 -0
- package/dist/api/media/audio/InnerAudioContext.js +84 -0
- package/dist/api/media/audio/index.js +15 -0
- package/dist/api/media/background-audio/BackgroundAudioManager.js +86 -0
- package/dist/api/media/background-audio/index.js +15 -0
- package/dist/api/media/camera.js +3 -0
- package/dist/api/media/image/chooseImage.js +74 -0
- package/dist/api/media/image/getImageInfo.js +31 -0
- package/dist/api/media/image/index.js +9 -0
- package/dist/api/media/image/previewImage.js +67 -0
- package/dist/api/media/index.js +12 -0
- package/dist/api/media/live.js +4 -0
- package/dist/api/media/map.js +3 -0
- package/dist/api/media/media-recorder.js +3 -0
- package/dist/api/media/recorder.js +5 -0
- package/dist/api/media/video/index.js +74 -0
- package/dist/api/media/video-decoder.js +3 -0
- package/dist/api/media/video-processing.js +3 -0
- package/dist/api/media/voip.js +16 -0
- package/dist/api/navigate/index.js +6 -0
- package/dist/api/network/download.js +124 -0
- package/dist/api/network/index.js +7 -0
- package/dist/api/network/mdns.js +12 -0
- package/dist/api/network/request/index.js +125 -0
- package/dist/api/network/tcp.js +3 -0
- package/dist/api/network/udp.js +3 -0
- package/dist/api/network/upload.js +146 -0
- package/dist/api/network/utils.js +65 -0
- package/dist/api/network/websocket/index.js +70 -0
- package/dist/api/network/websocket/socketTask.js +63 -0
- package/dist/api/open-api/account.js +3 -0
- package/dist/api/open-api/address.js +3 -0
- package/dist/api/open-api/authorize.js +4 -0
- package/dist/api/open-api/card.js +4 -0
- package/dist/api/open-api/channels-live.js +8 -0
- package/dist/api/open-api/customer-service.js +3 -0
- package/dist/api/open-api/facial.js +6 -0
- package/dist/api/open-api/favorites.js +4 -0
- package/dist/api/open-api/group.js +3 -0
- package/dist/api/open-api/index.js +18 -0
- package/dist/api/open-api/invoice.js +4 -0
- package/dist/api/open-api/license-plate.js +3 -0
- package/dist/api/open-api/login.js +5 -0
- package/dist/api/open-api/red-package.js +3 -0
- package/dist/api/open-api/settings.js +4 -0
- package/dist/api/open-api/soter.js +5 -0
- package/dist/api/open-api/subscribe-message.js +3 -0
- package/dist/api/open-api/user-info.js +4 -0
- package/dist/api/open-api/werun.js +4 -0
- package/dist/api/payment/index.js +4 -0
- package/dist/api/route/index.js +3 -0
- package/dist/api/share/index.js +12 -0
- package/dist/api/storage/background-fetch.js +6 -0
- package/dist/api/storage/index.js +157 -0
- package/dist/api/swan/index.js +26 -0
- package/dist/api/taro.js +47 -0
- package/dist/api/ui/animation/index.js +288 -0
- package/dist/api/ui/background.js +4 -0
- package/dist/api/ui/custom-component.js +3 -0
- package/dist/api/ui/fonts.js +51 -0
- package/dist/api/ui/index.js +12 -0
- package/dist/api/ui/interaction/actionSheet.js +188 -0
- package/dist/api/ui/interaction/index.js +268 -0
- package/dist/api/ui/interaction/modal.js +207 -0
- package/dist/api/ui/interaction/toast.js +195 -0
- package/dist/api/ui/menu.js +3 -0
- package/dist/api/ui/navigation-bar/index.js +42 -0
- package/dist/api/ui/pull-down-refresh.js +26 -0
- package/dist/api/ui/scroll/index.js +83 -0
- package/dist/api/ui/sticky.js +3 -0
- package/dist/api/ui/tab-bar.js +282 -0
- package/dist/api/ui/window.js +31 -0
- package/dist/api/utils/handler.js +80 -0
- package/dist/api/utils/index.js +172 -0
- package/dist/api/worker/index.js +3 -0
- package/dist/api/wxml/index.js +6 -0
- package/dist/api/wxml/nodesRef.js +42 -0
- package/dist/api/wxml/selectorQuery.js +201 -0
- package/dist/index.cjs.js +5028 -6988
- package/dist/index.js +4 -10767
- package/dist/taroApis.js +1 -1
- package/dist/types/type.js +2 -0
- package/package.json +11 -13
- package/src/api/ai/visual.ts +3 -0
- package/src/api/base/system.ts +207 -0
- package/src/api/canvas/CanvasContext.ts +42 -39
- package/src/api/canvas/createCanvasContext.ts +2 -2
- package/src/api/canvas/index.ts +10 -2
- package/src/api/cloud/index.ts +4 -0
- package/src/api/device/battery.ts +18 -1
- package/src/api/device/index.ts +1 -0
- package/src/api/{base/system → device}/network.ts +35 -15
- package/src/api/device/wifi.ts +1 -0
- package/src/api/location/chooseLocation.ts +2 -2
- package/src/api/media/{editor.ts → EditorContext.ts} +2 -0
- package/src/api/media/audio/InnerAudioContext.ts +98 -0
- package/src/api/media/audio/index.ts +1 -86
- package/src/api/media/background-audio/BackgroundAudioManager.ts +103 -0
- package/src/api/media/{background-audio.ts → background-audio/index.ts} +7 -2
- package/src/api/media/image/previewImage.ts +4 -25
- package/src/api/media/index.ts +0 -1
- package/src/api/network/download.ts +5 -5
- package/src/api/network/upload.ts +7 -13
- package/src/api/network/websocket/index.ts +1 -1
- package/src/api/ui/animation/index.ts +11 -12
- package/src/api/ui/fonts.ts +61 -2
- package/src/api/ui/interaction/index.ts +12 -10
- package/src/api/ui/navigation-bar/index.ts +2 -2
- package/src/api/ui/scroll/index.ts +3 -3
- package/src/api/utils/handler.ts +4 -4
- package/src/api/utils/index.ts +34 -13
- package/src/api/wxml/nodesRef.ts +10 -3
- package/src/api/wxml/selectorQuery.ts +68 -23
- package/src/index.ts +2 -2
- package/src/api/base/system/index.ts +0 -2
- package/src/api/base/system/info.ts +0 -64
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Taro from '@tarojs/
|
|
1
|
+
import Taro from '@tarojs/api'
|
|
2
2
|
|
|
3
3
|
import { MethodHandler } from '../../utils/handler'
|
|
4
4
|
import { getParameterError, shouldBeObject, temporarilyNotSupport } from '../../utils'
|
|
@@ -16,7 +16,7 @@ export function setNavigationBarTitle (options) {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
const { title, success, fail, complete } = options
|
|
19
|
-
const handle = new MethodHandler({ name: '
|
|
19
|
+
const handle = new MethodHandler({ name: 'setNavigationBarTitle', success, fail, complete })
|
|
20
20
|
|
|
21
21
|
if (!title || typeof title !== 'string') {
|
|
22
22
|
return handle.fail({
|
|
@@ -4,7 +4,7 @@ import { Current } from '@tarojs/runtime'
|
|
|
4
4
|
import { MethodHandler } from '../../utils/handler'
|
|
5
5
|
import { getTimingFunc, easeInOut } from '../../utils'
|
|
6
6
|
|
|
7
|
-
let timer:
|
|
7
|
+
let timer: NodeJS.Timer
|
|
8
8
|
const FRAME_DURATION = 17
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -21,9 +21,9 @@ export const pageScrollTo: typeof Taro.pageScrollTo = ({ scrollTop, selector = '
|
|
|
21
21
|
}, reject)
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
const id = Current.page?.path
|
|
24
|
+
const id = Current.page?.path?.replace(/([^a-z0-9\u00a0-\uffff_-])/ig, '\\$1')
|
|
25
25
|
const el: HTMLDivElement | null = (id
|
|
26
|
-
? document.
|
|
26
|
+
? document.querySelector(`.taro_page#${id}`)
|
|
27
27
|
: document.querySelector('.taro_page') ||
|
|
28
28
|
document.querySelector('.taro_router')) as HTMLDivElement
|
|
29
29
|
|
package/src/api/utils/handler.ts
CHANGED
|
@@ -58,7 +58,7 @@ export class CallbackManager {
|
|
|
58
58
|
* 添加回调
|
|
59
59
|
* @param {{ callback: function, ctx: any } | function} opt
|
|
60
60
|
*/
|
|
61
|
-
add (opt?: TCallbackManagerListItem) {
|
|
61
|
+
add = (opt?: TCallbackManagerListItem) => {
|
|
62
62
|
if (opt) this.callbacks.push(opt)
|
|
63
63
|
}
|
|
64
64
|
|
|
@@ -66,7 +66,7 @@ export class CallbackManager {
|
|
|
66
66
|
* 移除回调
|
|
67
67
|
* @param {{ callback: function, ctx: any } | function} opt
|
|
68
68
|
*/
|
|
69
|
-
remove (opt?: TCallbackManagerListItem) {
|
|
69
|
+
remove = (opt?: TCallbackManagerListItem) => {
|
|
70
70
|
if (opt) {
|
|
71
71
|
let pos = -1
|
|
72
72
|
this.callbacks.forEach((callback, k) => {
|
|
@@ -84,7 +84,7 @@ export class CallbackManager {
|
|
|
84
84
|
* 获取回调函数数量
|
|
85
85
|
* @return {number}
|
|
86
86
|
*/
|
|
87
|
-
count () {
|
|
87
|
+
count = () => {
|
|
88
88
|
return this.callbacks.length
|
|
89
89
|
}
|
|
90
90
|
|
|
@@ -92,7 +92,7 @@ export class CallbackManager {
|
|
|
92
92
|
* 触发回调
|
|
93
93
|
* @param {...any} args 回调的调用参数
|
|
94
94
|
*/
|
|
95
|
-
trigger (...args: TCallbackManagerList) {
|
|
95
|
+
trigger = (...args: TCallbackManagerList) => {
|
|
96
96
|
this.callbacks.forEach(opt => {
|
|
97
97
|
if (typeof opt === 'function') {
|
|
98
98
|
opt(...args)
|
package/src/api/utils/index.ts
CHANGED
|
@@ -12,7 +12,7 @@ export function shouldBeObject (target: unknown) {
|
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export function findDOM (inst): TaroElement | HTMLElement | undefined {
|
|
15
|
+
export function findDOM (inst?): TaroElement | HTMLElement | undefined {
|
|
16
16
|
const runtimeHooks = container.get<IHooks>(SERVICE_IDENTIFIER.Hooks)
|
|
17
17
|
|
|
18
18
|
if (inst) {
|
|
@@ -88,30 +88,51 @@ export function serializeParams (params) {
|
|
|
88
88
|
export function temporarilyNotSupport (apiName) {
|
|
89
89
|
return () => {
|
|
90
90
|
const errMsg = `暂时不支持 API ${apiName}`
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
91
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
92
|
+
console.error(errMsg)
|
|
93
|
+
return Promise.reject({
|
|
94
|
+
errMsg
|
|
95
|
+
})
|
|
96
|
+
} else {
|
|
97
|
+
console.warn(errMsg)
|
|
98
|
+
return Promise.resolve({
|
|
99
|
+
errMsg
|
|
100
|
+
})
|
|
101
|
+
}
|
|
95
102
|
}
|
|
96
103
|
}
|
|
97
104
|
|
|
98
105
|
export function weixinCorpSupport (apiName) {
|
|
99
106
|
return () => {
|
|
100
107
|
const errMsg = `h5端仅在微信公众号中支持 API ${apiName}`
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
108
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
109
|
+
console.error(errMsg)
|
|
110
|
+
return Promise.reject({
|
|
111
|
+
errMsg
|
|
112
|
+
})
|
|
113
|
+
} else {
|
|
114
|
+
console.warn(errMsg)
|
|
115
|
+
return Promise.resolve({
|
|
116
|
+
errMsg
|
|
117
|
+
})
|
|
118
|
+
}
|
|
105
119
|
}
|
|
106
120
|
}
|
|
107
121
|
|
|
108
122
|
export function permanentlyNotSupport (apiName) {
|
|
109
123
|
return () => {
|
|
110
124
|
const errMsg = `不支持 API ${apiName}`
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
125
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
126
|
+
console.error(errMsg)
|
|
127
|
+
return Promise.reject({
|
|
128
|
+
errMsg
|
|
129
|
+
})
|
|
130
|
+
} else {
|
|
131
|
+
console.warn(errMsg)
|
|
132
|
+
return Promise.resolve({
|
|
133
|
+
errMsg
|
|
134
|
+
})
|
|
135
|
+
}
|
|
115
136
|
}
|
|
116
137
|
}
|
|
117
138
|
|
package/src/api/wxml/nodesRef.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { temporarilyNotSupport } from '../utils'
|
|
2
1
|
import { SelectorQuery } from './selectorQuery'
|
|
3
2
|
|
|
4
3
|
export class NodesRef implements Taro.NodesRef {
|
|
@@ -14,9 +13,17 @@ export class NodesRef implements Taro.NodesRef {
|
|
|
14
13
|
this._single = single
|
|
15
14
|
}
|
|
16
15
|
|
|
17
|
-
context
|
|
16
|
+
context (cb) {
|
|
17
|
+
const { _selector, _component, _single, _selectorQuery } = this
|
|
18
|
+
_selectorQuery._push(_selector, _component, _single, { context: !0 }, cb)
|
|
19
|
+
return _selectorQuery
|
|
20
|
+
}
|
|
18
21
|
|
|
19
|
-
node
|
|
22
|
+
node (cb) {
|
|
23
|
+
const { _selector, _component, _single, _selectorQuery } = this
|
|
24
|
+
_selectorQuery._push(_selector, _component, _single, { nodeCanvasType: !0, node: !0 }, cb)
|
|
25
|
+
return _selectorQuery
|
|
26
|
+
}
|
|
20
27
|
|
|
21
28
|
boundingClientRect (cb) {
|
|
22
29
|
const { _selector, _component, _single, _selectorQuery } = this
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Taro from '@tarojs/api'
|
|
2
|
+
import { CanvasContext } from '../canvas/CanvasContext'
|
|
2
3
|
import { findDOM } from '../utils'
|
|
3
4
|
import { NodesRef } from './nodesRef'
|
|
4
5
|
|
|
@@ -16,33 +17,77 @@ type TSelectorQueryQueueCallback = (res: ISelectorQueryQueue) => void
|
|
|
16
17
|
function filter (fields, dom?: HTMLElement, selector?: string) {
|
|
17
18
|
if (!dom) return null
|
|
18
19
|
|
|
19
|
-
const
|
|
20
|
-
const {
|
|
21
|
-
const isViewport = selector === 'html'
|
|
20
|
+
const isViewport = selector === '.taro_page'
|
|
21
|
+
const { id, dataset, rect, size, scrollOffset, properties = [], computedStyle = [], nodeCanvasType, node, context } = fields
|
|
22
22
|
const res: any = {}
|
|
23
23
|
|
|
24
|
-
if (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
if (nodeCanvasType && node) {
|
|
25
|
+
const tagName = dom.tagName
|
|
26
|
+
res.node = {
|
|
27
|
+
id: dom.id,
|
|
28
|
+
$taroElement: dom
|
|
29
|
+
}
|
|
30
|
+
if (/^taro-canvas-core/i.test(tagName)) {
|
|
31
|
+
const type = (dom as any).type! || ''
|
|
32
|
+
res.nodeCanvasType = type
|
|
33
|
+
const canvas = dom.getElementsByTagName('canvas')[0]
|
|
34
|
+
if (/^(2d|webgl)/i.test(type) && canvas) {
|
|
35
|
+
res.node = canvas
|
|
36
|
+
} else {
|
|
37
|
+
res.node = null
|
|
38
|
+
}
|
|
32
39
|
} else {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
res.
|
|
36
|
-
res.
|
|
40
|
+
// TODO https://developers.weixin.qq.com/miniprogram/dev/component/scroll-view.html
|
|
41
|
+
// if (/^taro-scroll-view-core/i.test(tagName))
|
|
42
|
+
res.nodeCanvasType = ''
|
|
43
|
+
res.node = dom
|
|
37
44
|
}
|
|
45
|
+
return res
|
|
38
46
|
}
|
|
39
|
-
if (
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
if (context) {
|
|
48
|
+
const tagName = dom.tagName
|
|
49
|
+
if (/^taro-video-core/i.test(tagName)) {
|
|
50
|
+
// TODO HTMLVideoElement to VideoContext
|
|
51
|
+
return { context: dom as unknown as Taro.VideoContext }
|
|
52
|
+
} else if (/^taro-canvas-core/i.test(tagName)) {
|
|
53
|
+
const type = (dom as any).type! || '2d'
|
|
54
|
+
const canvas = dom?.querySelector('canvas') as HTMLCanvasElement
|
|
55
|
+
const ctx = canvas?.getContext(type) as CanvasRenderingContext2D
|
|
56
|
+
return { context: new CanvasContext(canvas, ctx) }
|
|
57
|
+
} else if (/^taro-live-player-core/i.test(tagName)) {
|
|
58
|
+
console.error('暂时不支持通过 NodesRef.context 获取 LivePlayerContext')
|
|
59
|
+
} else if (/^taro-editor-core/i.test(tagName)) {
|
|
60
|
+
console.error('暂时不支持通过 NodesRef.context 获取 EditorContext')
|
|
61
|
+
} else if (/^taro-map-core/i.test(tagName)) {
|
|
62
|
+
console.error('暂时不支持通过 NodesRef.context 获取 MapContext')
|
|
63
|
+
}
|
|
64
|
+
return
|
|
65
|
+
}
|
|
66
|
+
if (id) res.id = dom.id
|
|
67
|
+
if (dataset) res.dataset = Object.assign({}, dom.dataset)
|
|
68
|
+
if (rect || size) {
|
|
69
|
+
const { left, right, top, bottom, width, height } = dom.getBoundingClientRect()
|
|
70
|
+
if (rect) {
|
|
71
|
+
if (!isViewport) {
|
|
72
|
+
res.left = left
|
|
73
|
+
res.right = right
|
|
74
|
+
res.top = top
|
|
75
|
+
res.bottom = bottom
|
|
76
|
+
} else {
|
|
77
|
+
res.left = 0
|
|
78
|
+
res.right = 0
|
|
79
|
+
res.top = 0
|
|
80
|
+
res.bottom = 0
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (size) {
|
|
84
|
+
if (!isViewport) {
|
|
85
|
+
res.width = width
|
|
86
|
+
res.height = height
|
|
87
|
+
} else {
|
|
88
|
+
res.width = dom.clientWidth
|
|
89
|
+
res.height = dom.clientHeight
|
|
90
|
+
}
|
|
46
91
|
}
|
|
47
92
|
}
|
|
48
93
|
if (scrollOffset) {
|
|
@@ -147,7 +192,7 @@ export class SelectorQuery implements Taro.SelectorQuery {
|
|
|
147
192
|
}
|
|
148
193
|
|
|
149
194
|
selectViewport () {
|
|
150
|
-
return new NodesRef('
|
|
195
|
+
return new NodesRef('.taro_page', this, true)
|
|
151
196
|
}
|
|
152
197
|
|
|
153
198
|
exec (cb) {
|
package/src/index.ts
CHANGED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import Taro from '@tarojs/api'
|
|
2
|
-
import MobileDetect from 'mobile-detect'
|
|
3
|
-
|
|
4
|
-
import { MethodHandler } from '../../utils/handler'
|
|
5
|
-
|
|
6
|
-
export const getSystemInfoSync: typeof Taro.getSystemInfoSync = () => {
|
|
7
|
-
const md = new MobileDetect(navigator.userAgent)
|
|
8
|
-
|
|
9
|
-
const info: ReturnType<typeof Taro.getSystemInfoSync> = {
|
|
10
|
-
brand: md.mobile() || '', // 手机品牌
|
|
11
|
-
model: md.mobile() || '', // 手机型号
|
|
12
|
-
system: md.os(), // 操作系统版本
|
|
13
|
-
pixelRatio: window.devicePixelRatio, // 设备像素比
|
|
14
|
-
screenWidth: window.screen.width, // 屏幕宽度
|
|
15
|
-
screenHeight: window.screen.height, // 屏幕高度
|
|
16
|
-
windowWidth: document.documentElement.clientWidth, // 可使用窗口宽度
|
|
17
|
-
windowHeight: document.documentElement.clientHeight, // 可使用窗口高度
|
|
18
|
-
version: '', // 微信版本号
|
|
19
|
-
statusBarHeight: NaN, // 状态栏的高度
|
|
20
|
-
platform: navigator.platform, // 客户端平台
|
|
21
|
-
language: navigator.language, // 微信设置的语言
|
|
22
|
-
fontSizeSetting: NaN, // 用户字体大小设置。以“我-设置-通用-字体大小”中的设置为准,单位:px
|
|
23
|
-
SDKVersion: '', // 客户端基础库版本
|
|
24
|
-
|
|
25
|
-
// TODO
|
|
26
|
-
albumAuthorized: false,
|
|
27
|
-
benchmarkLevel: 0,
|
|
28
|
-
bluetoothEnabled: false,
|
|
29
|
-
cameraAuthorized: false,
|
|
30
|
-
enableDebug: false,
|
|
31
|
-
locationAuthorized: false,
|
|
32
|
-
locationEnabled: false,
|
|
33
|
-
microphoneAuthorized: false,
|
|
34
|
-
notificationAlertAuthorized: false,
|
|
35
|
-
notificationAuthorized: false,
|
|
36
|
-
notificationBadgeAuthorized: false,
|
|
37
|
-
notificationSoundAuthorized: false,
|
|
38
|
-
safeArea: {
|
|
39
|
-
bottom: 0,
|
|
40
|
-
height: 0,
|
|
41
|
-
left: 0,
|
|
42
|
-
right: 0,
|
|
43
|
-
top: 0,
|
|
44
|
-
width: 0
|
|
45
|
-
},
|
|
46
|
-
wifiEnabled: false
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return info
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export const getSystemInfo: typeof Taro.getSystemInfo = async (options = {}) => {
|
|
53
|
-
const { success, fail, complete } = options
|
|
54
|
-
const handle = new MethodHandler({ name: 'getSystemInfo', success, fail, complete })
|
|
55
|
-
|
|
56
|
-
try {
|
|
57
|
-
const info = await getSystemInfoSync()
|
|
58
|
-
return handle.success(info)
|
|
59
|
-
} catch (error) {
|
|
60
|
-
return handle.fail({
|
|
61
|
-
errMsg: error
|
|
62
|
-
})
|
|
63
|
-
}
|
|
64
|
-
}
|