@mpxjs/api-proxy 2.9.52 → 2.9.58
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/@types/index.d.ts +7 -7
- package/package.json +21 -5
- package/src/common/js/promisify.js +6 -6
- package/src/common/js/utils.js +16 -52
- package/src/common/js/web.js +0 -12
- package/src/install.js +2 -3
- package/src/platform/api/action-sheet/ActionSheet.js +3 -7
- package/src/platform/api/action-sheet/index.ali.js +2 -1
- package/src/platform/api/action-sheet/index.android.js +1 -0
- package/src/platform/api/action-sheet/index.ios.js +1 -0
- package/src/platform/api/action-sheet/rnActionSheet.jsx +127 -0
- package/src/platform/api/app/index.ios.js +1 -0
- package/src/platform/api/app/index.web.js +5 -4
- package/src/platform/api/clipboard-data/rnClipboard.js +5 -5
- package/src/platform/api/create-selector-query/index.ali.js +2 -1
- package/src/platform/api/create-selector-query/index.android.js +1 -0
- package/src/platform/api/create-selector-query/index.ios.js +9 -0
- package/src/platform/api/create-selector-query/rnNodesRef.js +262 -0
- package/src/platform/api/create-selector-query/rnSelectQuery.js +43 -0
- package/src/platform/api/device/network/getNetworkType.js +4 -4
- package/src/platform/api/device/network/rnNetwork.js +3 -3
- package/src/platform/api/image/Preview.js +3 -3
- package/src/platform/api/location/index.ali.js +31 -0
- package/src/platform/api/location/index.android.js +1 -0
- package/src/platform/api/location/index.ios.js +31 -0
- package/src/platform/api/location/index.js +13 -0
- package/src/platform/api/location/index.web.js +36 -0
- package/src/platform/api/make-phone-call/rnMakePhone.js +3 -3
- package/src/platform/api/modal/Modal.js +12 -15
- package/src/platform/api/modal/index.android.js +1 -0
- package/src/platform/api/modal/index.ios.js +1 -0
- package/src/platform/api/modal/rnModal.jsx +149 -0
- package/src/platform/api/next-tick/index.android.js +1 -0
- package/src/platform/api/next-tick/index.ios.js +1 -0
- package/src/platform/api/page-scroll-to/index.web.js +3 -3
- package/src/platform/api/pull-down/index.web.js +5 -5
- package/src/platform/api/request/index.web.js +3 -6
- package/src/platform/api/request-payment/index.ali.js +2 -1
- package/src/platform/api/route/index.ios.js +9 -9
- package/src/platform/api/route/index.web.js +15 -18
- package/src/platform/api/screen-brightness/index.android.js +1 -0
- package/src/platform/api/screen-brightness/index.ios.js +1 -0
- package/src/platform/api/screen-brightness/rnScreenBrightness.js +53 -0
- package/src/platform/api/set-navigation-bar/index.android.js +1 -0
- package/src/platform/api/set-navigation-bar/index.ios.js +41 -0
- package/src/platform/api/set-navigation-bar/index.web.js +3 -3
- package/src/platform/api/socket/SocketTask.js +8 -17
- package/src/platform/api/socket/index.android.js +1 -0
- package/src/platform/api/socket/index.web.js +3 -3
- package/src/platform/api/storage/index.web.js +12 -11
- package/src/platform/api/storage/rnStorage.js +13 -12
- package/src/platform/api/system/index.ali.js +6 -2
- package/src/platform/api/system/index.web.js +2 -2
- package/src/platform/api/system/rnSystem.js +3 -3
- package/src/platform/api/tab-bar/index.web.js +10 -9
- package/src/platform/api/toast/Toast.js +3 -4
- package/src/platform/api/toast/error.png +0 -0
- package/src/platform/api/toast/index.android.js +1 -0
- package/src/platform/api/toast/index.ios.js +1 -0
- package/src/platform/api/toast/rnToast.jsx +189 -0
- package/src/platform/api/toast/success.png +0 -0
- package/src/platform/index.js +3 -0
- /package/src/platform/api/{socket/index.andriod.js → app/index.android.js} +0 -0
- /package/src/platform/api/make-phone-call/{index.andriod.js → index.android.js} +0 -0
package/@types/index.d.ts
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
type AddPromise<W> = {
|
|
4
4
|
[K in keyof W]: W[K] extends (...args: any) => any
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
? Parameters<W[K]> extends [{ success?: (res: infer R) => any }?, ...any[]]
|
|
6
|
+
? (...args: Parameters<W[K]>) => ReturnType<W[K]> & Promise<R>
|
|
7
|
+
: W[K]
|
|
7
8
|
: W[K]
|
|
8
|
-
: W[K]
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
type AddParam<O, V extends (...args: any) => any> =
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
Parameters<V> extends [{ success?: (res: infer R) => any }, ...any[]]
|
|
13
|
+
? (options: O) => ReturnType<V> & Promise<R>
|
|
14
|
+
: (options: O) => ReturnType<V>
|
|
15
15
|
// @ts-ignore
|
|
16
16
|
type PickApiValue<T extends keyof WechatMiniprogram.Wx> = Pick<WechatMiniprogram.Wx, T>[T]
|
|
17
17
|
// @ts-ignore
|
|
@@ -33,7 +33,7 @@ declare module '@mpxjs/core' {
|
|
|
33
33
|
|
|
34
34
|
export const getProxy: (...args: any) => void
|
|
35
35
|
|
|
36
|
-
export const promisify: (listObj: object, whiteList
|
|
36
|
+
export const promisify: (listObj: object, whiteList?: string[], customBlackList?: string[]) => Record<string, any>
|
|
37
37
|
|
|
38
38
|
export const showActionSheet: WechatMiniprogram.Wx['showActionSheet']
|
|
39
39
|
export const addPhoneContact: WechatMiniprogram.Wx['addPhoneContact']
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/api-proxy",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.58",
|
|
4
4
|
"description": "convert miniprogram API at each end",
|
|
5
5
|
"module": "src/index.js",
|
|
6
6
|
"types": "@types/index.d.ts",
|
|
@@ -37,15 +37,19 @@
|
|
|
37
37
|
},
|
|
38
38
|
"homepage": "https://github.com/didi/mpx#readme",
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@mpxjs/utils": "^2.9.
|
|
41
|
-
"axios": "^1.
|
|
40
|
+
"@mpxjs/utils": "^2.9.58",
|
|
41
|
+
"axios": "^1.7.3"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
+
"@ant-design/react-native": "^5.1.3",
|
|
44
45
|
"@react-native-async-storage/async-storage": "^1.23.1",
|
|
45
46
|
"@react-native-clipboard/clipboard": "^1.14.0",
|
|
46
47
|
"@react-native-community/netinfo": "^11.2.1",
|
|
48
|
+
"expo-brightness": "~11.8.0",
|
|
47
49
|
"react-native-device-info": "^10.13.2",
|
|
48
|
-
"react-native-
|
|
50
|
+
"react-native-get-location": "^4.0.1",
|
|
51
|
+
"react-native-safe-area-context": "^4.10.1",
|
|
52
|
+
"react-native-webview": "^13.10.5"
|
|
49
53
|
},
|
|
50
54
|
"peerDependenciesMeta": {
|
|
51
55
|
"@react-native-async-storage/async-storage": {
|
|
@@ -62,7 +66,19 @@
|
|
|
62
66
|
},
|
|
63
67
|
"react-native-safe-area-context": {
|
|
64
68
|
"optional": true
|
|
69
|
+
},
|
|
70
|
+
"react-native-get-location": {
|
|
71
|
+
"optional": true
|
|
72
|
+
},
|
|
73
|
+
"@ant-design/react-native": {
|
|
74
|
+
"optional": true
|
|
75
|
+
},
|
|
76
|
+
"expo-brightness": {
|
|
77
|
+
"optional": true
|
|
78
|
+
},
|
|
79
|
+
"react-native-webview": {
|
|
80
|
+
"optional": true
|
|
65
81
|
}
|
|
66
82
|
},
|
|
67
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "49fe4c4bc46ff4bf87cd8adde37981d4b4134aa7"
|
|
68
84
|
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
const envObj = getEnvObj()
|
|
1
|
+
import { ENV_OBJ } from './utils'
|
|
4
2
|
|
|
5
3
|
// 特别指定的不进行Promise封装的方法
|
|
6
4
|
const blackList = [
|
|
@@ -31,7 +29,9 @@ const blackList = [
|
|
|
31
29
|
'createOffscreenCanvas',
|
|
32
30
|
'reportEvent',
|
|
33
31
|
'connectSocket',
|
|
34
|
-
'base64ToArrayBuffer'
|
|
32
|
+
'base64ToArrayBuffer',
|
|
33
|
+
'getDeviceInfo',
|
|
34
|
+
'getWindowInfo'
|
|
35
35
|
]
|
|
36
36
|
|
|
37
37
|
function getMapFromList (list) {
|
|
@@ -71,14 +71,14 @@ function promisify (listObj, whiteList, customBlackList) {
|
|
|
71
71
|
const obj = args[0] || {}
|
|
72
72
|
// 不需要转换 or 用户已定义回调,则不处理
|
|
73
73
|
if (!promisifyFilter(key) || obj.success || obj.fail) {
|
|
74
|
-
return listObj[key].apply(
|
|
74
|
+
return listObj[key].apply(ENV_OBJ, args)
|
|
75
75
|
} else { // 其他情况进行转换
|
|
76
76
|
if (!args[0]) args.unshift(obj)
|
|
77
77
|
let returned
|
|
78
78
|
const promise = new Promise((resolve, reject) => {
|
|
79
79
|
obj.success = resolve
|
|
80
80
|
obj.fail = reject
|
|
81
|
-
returned = listObj[key].apply(
|
|
81
|
+
returned = listObj[key].apply(ENV_OBJ, args)
|
|
82
82
|
})
|
|
83
83
|
promise.__returned = returned
|
|
84
84
|
return promise
|
package/src/common/js/utils.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { hasOwn, noop, getEnvObj } from '@mpxjs/utils'
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
*
|
|
3
5
|
* @param {Object} options 原参数
|
|
@@ -12,16 +14,6 @@
|
|
|
12
14
|
* d: 4 // 增加 d
|
|
13
15
|
* })
|
|
14
16
|
*/
|
|
15
|
-
const hasOwnProperty = Object.prototype.hasOwnProperty
|
|
16
|
-
|
|
17
|
-
function type (n) {
|
|
18
|
-
return Object.prototype.toString.call(n).slice(8, -1)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function hasOwn (obj, key) {
|
|
22
|
-
return hasOwnProperty.call(obj, key)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
17
|
function changeOpts (options, updateOrRemoveOpt = {}, extraOpt = {}) {
|
|
26
18
|
let opts = {}
|
|
27
19
|
|
|
@@ -53,31 +45,6 @@ const handleSuccess = (opts, getOptions = noop, thisObj) => {
|
|
|
53
45
|
}
|
|
54
46
|
}
|
|
55
47
|
|
|
56
|
-
function getEnvObj () {
|
|
57
|
-
switch (__mpx_mode__) {
|
|
58
|
-
case 'wx':
|
|
59
|
-
return wx
|
|
60
|
-
case 'ali':
|
|
61
|
-
return my
|
|
62
|
-
case 'swan':
|
|
63
|
-
return swan
|
|
64
|
-
case 'qq':
|
|
65
|
-
return qq
|
|
66
|
-
case 'tt':
|
|
67
|
-
return tt
|
|
68
|
-
case 'jd':
|
|
69
|
-
return jd
|
|
70
|
-
case 'qa':
|
|
71
|
-
return qa
|
|
72
|
-
case 'dd':
|
|
73
|
-
return dd
|
|
74
|
-
case 'web':
|
|
75
|
-
case 'ios':
|
|
76
|
-
case 'android':
|
|
77
|
-
return {}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
48
|
function warn (msg) {
|
|
82
49
|
console.warn && console.warn(`[@mpxjs/api-proxy warn]:\n ${msg}`)
|
|
83
50
|
}
|
|
@@ -87,20 +54,10 @@ function error (msg) {
|
|
|
87
54
|
}
|
|
88
55
|
function envError (method) {
|
|
89
56
|
return () => {
|
|
90
|
-
|
|
57
|
+
throw Error(`[@mpxjs/api-proxy error]:\n ${__mpx_mode__}环境不支持${method}方法`)
|
|
91
58
|
}
|
|
92
59
|
}
|
|
93
60
|
|
|
94
|
-
function noop () {
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function makeMap (arr) {
|
|
98
|
-
return arr.reduce((obj, item) => {
|
|
99
|
-
obj[item] = true
|
|
100
|
-
return obj
|
|
101
|
-
}, {})
|
|
102
|
-
}
|
|
103
|
-
|
|
104
61
|
function defineUnsupportedProps (resObj, props) {
|
|
105
62
|
const defineProps = {}
|
|
106
63
|
props.forEach((item) => {
|
|
@@ -120,21 +77,28 @@ function throwSSRWarning (info) {
|
|
|
120
77
|
console.error(`[Mpx runtime error]: Dangerous API! ${info}, It may cause some problems, please use this method with caution`)
|
|
121
78
|
}
|
|
122
79
|
|
|
80
|
+
function successHandle (result, success, complete) {
|
|
81
|
+
typeof success === 'function' && success(result)
|
|
82
|
+
typeof complete === 'function' && complete(result)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function failHandle (result, fail, complete) {
|
|
86
|
+
typeof fail === 'function' && fail(result)
|
|
87
|
+
typeof complete === 'function' && complete(result)
|
|
88
|
+
}
|
|
89
|
+
|
|
123
90
|
const ENV_OBJ = getEnvObj()
|
|
124
91
|
|
|
125
92
|
export {
|
|
126
93
|
changeOpts,
|
|
127
94
|
handleSuccess,
|
|
128
|
-
getEnvObj,
|
|
129
95
|
error,
|
|
130
96
|
envError,
|
|
131
97
|
warn,
|
|
132
|
-
noop,
|
|
133
|
-
makeMap,
|
|
134
98
|
isBrowser,
|
|
135
|
-
hasOwn,
|
|
136
99
|
throwSSRWarning,
|
|
137
100
|
ENV_OBJ,
|
|
138
|
-
|
|
139
|
-
|
|
101
|
+
defineUnsupportedProps,
|
|
102
|
+
successHandle,
|
|
103
|
+
failHandle
|
|
140
104
|
}
|
package/src/common/js/web.js
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
function webHandleSuccess (result, success, complete) {
|
|
2
|
-
typeof success === 'function' && success(result)
|
|
3
|
-
typeof complete === 'function' && complete(result)
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
function webHandleFail (result, fail, complete) {
|
|
7
|
-
typeof fail === 'function' && fail(result)
|
|
8
|
-
typeof complete === 'function' && complete(result)
|
|
9
|
-
}
|
|
10
|
-
|
|
11
1
|
function isTabBarPage (url, router) {
|
|
12
2
|
const tabBarPagesMap = global.__tabBarPagesMap
|
|
13
3
|
if (!tabBarPagesMap || !url) return false
|
|
@@ -49,8 +39,6 @@ function getRootElement () {
|
|
|
49
39
|
}
|
|
50
40
|
|
|
51
41
|
export {
|
|
52
|
-
webHandleSuccess,
|
|
53
|
-
webHandleFail,
|
|
54
42
|
createDom,
|
|
55
43
|
bindTap,
|
|
56
44
|
getRootElement,
|
package/src/install.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as platformApi from './platform'
|
|
2
|
-
import {
|
|
2
|
+
import { ENV_OBJ } from './common/js'
|
|
3
3
|
import promisify from './common/js/promisify'
|
|
4
4
|
|
|
5
5
|
export default function install (target, options = {}) {
|
|
@@ -9,8 +9,7 @@ export default function install (target, options = {}) {
|
|
|
9
9
|
blackList = [], // 强制不变成 promise 格式的 api
|
|
10
10
|
custom = {} // 自定义转化规则
|
|
11
11
|
} = options
|
|
12
|
-
const
|
|
13
|
-
const transedApi = Object.assign({}, envObj, platformApi)
|
|
12
|
+
const transedApi = Object.assign({}, ENV_OBJ, platformApi)
|
|
14
13
|
const promisedApi = usePromise ? promisify(transedApi, whiteList, blackList) : {}
|
|
15
14
|
Object.assign(target, transedApi, promisedApi, custom[__mpx_mode__])
|
|
16
15
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { successHandle, failHandle, createDom, bindTap, getRootElement } from '../../../common/js'
|
|
2
2
|
import '../../../common/stylus/ActionSheet.styl'
|
|
3
3
|
|
|
4
4
|
export default class ActionSheet {
|
|
@@ -44,8 +44,7 @@ export default class ActionSheet {
|
|
|
44
44
|
errMsg: 'showActionSheet:ok',
|
|
45
45
|
tapIndex: index
|
|
46
46
|
}
|
|
47
|
-
|
|
48
|
-
// this.toPromiseResolve(res)
|
|
47
|
+
successHandle(res, opts.success, opts.complete)
|
|
49
48
|
}))
|
|
50
49
|
list.appendChild(sheet)
|
|
51
50
|
})
|
|
@@ -57,8 +56,7 @@ export default class ActionSheet {
|
|
|
57
56
|
this.tempListeners.push(bindTap(this.cancelBtn, () => {
|
|
58
57
|
this.hide()
|
|
59
58
|
const err = { errMsg: 'showActionSheet:fail cancel' }
|
|
60
|
-
|
|
61
|
-
// !opts.fail && this.toPromiseReject(err)
|
|
59
|
+
failHandle(err, opts.fail, opts.complete)
|
|
62
60
|
}))
|
|
63
61
|
// make transition next frame
|
|
64
62
|
this.actionSheet.classList.add('show')
|
|
@@ -66,8 +64,6 @@ export default class ActionSheet {
|
|
|
66
64
|
setTimeout(() => {
|
|
67
65
|
this.box.classList.add('show')
|
|
68
66
|
}, 17)
|
|
69
|
-
|
|
70
|
-
// return this.toPromiseInitPromise()
|
|
71
67
|
}
|
|
72
68
|
|
|
73
69
|
hide () {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './rnActionSheet'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './rnActionSheet'
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { View, TouchableHighlight, Text, StyleSheet, Button, Animated } from 'react-native'
|
|
2
|
+
import { successHandle, failHandle } from '../../../common/js'
|
|
3
|
+
import { Portal } from '@ant-design/react-native'
|
|
4
|
+
function showActionSheet (options) {
|
|
5
|
+
const { alertText, itemList = [], itemColor = '#000000', success, fail, complete } = options
|
|
6
|
+
let actionSheetKey
|
|
7
|
+
const slideAnim = new Animated.Value(500)
|
|
8
|
+
const slideIn = () => {
|
|
9
|
+
// Will change fadeAnim value to 1 in 5 seconds
|
|
10
|
+
Animated.timing(slideAnim, {
|
|
11
|
+
toValue: 0,
|
|
12
|
+
duration: 200,
|
|
13
|
+
useNativeDriver: true,
|
|
14
|
+
}).start()
|
|
15
|
+
}
|
|
16
|
+
const slideOut = () => {
|
|
17
|
+
// Will change fadeAnim value to 1 in 5 seconds
|
|
18
|
+
Animated.timing(slideAnim, {
|
|
19
|
+
toValue: 500,
|
|
20
|
+
duration: 200,
|
|
21
|
+
useNativeDriver: true,
|
|
22
|
+
}).start(() => {
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
if (itemList.length === 0 || itemList.length > 6) {
|
|
26
|
+
const result = {
|
|
27
|
+
errMsg: 'showActionSheet:fail parameter error: itemList should not be large than 6'
|
|
28
|
+
}
|
|
29
|
+
if (itemList.length === 0) {
|
|
30
|
+
result.errno = 1001
|
|
31
|
+
result.errMsg = 'showActionSheet:fail parameter error: parameter.itemList should have at least 1 item;'
|
|
32
|
+
}
|
|
33
|
+
failHandle(result, fail, complete)
|
|
34
|
+
return
|
|
35
|
+
}
|
|
36
|
+
const styles = StyleSheet.create({
|
|
37
|
+
actionActionMask: {
|
|
38
|
+
left: 0,
|
|
39
|
+
top: 0,
|
|
40
|
+
bottom: 0,
|
|
41
|
+
right: 0,
|
|
42
|
+
backgroundColor: 'rgba(0,0,0,0.6)',
|
|
43
|
+
position: 'absolute',
|
|
44
|
+
zIndex: 1000
|
|
45
|
+
},
|
|
46
|
+
actionSheetContent: {
|
|
47
|
+
left: 0,
|
|
48
|
+
right: 0,
|
|
49
|
+
position: 'absolute',
|
|
50
|
+
bottom: 0,
|
|
51
|
+
backgroundColor: '#ffffff',
|
|
52
|
+
borderTopLeftRadius: 10,
|
|
53
|
+
borderTopRightRadius: 10,
|
|
54
|
+
transform: [{
|
|
55
|
+
translateY: -500
|
|
56
|
+
}]
|
|
57
|
+
},
|
|
58
|
+
itemStyle: {
|
|
59
|
+
paddingTop: 15,
|
|
60
|
+
paddingBottom: 15,
|
|
61
|
+
justifyContent: 'center',
|
|
62
|
+
alignItems: 'center',
|
|
63
|
+
borderBottomWidth: 1,
|
|
64
|
+
borderBottomStyle: 'solid',
|
|
65
|
+
borderBottomColor: 'rgba(0,0,0,0.1)'
|
|
66
|
+
},
|
|
67
|
+
itemTextStyle: {
|
|
68
|
+
fontSize: 18
|
|
69
|
+
},
|
|
70
|
+
buttonStyle: {
|
|
71
|
+
fontSize: 18,
|
|
72
|
+
paddingTop: 10,
|
|
73
|
+
paddingBottom: 10
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
const remove = function () {
|
|
77
|
+
if (actionSheetKey) {
|
|
78
|
+
slideOut()
|
|
79
|
+
setTimeout(() => {
|
|
80
|
+
Portal.remove(actionSheetKey)
|
|
81
|
+
actionSheetKey = null
|
|
82
|
+
}, 200)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const selectAction = function (index) {
|
|
86
|
+
const result = {
|
|
87
|
+
errMsg: 'showActionSheet:ok',
|
|
88
|
+
tapIndex: index
|
|
89
|
+
}
|
|
90
|
+
successHandle(result, success, complete)
|
|
91
|
+
remove()
|
|
92
|
+
}
|
|
93
|
+
const cancelAction = function () {
|
|
94
|
+
const result = {
|
|
95
|
+
errMsg: 'showActionSheet:fail cancel'
|
|
96
|
+
}
|
|
97
|
+
failHandle(result, fail, complete)
|
|
98
|
+
remove()
|
|
99
|
+
}
|
|
100
|
+
let alertTextList = []
|
|
101
|
+
if (alertText) {
|
|
102
|
+
alertTextList = [alertText]
|
|
103
|
+
}
|
|
104
|
+
const ActionSheetView = <TouchableHighlight underlayColor="rgba(0,0,0,0.6)" onPress={cancelAction} style={styles.actionActionMask}>
|
|
105
|
+
<Animated.View
|
|
106
|
+
style={[
|
|
107
|
+
styles.actionSheetContent,
|
|
108
|
+
{
|
|
109
|
+
transform: [{translateY: slideAnim}]
|
|
110
|
+
}
|
|
111
|
+
]}>
|
|
112
|
+
{ alertTextList.map((item, index) => <View key={index} style={ styles.itemStyle }><Text style={[styles.itemTextStyle, { color: '#666666' }]}>{item}</Text></View>) }
|
|
113
|
+
{ itemList.map((item, index) => <TouchableHighlight key={index} underlayColor="#ececec" onPress={() => selectAction(index)} style={ [styles.itemStyle, itemList.length -1 === index ? {
|
|
114
|
+
borderBottomWidth: 6,
|
|
115
|
+
borderBottomStyle: 'solid',
|
|
116
|
+
borderBottomColor: '#f7f7f7'
|
|
117
|
+
} : {}] }><Text style={[styles.itemTextStyle, { color: itemColor }]}>{item}</Text></TouchableHighlight>) }
|
|
118
|
+
<View style={styles.buttonStyle}><Button color={'#000000'} title={'取消'} onPress={cancelAction}></Button></View>
|
|
119
|
+
</Animated.View>
|
|
120
|
+
</TouchableHighlight>
|
|
121
|
+
actionSheetKey = Portal.add(ActionSheetView)
|
|
122
|
+
slideIn()
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export {
|
|
126
|
+
showActionSheet
|
|
127
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './index.web'
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { isBrowser } from '
|
|
1
|
+
import { isBrowser, isReact } from '@mpxjs/utils'
|
|
2
|
+
|
|
2
3
|
global.__mpxAppCbs = global.__mpxAppCbs || {
|
|
3
4
|
show: [],
|
|
4
5
|
hide: [],
|
|
@@ -7,7 +8,7 @@ global.__mpxAppCbs = global.__mpxAppCbs || {
|
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
function onError (callback) {
|
|
10
|
-
if (isBrowser) {
|
|
11
|
+
if (isBrowser || isReact) {
|
|
11
12
|
global.__mpxAppCbs.error.push(callback)
|
|
12
13
|
}
|
|
13
14
|
}
|
|
@@ -19,7 +20,7 @@ function offError (callback) {
|
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
function onAppShow (callback) {
|
|
22
|
-
if (isBrowser) {
|
|
23
|
+
if (isBrowser || isReact) {
|
|
23
24
|
global.__mpxAppCbs.show.push(callback)
|
|
24
25
|
}
|
|
25
26
|
}
|
|
@@ -31,7 +32,7 @@ function offAppShow (callback) {
|
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
function onAppHide (callback) {
|
|
34
|
-
if (isBrowser) {
|
|
35
|
+
if (isBrowser || isReact) {
|
|
35
36
|
global.__mpxAppCbs.hide.push(callback)
|
|
36
37
|
}
|
|
37
38
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Clipboard from '@react-native-clipboard/clipboard'
|
|
2
|
-
import {
|
|
2
|
+
import { successHandle, failHandle } from '../../../common/js'
|
|
3
3
|
import { type } from '@mpxjs/utils'
|
|
4
4
|
const setClipboardData = function (options) {
|
|
5
5
|
const { data, success, fail, complete } = options
|
|
@@ -9,14 +9,14 @@ const setClipboardData = function (options) {
|
|
|
9
9
|
errno: 1001,
|
|
10
10
|
errMsg: errStr
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
failHandle(result, fail, complete)
|
|
13
13
|
return
|
|
14
14
|
}
|
|
15
15
|
Clipboard.setString(data)
|
|
16
16
|
const result = {
|
|
17
17
|
errMsg: 'setClipboardData:ok'
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
successHandle(result, success, complete)
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
const getClipboardData = function (options) {
|
|
@@ -26,12 +26,12 @@ const getClipboardData = function (options) {
|
|
|
26
26
|
data,
|
|
27
27
|
errMsg: 'getClipboardData:ok'
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
successHandle(result, success, complete)
|
|
30
30
|
}).catch(() => {
|
|
31
31
|
const result = {
|
|
32
32
|
errMsg: 'setClipboardData:fail'
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
failHandle(result, fail, complete)
|
|
35
35
|
})
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './index.ios'
|