@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
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { View, Dimensions, Text, StyleSheet, TouchableOpacity, ScrollView } from 'react-native'
|
|
2
|
+
import { successHandle, failHandle } from '../../../common/js'
|
|
3
|
+
import { Portal } from '@ant-design/react-native'
|
|
4
|
+
const { width, height } = Dimensions.get('window')
|
|
5
|
+
const showModal = function (options) {
|
|
6
|
+
const {
|
|
7
|
+
title,
|
|
8
|
+
content,
|
|
9
|
+
showCancel = true,
|
|
10
|
+
cancelText = '取消',
|
|
11
|
+
cancelColor = '#000000',
|
|
12
|
+
confirmText = '确定',
|
|
13
|
+
confirmColor = '#576B95',
|
|
14
|
+
editable = false,
|
|
15
|
+
placeholderText,
|
|
16
|
+
success,
|
|
17
|
+
fail,
|
|
18
|
+
complete
|
|
19
|
+
} = options
|
|
20
|
+
const modalWidth = width - 60
|
|
21
|
+
const styles = StyleSheet.create({
|
|
22
|
+
modalTask: {
|
|
23
|
+
width,
|
|
24
|
+
height,
|
|
25
|
+
justifyContent: 'center',
|
|
26
|
+
alignItems: 'center',
|
|
27
|
+
backgroundColor: 'rgba(0,0,0,0.6)',
|
|
28
|
+
position: 'absolute'
|
|
29
|
+
},
|
|
30
|
+
modalContent: {
|
|
31
|
+
paddingTop: 20,
|
|
32
|
+
width: modalWidth,
|
|
33
|
+
backgroundColor: '#ffffff',
|
|
34
|
+
borderRadius: 15,
|
|
35
|
+
justifyContent: 'center',
|
|
36
|
+
alignItems: 'center'
|
|
37
|
+
},
|
|
38
|
+
modalTitleText: {
|
|
39
|
+
fontSize: 18,
|
|
40
|
+
fontWeight: 'bold',
|
|
41
|
+
paddingLeft: 20,
|
|
42
|
+
paddingRight: 20
|
|
43
|
+
},
|
|
44
|
+
contentBox: {
|
|
45
|
+
maxHeight: height * 0.45,
|
|
46
|
+
marginTop: 10
|
|
47
|
+
},
|
|
48
|
+
modalContentText: {
|
|
49
|
+
fontSize: 16,
|
|
50
|
+
lineHeight: 26,
|
|
51
|
+
color: '#808080',
|
|
52
|
+
paddingLeft: 20,
|
|
53
|
+
paddingRight: 20
|
|
54
|
+
},
|
|
55
|
+
modalBtnBox: {
|
|
56
|
+
borderTopWidth: StyleSheet.hairlineWidth,
|
|
57
|
+
borderTopColor: 'rgba(0,0,0,0.2)',
|
|
58
|
+
borderStyle: 'solid',
|
|
59
|
+
marginTop: 25,
|
|
60
|
+
width: '100%',
|
|
61
|
+
display: 'flex',
|
|
62
|
+
flexDirection: 'row'
|
|
63
|
+
},
|
|
64
|
+
modalBtn: {
|
|
65
|
+
flex: 1,
|
|
66
|
+
textAlign: 'center',
|
|
67
|
+
paddingTop: 10,
|
|
68
|
+
paddingBottom: 10,
|
|
69
|
+
},
|
|
70
|
+
modalButton: {
|
|
71
|
+
width: '100%',
|
|
72
|
+
fontWeight: 'bold',
|
|
73
|
+
textAlign: 'center'
|
|
74
|
+
},
|
|
75
|
+
cancelStyle: {
|
|
76
|
+
borderRightWidth: StyleSheet.hairlineWidth,
|
|
77
|
+
borderRightColor: 'rgba(0,0,0,0.2)',
|
|
78
|
+
borderStyle: 'solid',
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
let modalKey
|
|
82
|
+
let ModalView
|
|
83
|
+
let modalTitle = []
|
|
84
|
+
let modalContent = []
|
|
85
|
+
let modalButton = [{
|
|
86
|
+
text: confirmText,
|
|
87
|
+
confirmColor,
|
|
88
|
+
type: 'confirm',
|
|
89
|
+
color: 'rgb(87, 107, 149)'
|
|
90
|
+
}]
|
|
91
|
+
const closeModal = function (buttonInfo) {
|
|
92
|
+
Portal.remove(modalKey)
|
|
93
|
+
modalKey = null
|
|
94
|
+
const result = {
|
|
95
|
+
errMsg: 'showModal:ok'
|
|
96
|
+
}
|
|
97
|
+
if (buttonInfo.type === 'confirm') {
|
|
98
|
+
Object.assign(result, {
|
|
99
|
+
confirm: true,
|
|
100
|
+
cancel: false,
|
|
101
|
+
content: null
|
|
102
|
+
})
|
|
103
|
+
} else {
|
|
104
|
+
Object.assign(result, {
|
|
105
|
+
confirm: false,
|
|
106
|
+
cancel: true
|
|
107
|
+
})
|
|
108
|
+
}
|
|
109
|
+
successHandle(result, success, complete)
|
|
110
|
+
}
|
|
111
|
+
if (title) {
|
|
112
|
+
modalTitle.push(title)
|
|
113
|
+
}
|
|
114
|
+
if (!editable && content) {
|
|
115
|
+
modalContent.push(content)
|
|
116
|
+
}
|
|
117
|
+
if (showCancel) {
|
|
118
|
+
modalButton.unshift({
|
|
119
|
+
text: cancelText,
|
|
120
|
+
cancelColor,
|
|
121
|
+
type: 'cancel',
|
|
122
|
+
style: styles.cancelStyle,
|
|
123
|
+
color: '#000000'
|
|
124
|
+
})
|
|
125
|
+
}
|
|
126
|
+
if (!editable) {
|
|
127
|
+
ModalView = <View style={styles.modalTask}>
|
|
128
|
+
<View style={styles.modalContent}>
|
|
129
|
+
{modalTitle.map((item, index) => <View key={index}><Text style={styles.modalTitleText}>{item}</Text></View>)}
|
|
130
|
+
{modalContent.map((item, index) => <ScrollView key={index} style={styles.contentBox}><Text style={styles.modalContentText}>{item}</Text></ScrollView>)}
|
|
131
|
+
<View style={styles.modalBtnBox}>
|
|
132
|
+
{modalButton.map((item, index) => <TouchableOpacity key={index} style={[ styles.modalBtn, item.style ]} onPress={() => closeModal(item)}><Text style={[styles.modalButton, { color: item.color }]}>{item.text}</Text></TouchableOpacity>)}
|
|
133
|
+
</View>
|
|
134
|
+
</View>
|
|
135
|
+
</View>
|
|
136
|
+
}
|
|
137
|
+
try {
|
|
138
|
+
modalKey = Portal.add(ModalView)
|
|
139
|
+
} catch (e) {
|
|
140
|
+
const result = {
|
|
141
|
+
errMsg: `showModal:fail invalid ${e}`
|
|
142
|
+
}
|
|
143
|
+
failHandle(result, fail, complete)
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export {
|
|
148
|
+
showModal
|
|
149
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './index.ali'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './index.ali'
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { successHandle, failHandle, isBrowser, throwSSRWarning } from '../../../common/js'
|
|
2
2
|
import { nextTick } from '../next-tick'
|
|
3
3
|
|
|
4
4
|
export function pageScrollTo (options) {
|
|
@@ -11,13 +11,13 @@ export function pageScrollTo (options) {
|
|
|
11
11
|
const { success, fail, complete } = options
|
|
12
12
|
|
|
13
13
|
if (!ms) {
|
|
14
|
-
return
|
|
14
|
+
return failHandle({
|
|
15
15
|
errMsg: 'pageScrollTo:fail'
|
|
16
16
|
}, fail, complete)
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
ms.pageScrollTo(options)
|
|
20
|
-
|
|
20
|
+
successHandle({
|
|
21
21
|
errMsg: 'pageScrollTo:ok'
|
|
22
22
|
}, success, complete)
|
|
23
23
|
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { successHandle, failHandle, throwSSRWarning, isBrowser } from '../../../common/js'
|
|
2
2
|
|
|
3
3
|
function stopPullDownRefresh (options = {}) {
|
|
4
4
|
if (!isBrowser) {
|
|
@@ -22,10 +22,10 @@ function stopPullDownRefresh (options = {}) {
|
|
|
22
22
|
}
|
|
23
23
|
if (err) {
|
|
24
24
|
const res = { errMsg: `stopPullDownRefresh:fail ${err}` }
|
|
25
|
-
|
|
25
|
+
failHandle(res, options.fail, options.complete)
|
|
26
26
|
} else {
|
|
27
27
|
const res = { errMsg: 'stopPullDownRefresh:ok' }
|
|
28
|
-
|
|
28
|
+
successHandle(res, options.success, options.complete)
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -52,10 +52,10 @@ function startPullDownRefresh (options = {}) {
|
|
|
52
52
|
}
|
|
53
53
|
if (err) {
|
|
54
54
|
const res = { errMsg: `startPullDownRefresh:fail ${err}` }
|
|
55
|
-
|
|
55
|
+
failHandle(res, options.fail, options.complete)
|
|
56
56
|
} else {
|
|
57
57
|
const res = { errMsg: 'startPullDownRefresh:ok' }
|
|
58
|
-
|
|
58
|
+
successHandle(res, options.success, options.complete)
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import axios from 'axios'
|
|
2
|
-
import {
|
|
2
|
+
import { successHandle, failHandle, defineUnsupportedProps } from '../../../common/js'
|
|
3
3
|
import RequestTask from './RequestTask'
|
|
4
4
|
|
|
5
5
|
function request (options = { url: '' }) {
|
|
@@ -70,7 +70,7 @@ function request (options = { url: '' }) {
|
|
|
70
70
|
header: res.headers
|
|
71
71
|
}
|
|
72
72
|
defineUnsupportedProps(result, ['cookies', 'profile', 'exception'])
|
|
73
|
-
|
|
73
|
+
successHandle(result, success, complete)
|
|
74
74
|
return result
|
|
75
75
|
}).catch(err => {
|
|
76
76
|
const response = err?.response || {}
|
|
@@ -80,10 +80,7 @@ function request (options = { url: '' }) {
|
|
|
80
80
|
header: response.headers,
|
|
81
81
|
data: response.data
|
|
82
82
|
}
|
|
83
|
-
|
|
84
|
-
if (!fail) {
|
|
85
|
-
return Promise.reject(res)
|
|
86
|
-
}
|
|
83
|
+
failHandle(res, fail, complete)
|
|
87
84
|
})
|
|
88
85
|
|
|
89
86
|
return requestTask
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { successHandle, failHandle } from '../../../common/js'
|
|
2
2
|
import { parseQuery } from '@mpxjs/utils'
|
|
3
3
|
|
|
4
4
|
function parseUrl (url) {
|
|
@@ -58,11 +58,11 @@ function navigateTo (options = {}) {
|
|
|
58
58
|
navigation.push(finalPath, queryObj)
|
|
59
59
|
navigationHelper.lastSuccessCallback = () => {
|
|
60
60
|
const res = { errMsg: 'navigateTo:ok' }
|
|
61
|
-
|
|
61
|
+
successHandle(res, options.success, options.complete)
|
|
62
62
|
}
|
|
63
63
|
navigationHelper.lastFailCallback = (msg) => {
|
|
64
64
|
const res = { errMsg: `navigateTo:fail ${msg}` }
|
|
65
|
-
|
|
65
|
+
failHandle(res, options.fail, options.complete)
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
}
|
|
@@ -77,11 +77,11 @@ function redirectTo (options = {}) {
|
|
|
77
77
|
navigation.replace(finalPath, queryObj)
|
|
78
78
|
navigationHelper.lastSuccessCallback = () => {
|
|
79
79
|
const res = { errMsg: 'redirectTo:ok' }
|
|
80
|
-
|
|
80
|
+
successHandle(res, options.success, options.complete)
|
|
81
81
|
}
|
|
82
82
|
navigationHelper.lastFailCallback = (msg) => {
|
|
83
83
|
const res = { errMsg: `redirectTo:fail ${msg}` }
|
|
84
|
-
|
|
84
|
+
failHandle(res, options.fail, options.complete)
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
}
|
|
@@ -93,11 +93,11 @@ function navigateBack (options = {}) {
|
|
|
93
93
|
navigation.pop(options.delta || 1)
|
|
94
94
|
navigationHelper.lastSuccessCallback = () => {
|
|
95
95
|
const res = { errMsg: 'navigateBack:ok' }
|
|
96
|
-
|
|
96
|
+
successHandle(res, options.success, options.complete)
|
|
97
97
|
}
|
|
98
98
|
navigationHelper.lastFailCallback = (msg) => {
|
|
99
99
|
const res = { errMsg: `navigateBack:fail ${msg}` }
|
|
100
|
-
|
|
100
|
+
failHandle(res, options.fail, options.complete)
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
}
|
|
@@ -120,11 +120,11 @@ function reLaunch (options = {}) {
|
|
|
120
120
|
})
|
|
121
121
|
navigationHelper.lastSuccessCallback = () => {
|
|
122
122
|
const res = { errMsg: 'redirectTo:ok' }
|
|
123
|
-
|
|
123
|
+
successHandle(res, options.success, options.complete)
|
|
124
124
|
}
|
|
125
125
|
navigationHelper.lastFailCallback = (msg) => {
|
|
126
126
|
const res = { errMsg: `redirectTo:fail ${msg}` }
|
|
127
|
-
|
|
127
|
+
failHandle(res, options.fail, options.complete)
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { successHandle, failHandle, isTabBarPage, throwSSRWarning, isBrowser } from '../../../common/js'
|
|
2
2
|
import { EventChannel } from '../event-channel'
|
|
3
3
|
|
|
4
4
|
let routeCount = 0
|
|
@@ -12,8 +12,7 @@ function redirectTo (options = {}) {
|
|
|
12
12
|
if (router) {
|
|
13
13
|
if (isTabBarPage(options.url, router)) {
|
|
14
14
|
const res = { errMsg: 'redirectTo:fail can not redirectTo a tabBar page' }
|
|
15
|
-
|
|
16
|
-
return Promise.reject(res)
|
|
15
|
+
failHandle(res, options.fail, options.complete)
|
|
17
16
|
}
|
|
18
17
|
router.__mpxAction = { type: 'redirect' }
|
|
19
18
|
if (routeCount === 0 && router.currentRoute.query.routeCount) routeCount = router.currentRoute.query.routeCount
|
|
@@ -26,11 +25,11 @@ function redirectTo (options = {}) {
|
|
|
26
25
|
},
|
|
27
26
|
() => {
|
|
28
27
|
const res = { errMsg: 'redirectTo:ok' }
|
|
29
|
-
|
|
28
|
+
successHandle(res, options.success, options.complete)
|
|
30
29
|
},
|
|
31
30
|
err => {
|
|
32
31
|
const res = { errMsg: `redirectTo:fail ${err}` }
|
|
33
|
-
|
|
32
|
+
failHandle(res, options.fail, options.complete)
|
|
34
33
|
}
|
|
35
34
|
)
|
|
36
35
|
}
|
|
@@ -45,8 +44,7 @@ function navigateTo (options = {}) {
|
|
|
45
44
|
if (router) {
|
|
46
45
|
if (isTabBarPage(options.url, router)) {
|
|
47
46
|
const res = { errMsg: 'navigateTo:fail can not navigateTo a tabBar page' }
|
|
48
|
-
|
|
49
|
-
return Promise.reject(res)
|
|
47
|
+
failHandle(res, options.fail, options.complete)
|
|
50
48
|
}
|
|
51
49
|
const eventChannel = new EventChannel()
|
|
52
50
|
router.__mpxAction = {
|
|
@@ -66,11 +64,11 @@ function navigateTo (options = {}) {
|
|
|
66
64
|
},
|
|
67
65
|
() => {
|
|
68
66
|
const res = { errMsg: 'navigateTo:ok', eventChannel }
|
|
69
|
-
|
|
67
|
+
successHandle(res, options.success, options.complete)
|
|
70
68
|
},
|
|
71
69
|
err => {
|
|
72
70
|
const res = { errMsg: `navigateTo:fail ${err}` }
|
|
73
|
-
|
|
71
|
+
failHandle(res, options.fail, options.complete)
|
|
74
72
|
}
|
|
75
73
|
)
|
|
76
74
|
}
|
|
@@ -94,7 +92,7 @@ function navigateBack (options = {}) {
|
|
|
94
92
|
}
|
|
95
93
|
router.go(-delta)
|
|
96
94
|
const res = { errMsg: 'navigateBack:ok' }
|
|
97
|
-
|
|
95
|
+
successHandle(res, options.success, options.complete)
|
|
98
96
|
}
|
|
99
97
|
}
|
|
100
98
|
|
|
@@ -127,16 +125,16 @@ function reLaunch (options = {}) {
|
|
|
127
125
|
},
|
|
128
126
|
() => {
|
|
129
127
|
const res = { errMsg: 'reLaunch:ok' }
|
|
130
|
-
|
|
128
|
+
successHandle(res, options.success, options.complete)
|
|
131
129
|
},
|
|
132
130
|
err => {
|
|
133
131
|
const res = { errMsg: `reLaunch:fail ${err}` }
|
|
134
|
-
|
|
132
|
+
failHandle(res, options.fail, options.complete)
|
|
135
133
|
}
|
|
136
134
|
)
|
|
137
135
|
}
|
|
138
136
|
const res = { errMsg: 'reLaunch:ok' }
|
|
139
|
-
|
|
137
|
+
successHandle(res, options.success, options.complete)
|
|
140
138
|
}
|
|
141
139
|
}
|
|
142
140
|
|
|
@@ -152,8 +150,7 @@ function switchTab (options = {}) {
|
|
|
152
150
|
if (toRoute.path !== currentRoute.path) {
|
|
153
151
|
if (!isTabBarPage(options.url, router)) {
|
|
154
152
|
const res = { errMsg: 'switchTab:fail can not switch to no-tabBar page!' }
|
|
155
|
-
|
|
156
|
-
return Promise.reject(res)
|
|
153
|
+
failHandle(res, options.fail, options.complete)
|
|
157
154
|
}
|
|
158
155
|
router.__mpxAction = {
|
|
159
156
|
type: 'switch',
|
|
@@ -171,17 +168,17 @@ function switchTab (options = {}) {
|
|
|
171
168
|
},
|
|
172
169
|
() => {
|
|
173
170
|
const res = { errMsg: 'switchTab:ok' }
|
|
174
|
-
|
|
171
|
+
successHandle(res, options.success, options.complete)
|
|
175
172
|
},
|
|
176
173
|
err => {
|
|
177
174
|
const res = { errMsg: `switchTab:fail ${err}` }
|
|
178
|
-
|
|
175
|
+
failHandle(res, options.fail, options.complete)
|
|
179
176
|
}
|
|
180
177
|
)
|
|
181
178
|
}
|
|
182
179
|
}
|
|
183
180
|
const res = { errMsg: 'switchTab:ok' }
|
|
184
|
-
|
|
181
|
+
successHandle(res, options.success, options.complete)
|
|
185
182
|
}
|
|
186
183
|
}
|
|
187
184
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './rnScreenBrightness'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './rnScreenBrightness'
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// import * as Brightness from 'expo-brightness'
|
|
2
|
+
import { successHandle, failHandle } from '../../../common/js'
|
|
3
|
+
//
|
|
4
|
+
// function getScreenBrightness (options) {
|
|
5
|
+
// const { success, fail, complete } = options
|
|
6
|
+
// Brightness.getBrightnessAsync().then(value => {
|
|
7
|
+
// const result = {
|
|
8
|
+
// errMsg: 'getScreenBrightness:ok',
|
|
9
|
+
// value
|
|
10
|
+
// }
|
|
11
|
+
// successHandle(result, success, complete)
|
|
12
|
+
// }).catch(() => {
|
|
13
|
+
// const result = {
|
|
14
|
+
// errMsg: 'getScreenBrightness:fail'
|
|
15
|
+
// }
|
|
16
|
+
// failHandle(result, fail, complete)
|
|
17
|
+
// })
|
|
18
|
+
// }
|
|
19
|
+
//
|
|
20
|
+
// function setScreenBrightness (options) {
|
|
21
|
+
// const { value, success, fail, complete } = options
|
|
22
|
+
// Brightness.setBrightnessAsync(value).then(() => {
|
|
23
|
+
// const result = {
|
|
24
|
+
// errMsg: 'setScreenBrightness:ok'
|
|
25
|
+
// }
|
|
26
|
+
// successHandle(result, success, complete)
|
|
27
|
+
// }).catch(() => {
|
|
28
|
+
// const result = {
|
|
29
|
+
// errMsg: 'setScreenBrightness:fail'
|
|
30
|
+
// }
|
|
31
|
+
// failHandle(result, fail, complete)
|
|
32
|
+
// })
|
|
33
|
+
// }
|
|
34
|
+
|
|
35
|
+
function getScreenBrightness (options) {
|
|
36
|
+
const { success, complete } = options
|
|
37
|
+
const result = {
|
|
38
|
+
errMsg: 'getScreenBrightness:ok'
|
|
39
|
+
}
|
|
40
|
+
successHandle(result, success, complete)
|
|
41
|
+
}
|
|
42
|
+
function setScreenBrightness (options) {
|
|
43
|
+
const { fail, complete } = options
|
|
44
|
+
const result = {
|
|
45
|
+
errMsg: 'setScreenBrightness:fail'
|
|
46
|
+
}
|
|
47
|
+
failHandle(result, fail, complete)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export {
|
|
51
|
+
getScreenBrightness,
|
|
52
|
+
setScreenBrightness
|
|
53
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './index.ios'
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { successHandle, failHandle } from '../../../common/js'
|
|
2
|
+
|
|
3
|
+
function getFocusedNavigation () {
|
|
4
|
+
for (const key in global.__mpxPagesMap) {
|
|
5
|
+
const navigation = global.__mpxPagesMap[key]?.[1]
|
|
6
|
+
if (navigation && navigation.isFocused()) {
|
|
7
|
+
return navigation
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function setNavigationBarTitle (options = {}) {
|
|
12
|
+
const { title = '', success, fail, complete } = options
|
|
13
|
+
const navigation = getFocusedNavigation()
|
|
14
|
+
if (!(navigation && navigation.setOptions)) {
|
|
15
|
+
failHandle({ errMsg: 'setNavigationBarTitle:fail' }, fail, complete)
|
|
16
|
+
} else {
|
|
17
|
+
navigation.setOptions({ headerTitle: title })
|
|
18
|
+
successHandle({ errMsg: 'setNavigationBarTitle:ok' }, success, complete)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function setNavigationBarColor (options = {}) {
|
|
23
|
+
const { frontColor = '', backgroundColor = '', success, fail, complete } = options
|
|
24
|
+
const navigation = getFocusedNavigation()
|
|
25
|
+
if (!(navigation && navigation.setOptions)) {
|
|
26
|
+
failHandle({ errMsg: 'setNavigationBarColor:fail' }, fail, complete)
|
|
27
|
+
} else {
|
|
28
|
+
navigation.setOptions({
|
|
29
|
+
headerStyle: {
|
|
30
|
+
backgroundColor: backgroundColor
|
|
31
|
+
},
|
|
32
|
+
headerTintColor: frontColor
|
|
33
|
+
})
|
|
34
|
+
successHandle({ errMsg: 'setNavigationBarColor:ok' }, success, complete)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export {
|
|
39
|
+
setNavigationBarTitle,
|
|
40
|
+
setNavigationBarColor
|
|
41
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isBrowser, throwSSRWarning,
|
|
1
|
+
import { isBrowser, throwSSRWarning, successHandle } from '../../../common/js'
|
|
2
2
|
|
|
3
3
|
function setNavigationBarTitle (options = {}) {
|
|
4
4
|
if (!isBrowser) {
|
|
@@ -10,7 +10,7 @@ function setNavigationBarTitle (options = {}) {
|
|
|
10
10
|
document.title = title
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
successHandle({ errMsg: 'setNavigationBarTitle:ok' }, success, complete)
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
function setNavigationBarColor (options = {}) {
|
|
@@ -23,7 +23,7 @@ function setNavigationBarColor (options = {}) {
|
|
|
23
23
|
meta.setAttribute('name', 'theme-color')
|
|
24
24
|
meta.setAttribute('content', backgroundColor)
|
|
25
25
|
document.head.appendChild(meta)
|
|
26
|
-
|
|
26
|
+
successHandle({ errMsg: 'setNavigationBarColor:ok' }, success, complete)
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
export {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { successHandle, failHandle } from '../../../common/js'
|
|
2
|
+
import { type } from '@mpxjs/utils'
|
|
2
3
|
|
|
3
4
|
const socketTasks = new Set()
|
|
4
5
|
|
|
@@ -43,20 +44,14 @@ class SocketTask {
|
|
|
43
44
|
const { data = '', success, fail, complete } = options
|
|
44
45
|
if (typeof data !== 'string' || type(data) !== 'ArrayBuffer') {
|
|
45
46
|
const res = { errMsg: 'sendSocketMessage:fail Unsupported data type' }
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
if (this._socket.readyState === 1) {
|
|
47
|
+
failHandle(res, fail, complete)
|
|
48
|
+
} else if (this._socket.readyState === 1) {
|
|
50
49
|
this._socket.send(data)
|
|
51
50
|
const res = { errMsg: 'sendSocketMessage:ok' }
|
|
52
|
-
|
|
53
|
-
return Promise.resolve(res)
|
|
51
|
+
successHandle(res, success, complete)
|
|
54
52
|
} else {
|
|
55
53
|
const res = { errMsg: 'sendSocketMessage:fail' }
|
|
56
|
-
|
|
57
|
-
if (!fail) {
|
|
58
|
-
return Promise.reject(res)
|
|
59
|
-
}
|
|
54
|
+
failHandle(res, fail, complete)
|
|
60
55
|
}
|
|
61
56
|
}
|
|
62
57
|
|
|
@@ -69,14 +64,10 @@ class SocketTask {
|
|
|
69
64
|
try {
|
|
70
65
|
this._socket.close()
|
|
71
66
|
const res = { errMsg: 'closeSocket:ok' }
|
|
72
|
-
|
|
73
|
-
return Promise.resolve(res)
|
|
67
|
+
successHandle(res, success, complete)
|
|
74
68
|
} catch (err) {
|
|
75
69
|
const res = { errMsg: `closeSocket:fail ${err}` }
|
|
76
|
-
|
|
77
|
-
if (!fail) {
|
|
78
|
-
return Promise.reject(res)
|
|
79
|
-
}
|
|
70
|
+
failHandle(res, fail, complete)
|
|
80
71
|
}
|
|
81
72
|
}
|
|
82
73
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './index.web'
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { warn,
|
|
1
|
+
import { warn, successHandle, failHandle, isBrowser, throwSSRWarning } from '../../../common/js'
|
|
2
2
|
import SocketTask from './SocketTask'
|
|
3
3
|
|
|
4
4
|
function connectSocket (options = { url: '' }) {
|
|
@@ -10,10 +10,10 @@ function connectSocket (options = { url: '' }) {
|
|
|
10
10
|
|
|
11
11
|
try {
|
|
12
12
|
const socketTask = new SocketTask(url, protocols)
|
|
13
|
-
|
|
13
|
+
successHandle({ errMsg: 'connectSocket:ok' }, success, complete)
|
|
14
14
|
return socketTask
|
|
15
15
|
} catch (e) {
|
|
16
|
-
|
|
16
|
+
failHandle({ errMsg: `connectSocket:fail ${e}` }, fail, complete)
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|