@mpxjs/api-proxy 2.9.70-alpha.0 → 2.9.70
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 +13 -0
- package/LICENSE +433 -0
- package/package.json +4 -3
- package/src/common/js/index.js +0 -1
- package/src/common/js/promisify.js +11 -3
- package/src/common/js/utils.js +1 -11
- package/src/platform/api/action-sheet/rnActionSheet.jsx +67 -81
- package/src/platform/api/app/index.web.js +26 -11
- package/src/platform/api/create-intersection-observer/rnIntersectionObserver.js +2 -2
- package/src/platform/api/image/index.ali.js +4 -1
- package/src/platform/api/image/index.ios.js +45 -0
- package/src/platform/api/image/index.js +4 -1
- package/src/platform/api/image/index.web.js +46 -2
- package/src/platform/api/modal/rnModal.jsx +7 -8
- package/src/platform/api/request/index.web.js +2 -3
- package/src/platform/api/set-navigation-bar/index.ali.js +6 -1
- package/src/platform/api/set-navigation-bar/index.ios.js +6 -3
- package/src/platform/api/set-navigation-bar/index.js +4 -1
- package/src/platform/api/set-navigation-bar/index.web.js +5 -2
- package/src/platform/api/setting/index.js +19 -0
- package/src/platform/api/system/index.ios.js +84 -1
- package/src/platform/api/system/rnSystem.js +35 -72
- package/src/platform/api/toast/rnToast.jsx +23 -16
- package/src/platform/index.js +4 -1
- package/src/common/js/ToPromise.js +0 -25
- package/src/common/stylus/Modal.tenon.styl +0 -42
- package/src/common/stylus/Toast.tenon.styl +0 -56
- package/src/index.tenon.js +0 -27
- package/src/platform/api/animation/animation.tenon.js +0 -225
- package/src/platform/api/animation/index.tenon.js +0 -89
- package/src/platform/api/event-channel/index.tenon.js +0 -52
- package/src/platform/api/modal/index.tenon.js +0 -12
- package/src/platform/api/modal/tenonModal.js +0 -154
- package/src/platform/api/next-tick/index.tenon.js +0 -11
- package/src/platform/api/request/index.tenon.js +0 -85
- package/src/platform/api/request/tenonUtil.js +0 -0
- package/src/platform/api/route/index.tenon.js +0 -121
- package/src/platform/api/set-navigation-bar/index.tenon.js +0 -17
- package/src/platform/api/socket/SocketTask.tenon.js +0 -105
- package/src/platform/api/socket/index.tenon.js +0 -48
- package/src/platform/api/storage/index.tenon.js +0 -144
- package/src/platform/api/system/index.tenon.js +0 -52
- package/src/platform/api/system/rnWindowInfo.js +0 -42
- package/src/platform/api/toast/Toast.tenon.js +0 -101
- package/src/platform/api/toast/index.tenon.js +0 -36
|
@@ -1,38 +1,17 @@
|
|
|
1
|
-
import { View, TouchableHighlight, Text, StyleSheet,
|
|
1
|
+
import { View, TouchableHighlight, Text, StyleSheet, TouchableOpacity } from 'react-native'
|
|
2
2
|
import { successHandle, failHandle } from '../../../common/js'
|
|
3
3
|
import { Portal } from '@ant-design/react-native'
|
|
4
|
+
import { getWindowInfo } from '../system/rnSystem'
|
|
5
|
+
import Animated, {
|
|
6
|
+
useSharedValue,
|
|
7
|
+
useAnimatedStyle,
|
|
8
|
+
withTiming
|
|
9
|
+
} from 'react-native-reanimated'
|
|
4
10
|
function showActionSheet (options = {}) {
|
|
5
11
|
const { alertText, itemList = [], itemColor = '#000000', success, fail, complete } = options
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
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
|
-
}
|
|
12
|
+
const windowInfo = getWindowInfo()
|
|
13
|
+
const bottom = windowInfo.screenHeight - windowInfo.safeArea.bottom
|
|
14
|
+
let actionSheetKey = null
|
|
36
15
|
const styles = StyleSheet.create({
|
|
37
16
|
actionActionMask: {
|
|
38
17
|
left: 0,
|
|
@@ -44,16 +23,14 @@ function showActionSheet (options = {}) {
|
|
|
44
23
|
zIndex: 1000
|
|
45
24
|
},
|
|
46
25
|
actionSheetContent: {
|
|
47
|
-
left: 0,
|
|
48
|
-
right: 0,
|
|
49
|
-
position: 'absolute',
|
|
50
|
-
bottom: 0,
|
|
51
26
|
backgroundColor: '#ffffff',
|
|
52
27
|
borderTopLeftRadius: 10,
|
|
53
28
|
borderTopRightRadius: 10,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
29
|
+
position: 'absolute',
|
|
30
|
+
bottom: 0,
|
|
31
|
+
left: 0,
|
|
32
|
+
right: 0,
|
|
33
|
+
paddingBottom: bottom
|
|
57
34
|
},
|
|
58
35
|
itemStyle: {
|
|
59
36
|
paddingTop: 15,
|
|
@@ -73,53 +50,62 @@ function showActionSheet (options = {}) {
|
|
|
73
50
|
paddingBottom: 10
|
|
74
51
|
}
|
|
75
52
|
})
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
53
|
+
function ActionSheet () {
|
|
54
|
+
const offset = useSharedValue(1000);
|
|
55
|
+
|
|
56
|
+
const animatedStyles = useAnimatedStyle(() => ({
|
|
57
|
+
transform: [{ translateY: offset.value }],
|
|
58
|
+
}))
|
|
59
|
+
|
|
60
|
+
const slideOut = () => {
|
|
61
|
+
// Will change fadeAnim value to 1 in 5 seconds
|
|
62
|
+
offset.value = withTiming(1000)
|
|
83
63
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
64
|
+
|
|
65
|
+
offset.value = withTiming(0)
|
|
66
|
+
|
|
67
|
+
const selectAction = function (index) {
|
|
68
|
+
const result = {
|
|
69
|
+
errMsg: 'showActionSheet:ok',
|
|
70
|
+
tapIndex: index
|
|
71
|
+
}
|
|
72
|
+
successHandle(result, success, complete)
|
|
73
|
+
remove()
|
|
89
74
|
}
|
|
90
|
-
|
|
91
|
-
remove()
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
75
|
+
|
|
76
|
+
const remove = function () {
|
|
77
|
+
if (actionSheetKey) {
|
|
78
|
+
slideOut()
|
|
79
|
+
setTimeout(() => {
|
|
80
|
+
Portal.remove(actionSheetKey)
|
|
81
|
+
actionSheetKey = null
|
|
82
|
+
}, 200)
|
|
83
|
+
}
|
|
96
84
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
85
|
+
|
|
86
|
+
const cancelAction = function () {
|
|
87
|
+
const result = {
|
|
88
|
+
errMsg: 'showActionSheet:fail cancel'
|
|
89
|
+
}
|
|
90
|
+
failHandle(result, fail, complete)
|
|
91
|
+
remove()
|
|
92
|
+
}
|
|
93
|
+
return (
|
|
94
|
+
<TouchableHighlight underlayColor="rgba(0,0,0,0.6)" activeOpacity={1} onPress={cancelAction} style={styles.actionActionMask}>
|
|
95
|
+
<Animated.View style={[styles.actionSheetContent, animatedStyles]} >
|
|
96
|
+
{ alertText ? <View style={ styles.itemStyle }><Text style={[styles.itemTextStyle, { color: '#666666' }]}>{alertText}</Text></View> : null }
|
|
97
|
+
{ itemList.map((item, index) => <TouchableHighlight key={index} underlayColor="#ececec" onPress={() => selectAction(index)} style={ [styles.itemStyle, itemList.length -1 === index ? {
|
|
98
|
+
borderBottomWidth: 6,
|
|
99
|
+
borderBottomStyle: 'solid',
|
|
100
|
+
borderBottomColor: '#f7f7f7'
|
|
101
|
+
} : {}] }><Text style={[styles.itemTextStyle, { color: itemColor }]}>{item}</Text></TouchableHighlight>) }
|
|
102
|
+
<View style={styles.buttonStyle}><TouchableOpacity onPress={cancelAction}><Text style={{ color: "#000000", width: "100%", textAlign: "center" }}>取消</Text></TouchableOpacity></View>
|
|
103
|
+
</Animated.View>
|
|
104
|
+
</TouchableHighlight>
|
|
105
|
+
)
|
|
103
106
|
}
|
|
104
|
-
|
|
105
|
-
|
|
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()
|
|
107
|
+
|
|
108
|
+
actionSheetKey = Portal.add(<ActionSheet/>)
|
|
123
109
|
}
|
|
124
110
|
|
|
125
111
|
export {
|
|
@@ -3,8 +3,27 @@ import { isBrowser, isReact } from '@mpxjs/utils'
|
|
|
3
3
|
global.__mpxAppCbs = global.__mpxAppCbs || {
|
|
4
4
|
show: [],
|
|
5
5
|
hide: [],
|
|
6
|
-
error: []
|
|
6
|
+
error: [],
|
|
7
|
+
rejection: []
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function off (cbs, cb) {
|
|
11
|
+
if (cb) {
|
|
12
|
+
const idx = cbs.indexOf(cb)
|
|
13
|
+
if (idx > -1) cbs.splice(idx, 1)
|
|
14
|
+
} else {
|
|
15
|
+
cbs.length = 0
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function onUnhandledRejection (callback) {
|
|
20
|
+
if (isBrowser || isReact) {
|
|
21
|
+
global.__mpxAppCbs.rejection.push(callback)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
7
24
|
|
|
25
|
+
function offUnhandledRejection (callback) {
|
|
26
|
+
off(global.__mpxAppCbs.rejection, callback)
|
|
8
27
|
}
|
|
9
28
|
|
|
10
29
|
function onError (callback) {
|
|
@@ -14,9 +33,7 @@ function onError (callback) {
|
|
|
14
33
|
}
|
|
15
34
|
|
|
16
35
|
function offError (callback) {
|
|
17
|
-
|
|
18
|
-
const index = cbs.indexOf(callback)
|
|
19
|
-
if (index > -1) cbs.splice(index, 1)
|
|
36
|
+
off(global.__mpxAppCbs.error, callback)
|
|
20
37
|
}
|
|
21
38
|
|
|
22
39
|
function onAppShow (callback) {
|
|
@@ -26,9 +43,7 @@ function onAppShow (callback) {
|
|
|
26
43
|
}
|
|
27
44
|
|
|
28
45
|
function offAppShow (callback) {
|
|
29
|
-
|
|
30
|
-
const index = cbs.indexOf(callback)
|
|
31
|
-
if (index > -1) cbs.splice(index, 1)
|
|
46
|
+
off(global.__mpxAppCbs.show, callback)
|
|
32
47
|
}
|
|
33
48
|
|
|
34
49
|
function onAppHide (callback) {
|
|
@@ -38,9 +53,7 @@ function onAppHide (callback) {
|
|
|
38
53
|
}
|
|
39
54
|
|
|
40
55
|
function offAppHide (callback) {
|
|
41
|
-
|
|
42
|
-
const index = cbs.indexOf(callback)
|
|
43
|
-
if (index > -1) cbs.splice(index, 1)
|
|
56
|
+
off(global.__mpxAppCbs.hide, callback)
|
|
44
57
|
}
|
|
45
58
|
|
|
46
59
|
export {
|
|
@@ -49,5 +62,7 @@ export {
|
|
|
49
62
|
offAppShow,
|
|
50
63
|
offAppHide,
|
|
51
64
|
onError,
|
|
52
|
-
offError
|
|
65
|
+
offError,
|
|
66
|
+
onUnhandledRejection,
|
|
67
|
+
offUnhandledRejection
|
|
53
68
|
}
|
|
@@ -85,7 +85,7 @@ class RNIntersectionObserver {
|
|
|
85
85
|
|
|
86
86
|
_getWindowRect () {
|
|
87
87
|
if (this.windowRect) return this.windowRect
|
|
88
|
-
const navigation = getFocusedNavigation()
|
|
88
|
+
const navigation = getFocusedNavigation() || {}
|
|
89
89
|
const screen = Dimensions.get('screen')
|
|
90
90
|
const navigationLayout = navigation.layout || {
|
|
91
91
|
x: 0,
|
|
@@ -96,7 +96,7 @@ class RNIntersectionObserver {
|
|
|
96
96
|
|
|
97
97
|
const windowRect = {
|
|
98
98
|
top: navigationLayout.y + this.margins.top,
|
|
99
|
-
left:
|
|
99
|
+
left: this.margins.left,
|
|
100
100
|
right: navigationLayout.width - this.margins.right,
|
|
101
101
|
bottom: navigationLayout.y + navigationLayout.height - this.margins.bottom
|
|
102
102
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { envError, defineUnsupportedProps, successHandle, failHandle } from '../../../common/js'
|
|
2
|
+
import { Image } from 'react-native'
|
|
3
|
+
|
|
4
|
+
const previewImage = envError('previewImage')
|
|
5
|
+
|
|
6
|
+
const compressImage = envError('compressImage')
|
|
7
|
+
|
|
8
|
+
const getImageInfo = function (options = {}) {
|
|
9
|
+
const { src, success, fail, complete } = options
|
|
10
|
+
if (src === undefined) {
|
|
11
|
+
const result = {
|
|
12
|
+
errMsg: 'getImageInfo:fail parameter error: parameter.src should be String instead of Undefined;',
|
|
13
|
+
errno: 1001
|
|
14
|
+
}
|
|
15
|
+
failHandle(result, fail, complete)
|
|
16
|
+
return
|
|
17
|
+
}
|
|
18
|
+
if (src === '') {
|
|
19
|
+
const result = {
|
|
20
|
+
errMsg: 'getImageInfo:fail image not found'
|
|
21
|
+
}
|
|
22
|
+
failHandle(result, fail, complete)
|
|
23
|
+
return
|
|
24
|
+
}
|
|
25
|
+
Image.getSize(src, (width, height) => {
|
|
26
|
+
const result = {
|
|
27
|
+
errMsg: 'getImageInfo:ok',
|
|
28
|
+
width,
|
|
29
|
+
height
|
|
30
|
+
}
|
|
31
|
+
defineUnsupportedProps(result, ['path', 'orientation', 'type'])
|
|
32
|
+
successHandle(result, success, complete)
|
|
33
|
+
}, (err) => {
|
|
34
|
+
const result = {
|
|
35
|
+
errMsg: 'getImageInfo:fail download image fail. reason: ' + err
|
|
36
|
+
}
|
|
37
|
+
failHandle(result, fail, complete)
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export {
|
|
42
|
+
previewImage,
|
|
43
|
+
compressImage,
|
|
44
|
+
getImageInfo
|
|
45
|
+
}
|
|
@@ -4,7 +4,10 @@ const previewImage = ENV_OBJ.previewImage || envError('previewImage')
|
|
|
4
4
|
|
|
5
5
|
const compressImage = ENV_OBJ.compressImage || envError('compressImage')
|
|
6
6
|
|
|
7
|
+
const getImageInfo = ENV_OBJ.getImageInfo || envError('getImageInfo')
|
|
8
|
+
|
|
7
9
|
export {
|
|
8
10
|
previewImage,
|
|
9
|
-
compressImage
|
|
11
|
+
compressImage,
|
|
12
|
+
getImageInfo
|
|
10
13
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Preview from './Preview'
|
|
2
|
-
import { isBrowser, throwSSRWarning, envError } from '../../../common/js'
|
|
2
|
+
import { isBrowser, throwSSRWarning, envError, defineUnsupportedProps, successHandle, failHandle } from '../../../common/js'
|
|
3
3
|
|
|
4
4
|
let preview = null
|
|
5
5
|
|
|
@@ -15,9 +15,53 @@ const previewImage = (options) => {
|
|
|
15
15
|
if (!preview) preview = new Preview()
|
|
16
16
|
preview.show(options)
|
|
17
17
|
}
|
|
18
|
+
|
|
18
19
|
const compressImage = envError('compressImage')
|
|
19
20
|
|
|
21
|
+
const getImageInfo = function (options = {}) {
|
|
22
|
+
const { src, success, fail, complete } = options
|
|
23
|
+
|
|
24
|
+
if (src === undefined) {
|
|
25
|
+
const result = {
|
|
26
|
+
errMsg: 'getImageInfo:fail parameter error: parameter.src should be String instead of Undefined;',
|
|
27
|
+
errno: 1001
|
|
28
|
+
}
|
|
29
|
+
failHandle(result, fail, complete)
|
|
30
|
+
return
|
|
31
|
+
}
|
|
32
|
+
if (src === '') {
|
|
33
|
+
const result = {
|
|
34
|
+
errMsg: 'getImageInfo:fail image not found'
|
|
35
|
+
}
|
|
36
|
+
failHandle(result, fail, complete)
|
|
37
|
+
return
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const img = new Image()
|
|
41
|
+
img.src = src
|
|
42
|
+
|
|
43
|
+
img.onload = function () {
|
|
44
|
+
const width = img.width
|
|
45
|
+
const height = img.height
|
|
46
|
+
const result = {
|
|
47
|
+
errMsg: 'getImageInfo:ok',
|
|
48
|
+
width,
|
|
49
|
+
height
|
|
50
|
+
}
|
|
51
|
+
defineUnsupportedProps(result, ['path', 'orientation', 'type'])
|
|
52
|
+
successHandle(result, success, complete)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
img.onerror = function () {
|
|
56
|
+
const result = {
|
|
57
|
+
errMsg: 'getImageInfo:fail download image fail. '
|
|
58
|
+
}
|
|
59
|
+
failHandle(result, fail, complete)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
20
63
|
export {
|
|
21
64
|
previewImage,
|
|
22
|
-
compressImage
|
|
65
|
+
compressImage,
|
|
66
|
+
getImageInfo
|
|
23
67
|
}
|
|
@@ -17,7 +17,7 @@ const showModal = function (options = {}) {
|
|
|
17
17
|
fail,
|
|
18
18
|
complete
|
|
19
19
|
} = options
|
|
20
|
-
const modalWidth = width
|
|
20
|
+
const modalWidth = width * 0.8
|
|
21
21
|
const styles = StyleSheet.create({
|
|
22
22
|
modalTask: {
|
|
23
23
|
left: 0,
|
|
@@ -53,7 +53,8 @@ const showModal = function (options = {}) {
|
|
|
53
53
|
lineHeight: 26,
|
|
54
54
|
color: '#808080',
|
|
55
55
|
paddingLeft: 20,
|
|
56
|
-
paddingRight: 20
|
|
56
|
+
paddingRight: 20,
|
|
57
|
+
textAlign: 'center'
|
|
57
58
|
},
|
|
58
59
|
modalBtnBox: {
|
|
59
60
|
borderTopWidth: StyleSheet.hairlineWidth,
|
|
@@ -67,8 +68,8 @@ const showModal = function (options = {}) {
|
|
|
67
68
|
modalBtn: {
|
|
68
69
|
flex: 1,
|
|
69
70
|
textAlign: 'center',
|
|
70
|
-
paddingTop:
|
|
71
|
-
paddingBottom:
|
|
71
|
+
paddingTop: width * 0.04,
|
|
72
|
+
paddingBottom: width * 0.04,
|
|
72
73
|
},
|
|
73
74
|
modalButton: {
|
|
74
75
|
width: '100%',
|
|
@@ -88,9 +89,8 @@ const showModal = function (options = {}) {
|
|
|
88
89
|
let editableContent = []
|
|
89
90
|
let modalButton = [{
|
|
90
91
|
text: confirmText,
|
|
91
|
-
confirmColor,
|
|
92
92
|
type: 'confirm',
|
|
93
|
-
color:
|
|
93
|
+
color: confirmColor
|
|
94
94
|
}]
|
|
95
95
|
let contentText = content
|
|
96
96
|
const onChangeText = function (text) {
|
|
@@ -128,10 +128,9 @@ const showModal = function (options = {}) {
|
|
|
128
128
|
if (showCancel) {
|
|
129
129
|
modalButton.unshift({
|
|
130
130
|
text: cancelText,
|
|
131
|
-
cancelColor,
|
|
132
131
|
type: 'cancel',
|
|
133
132
|
style: styles.cancelStyle,
|
|
134
|
-
color:
|
|
133
|
+
color: cancelColor
|
|
135
134
|
})
|
|
136
135
|
}
|
|
137
136
|
ModalView = <View style={styles.modalTask}>
|
|
@@ -107,10 +107,9 @@ function request (options = { url: '' }) {
|
|
|
107
107
|
errMsg: `request:fail ${err}`,
|
|
108
108
|
statusCode: response.status,
|
|
109
109
|
header: response.headers,
|
|
110
|
-
data: response.data
|
|
111
|
-
stack: realError.stack,
|
|
112
|
-
...realError
|
|
110
|
+
data: response.data
|
|
113
111
|
}
|
|
112
|
+
Object.assign(res, realError)
|
|
114
113
|
failHandle(res, fail, complete)
|
|
115
114
|
})
|
|
116
115
|
|
|
@@ -17,7 +17,12 @@ function setNavigationBarColor (options = {}) {
|
|
|
17
17
|
return ENV_OBJ.setNavigationBar(options)
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
function hideHomeButton (options = {}) {
|
|
21
|
+
return ENV_OBJ.hideBackHome(options)
|
|
22
|
+
}
|
|
23
|
+
|
|
20
24
|
export {
|
|
21
25
|
setNavigationBarTitle,
|
|
22
|
-
setNavigationBarColor
|
|
26
|
+
setNavigationBarColor,
|
|
27
|
+
hideHomeButton
|
|
23
28
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { successHandle, failHandle, getFocusedNavigation } from '../../../common/js'
|
|
1
|
+
import { successHandle, failHandle, getFocusedNavigation, envError } from '../../../common/js'
|
|
2
2
|
import { nextTick } from '../next-tick'
|
|
3
3
|
function setNavigationBarTitle (options = {}) {
|
|
4
4
|
const { title = '', success, fail, complete } = options
|
|
@@ -7,7 +7,7 @@ function setNavigationBarTitle (options = {}) {
|
|
|
7
7
|
failHandle({ errMsg: 'setNavigationBarTitle:fail' }, fail, complete)
|
|
8
8
|
} else {
|
|
9
9
|
nextTick(() => {
|
|
10
|
-
navigation.setOptions({
|
|
10
|
+
navigation.setOptions({ title })
|
|
11
11
|
successHandle({ errMsg: 'setNavigationBarTitle:ok' }, success, complete)
|
|
12
12
|
})
|
|
13
13
|
}
|
|
@@ -31,7 +31,10 @@ function setNavigationBarColor (options = {}) {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
const hideHomeButton = envError('hideHomeButton')
|
|
35
|
+
|
|
34
36
|
export {
|
|
35
37
|
setNavigationBarTitle,
|
|
36
|
-
setNavigationBarColor
|
|
38
|
+
setNavigationBarColor,
|
|
39
|
+
hideHomeButton
|
|
37
40
|
}
|
|
@@ -4,7 +4,10 @@ const setNavigationBarTitle = ENV_OBJ.setNavigationBarTitle || envError('setNavi
|
|
|
4
4
|
|
|
5
5
|
const setNavigationBarColor = ENV_OBJ.setNavigationBarColor || envError('setNavigationBarColor')
|
|
6
6
|
|
|
7
|
+
const hideHomeButton = ENV_OBJ.hideHomeButton || envError('hideHomeButton')
|
|
8
|
+
|
|
7
9
|
export {
|
|
8
10
|
setNavigationBarTitle,
|
|
9
|
-
setNavigationBarColor
|
|
11
|
+
setNavigationBarColor,
|
|
12
|
+
hideHomeButton
|
|
10
13
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isBrowser, throwSSRWarning, successHandle } from '../../../common/js'
|
|
1
|
+
import { isBrowser, envError, throwSSRWarning, successHandle } from '../../../common/js'
|
|
2
2
|
|
|
3
3
|
function setNavigationBarTitle (options = {}) {
|
|
4
4
|
if (!isBrowser) {
|
|
@@ -26,7 +26,10 @@ function setNavigationBarColor (options = {}) {
|
|
|
26
26
|
successHandle({ errMsg: 'setNavigationBarColor:ok' }, success, complete)
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
const hideHomeButton = envError('hideHomeButton')
|
|
30
|
+
|
|
29
31
|
export {
|
|
30
32
|
setNavigationBarTitle,
|
|
31
|
-
setNavigationBarColor
|
|
33
|
+
setNavigationBarColor,
|
|
34
|
+
hideHomeButton
|
|
32
35
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ENV_OBJ, envError } from '../../../common/js'
|
|
2
|
+
|
|
3
|
+
const getSetting = ENV_OBJ.getSetting || envError('getSetting')
|
|
4
|
+
|
|
5
|
+
const openSetting = ENV_OBJ.openSetting || envError('openSetting')
|
|
6
|
+
|
|
7
|
+
const enableAlertBeforeUnload = ENV_OBJ.enableAlertBeforeUnload || envError('enableAlertBeforeUnload')
|
|
8
|
+
|
|
9
|
+
const disableAlertBeforeUnload = ENV_OBJ.disableAlertBeforeUnload || envError('disableAlertBeforeUnload')
|
|
10
|
+
|
|
11
|
+
const getMenuButtonBoundingClientRect = ENV_OBJ.getMenuButtonBoundingClientRect || envError('getMenuButtonBoundingClientRect')
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
getSetting,
|
|
15
|
+
openSetting,
|
|
16
|
+
enableAlertBeforeUnload,
|
|
17
|
+
disableAlertBeforeUnload,
|
|
18
|
+
getMenuButtonBoundingClientRect
|
|
19
|
+
}
|
|
@@ -1 +1,84 @@
|
|
|
1
|
-
|
|
1
|
+
import DeviceInfo from 'react-native-device-info'
|
|
2
|
+
import { PixelRatio } from 'react-native'
|
|
3
|
+
import { successHandle, failHandle, defineUnsupportedProps } from '../../../common/js'
|
|
4
|
+
import { getWindowInfo, getLaunchOptionsSync, getEnterOptionsSync } from './rnSystem'
|
|
5
|
+
|
|
6
|
+
const getSystemInfoSync = function () {
|
|
7
|
+
const windowInfo = getWindowInfo()
|
|
8
|
+
const { screenWidth, screenHeight } = windowInfo
|
|
9
|
+
|
|
10
|
+
const result = {
|
|
11
|
+
brand: DeviceInfo.getBrand(),
|
|
12
|
+
model: DeviceInfo.getModel(),
|
|
13
|
+
system: `${DeviceInfo.getSystemName()} ${DeviceInfo.getSystemVersion()}`,
|
|
14
|
+
platform: DeviceInfo.isEmulatorSync() ? 'emulator' : DeviceInfo.getSystemName(),
|
|
15
|
+
deviceOrientation: screenWidth > screenHeight ? 'portrait' : 'landscape',
|
|
16
|
+
fontSizeSetting: PixelRatio.getFontScale()
|
|
17
|
+
}
|
|
18
|
+
Object.assign(result, windowInfo)
|
|
19
|
+
defineUnsupportedProps(result, [
|
|
20
|
+
'language',
|
|
21
|
+
'version',
|
|
22
|
+
'SDKVersion',
|
|
23
|
+
'benchmarkLevel',
|
|
24
|
+
'albumAuthorized',
|
|
25
|
+
'cameraAuthorized',
|
|
26
|
+
'locationAuthorized',
|
|
27
|
+
'microphoneAuthorized',
|
|
28
|
+
'notificationAuthorized',
|
|
29
|
+
'phoneCalendarAuthorized',
|
|
30
|
+
'host',
|
|
31
|
+
'enableDebug',
|
|
32
|
+
'notificationAlertAuthorized',
|
|
33
|
+
'notificationBadgeAuthorized',
|
|
34
|
+
'notificationSoundAuthorized',
|
|
35
|
+
'bluetoothEnabled',
|
|
36
|
+
'locationEnabled',
|
|
37
|
+
'wifiEnabled',
|
|
38
|
+
'locationReducedAccuracy',
|
|
39
|
+
'theme'
|
|
40
|
+
])
|
|
41
|
+
return result
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const getSystemInfo = function (options = {}) {
|
|
45
|
+
const { success, fail, complete } = options
|
|
46
|
+
try {
|
|
47
|
+
const systemInfo = getSystemInfoSync()
|
|
48
|
+
Object.assign(systemInfo, {
|
|
49
|
+
errMsg: 'setStorage:ok'
|
|
50
|
+
})
|
|
51
|
+
successHandle(systemInfo, success, complete)
|
|
52
|
+
} catch (err) {
|
|
53
|
+
const result = {
|
|
54
|
+
errMsg: `getSystemInfo:fail ${err}`
|
|
55
|
+
}
|
|
56
|
+
failHandle(result, fail, complete)
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const getDeviceInfo = function () {
|
|
61
|
+
const deviceInfo = {}
|
|
62
|
+
if (__mpx_mode__ === 'android') {
|
|
63
|
+
const deviceAbi = DeviceInfo.supported64BitAbisSync() || []
|
|
64
|
+
deviceInfo.deviceAbi = deviceAbi[0] || null
|
|
65
|
+
}
|
|
66
|
+
defineUnsupportedProps(deviceInfo, ['benchmarkLevel', 'abi', 'cpuType'])
|
|
67
|
+
Object.assign(deviceInfo, {
|
|
68
|
+
brand: DeviceInfo.getBrand(),
|
|
69
|
+
model: DeviceInfo.getModel(),
|
|
70
|
+
system: `${DeviceInfo.getSystemName()} ${DeviceInfo.getSystemVersion()}`,
|
|
71
|
+
platform: DeviceInfo.isEmulatorSync() ? 'emulator' : DeviceInfo.getSystemName(),
|
|
72
|
+
memorySize: DeviceInfo.getTotalMemorySync() / (1024 * 1024)
|
|
73
|
+
})
|
|
74
|
+
return deviceInfo
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export {
|
|
78
|
+
getSystemInfo,
|
|
79
|
+
getSystemInfoSync,
|
|
80
|
+
getDeviceInfo,
|
|
81
|
+
getWindowInfo,
|
|
82
|
+
getLaunchOptionsSync,
|
|
83
|
+
getEnterOptionsSync
|
|
84
|
+
}
|