@mpxjs/api-proxy 2.9.67 → 2.9.69-beta.1
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/package.json +3 -4
- package/src/common/js/promisify.js +11 -3
- package/src/platform/api/action-sheet/rnActionSheet.jsx +69 -81
- package/src/platform/api/app/index.web.js +26 -11
- package/src/platform/api/create-intersection-observer/rnIntersectionObserver.js +14 -10
- package/src/platform/api/create-selector-query/rnNodesRef.js +1 -6
- 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/next-tick/index.ios.js +7 -1
- package/src/platform/api/request/index.web.js +2 -3
- package/src/platform/api/route/index.ios.js +18 -8
- 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/storage/index.web.js +1 -1
- package/src/platform/api/storage/rnStorage.js +1 -1
- package/src/platform/api/system/index.ali.js +7 -1
- package/src/platform/api/system/index.ios.js +84 -1
- package/src/platform/api/system/index.js +7 -1
- package/src/platform/api/system/index.web.js +77 -16
- package/src/platform/api/system/rnSystem.js +48 -69
- package/src/platform/api/toast/rnToast.jsx +23 -16
- package/src/platform/index.js +4 -4
- package/LICENSE +0 -433
- package/src/platform/api/lifecycle/index.ali.js +0 -9
- package/src/platform/api/lifecycle/index.js +0 -7
- package/src/platform/api/lifecycle/index.web.js +0 -12
- package/src/platform/api/system/rnWindowInfo.js +0 -42
package/@types/index.d.ts
CHANGED
|
@@ -110,6 +110,19 @@ export const createVideoContext: WechatMiniprogram.Wx['createVideoContext']
|
|
|
110
110
|
export const onWindowResize: WechatMiniprogram.Wx['onWindowResize']
|
|
111
111
|
export const offWindowResize: WechatMiniprogram.Wx['offWindowResize']
|
|
112
112
|
export const createAnimation: WechatMiniprogram.Wx['createAnimation']
|
|
113
|
+
export const hideHomeButton: WechatMiniprogram.Wx['hideHomeButton']
|
|
114
|
+
export const getSetting: WechatMiniprogram.Wx['getSetting']
|
|
115
|
+
export const openSetting: WechatMiniprogram.Wx['openSetting']
|
|
116
|
+
export const enableAlertBeforeUnload: WechatMiniprogram.Wx['enableAlertBeforeUnload']
|
|
117
|
+
export const disableAlertBeforeUnload: WechatMiniprogram.Wx['disableAlertBeforeUnload']
|
|
118
|
+
export const getMenuButtonBoundingClientRect: WechatMiniprogram.Wx['getMenuButtonBoundingClientRect']
|
|
119
|
+
export const getImageInfo: WechatMiniprogram.Wx['getImageInfo']
|
|
120
|
+
export const vibrateShort: WechatMiniprogram.Wx['vibrateShort']
|
|
121
|
+
export const vibrateLong: WechatMiniprogram.Wx['vibrateLong']
|
|
122
|
+
export const getExtConfig: WechatMiniprogram.Wx['getExtConfig']
|
|
123
|
+
export const getExtConfigSync: WechatMiniprogram.Wx['getExtConfigSync']
|
|
124
|
+
export const openLocation: WechatMiniprogram.Wx['openLocation']
|
|
125
|
+
export const chooseLocation: WechatMiniprogram.Wx['chooseLocation']
|
|
113
126
|
|
|
114
127
|
declare const install: (...args: any) => any
|
|
115
128
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/api-proxy",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.69-beta.1",
|
|
4
4
|
"description": "convert miniprogram API at each end",
|
|
5
5
|
"module": "src/index.js",
|
|
6
6
|
"types": "@types/index.d.ts",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"homepage": "https://github.com/didi/mpx#readme",
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@mpxjs/utils": "^2.9.
|
|
40
|
+
"@mpxjs/utils": "^2.9.69",
|
|
41
41
|
"axios": "^1.7.3"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
@@ -71,6 +71,5 @@
|
|
|
71
71
|
"react-native-haptic-feedback": {
|
|
72
72
|
"optional": true
|
|
73
73
|
}
|
|
74
|
-
}
|
|
75
|
-
"gitHead": "b23d3850c16543c5998811b8d1d8e6ee7988c0f8"
|
|
74
|
+
}
|
|
76
75
|
}
|
|
@@ -70,14 +70,22 @@ function promisify (listObj, whiteList, customBlackList) {
|
|
|
70
70
|
result[key] = function (...args) {
|
|
71
71
|
const obj = args[0] || {}
|
|
72
72
|
// 不需要转换 or 用户已定义回调,则不处理
|
|
73
|
-
if (!promisifyFilter(key)
|
|
73
|
+
if (!promisifyFilter(key)) {
|
|
74
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
|
-
obj.success
|
|
80
|
-
obj.fail
|
|
79
|
+
const originSuccess = obj.success
|
|
80
|
+
const originFail = obj.fail
|
|
81
|
+
obj.success = function (res) {
|
|
82
|
+
originSuccess && originSuccess.call(this, res)
|
|
83
|
+
resolve(res)
|
|
84
|
+
}
|
|
85
|
+
obj.fail = function (e) {
|
|
86
|
+
originFail && originFail.call(this, e)
|
|
87
|
+
reject(e)
|
|
88
|
+
}
|
|
81
89
|
returned = listObj[key].apply(ENV_OBJ, args)
|
|
82
90
|
})
|
|
83
91
|
promise.__returned = returned
|
|
@@ -1,38 +1,17 @@
|
|
|
1
|
-
import { View,
|
|
1
|
+
import { View, Text, StyleSheet } 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,64 @@ 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, e) {
|
|
68
|
+
e.stopPropagation()
|
|
69
|
+
const result = {
|
|
70
|
+
errMsg: 'showActionSheet:ok',
|
|
71
|
+
tapIndex: index
|
|
72
|
+
}
|
|
73
|
+
successHandle(result, success, complete)
|
|
74
|
+
remove()
|
|
89
75
|
}
|
|
90
|
-
|
|
91
|
-
remove()
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
76
|
+
|
|
77
|
+
const remove = function () {
|
|
78
|
+
if (actionSheetKey) {
|
|
79
|
+
slideOut()
|
|
80
|
+
setTimeout(() => {
|
|
81
|
+
Portal.remove(actionSheetKey)
|
|
82
|
+
actionSheetKey = null
|
|
83
|
+
}, 200)
|
|
84
|
+
}
|
|
96
85
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
86
|
+
|
|
87
|
+
const cancelAction = function (e) {
|
|
88
|
+
e.stopPropagation()
|
|
89
|
+
const result = {
|
|
90
|
+
errMsg: 'showActionSheet:fail cancel'
|
|
91
|
+
}
|
|
92
|
+
failHandle(result, fail, complete)
|
|
93
|
+
remove()
|
|
94
|
+
}
|
|
95
|
+
return (
|
|
96
|
+
<View onTouchEnd={cancelAction} style={styles.actionActionMask}>
|
|
97
|
+
<Animated.View style={[styles.actionSheetContent, animatedStyles]}>
|
|
98
|
+
{ alertText ? <View style={ styles.itemStyle }><Text style={[styles.itemTextStyle, { color: '#666666' }]}>{alertText}</Text></View> : null }
|
|
99
|
+
{ itemList.map((item, index) => <View key={index} onTouchEnd={(e) => selectAction(index, e)} style={ [styles.itemStyle, itemList.length -1 === index ? {
|
|
100
|
+
borderBottomWidth: 6,
|
|
101
|
+
borderBottomStyle: 'solid',
|
|
102
|
+
borderBottomColor: '#f7f7f7'
|
|
103
|
+
} : {}] }><Text style={[styles.itemTextStyle, { color: itemColor }]}>{item}</Text></View>) }
|
|
104
|
+
<View style={styles.buttonStyle} onTouchEnd={cancelAction}><Text style={{ color: "#000000", width: "100%", textAlign: "center" }}>取消</Text></View>
|
|
105
|
+
</Animated.View>
|
|
106
|
+
</View>
|
|
107
|
+
)
|
|
103
108
|
}
|
|
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()
|
|
109
|
+
|
|
110
|
+
actionSheetKey = Portal.add(<ActionSheet/>)
|
|
123
111
|
}
|
|
124
112
|
|
|
125
113
|
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
|
}
|
|
@@ -12,10 +12,14 @@ class RNIntersectionObserver {
|
|
|
12
12
|
constructor (component, options, intersectionCtx) {
|
|
13
13
|
this.id = idCount++
|
|
14
14
|
this.component = component
|
|
15
|
-
this.options =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
this.options = Object.assign({
|
|
16
|
+
thresholds: [0],
|
|
17
|
+
initialRatio: 0,
|
|
18
|
+
observeAll: false
|
|
19
|
+
}, options || {})
|
|
20
|
+
this.thresholds = this.options.thresholds.sort((a, b) => a - b) || [0]
|
|
21
|
+
this.initialRatio = this.options.initialRatio
|
|
22
|
+
this.observeAll = this.options.observeAll
|
|
19
23
|
|
|
20
24
|
// 组件上挂载对应的observers,用于在组件销毁的时候进行批量disconnect
|
|
21
25
|
this.component._intersectionObservers = this.component.__intersectionObservers || []
|
|
@@ -26,7 +30,7 @@ class RNIntersectionObserver {
|
|
|
26
30
|
this.margins = DefaultMargin
|
|
27
31
|
this.callback = noop
|
|
28
32
|
|
|
29
|
-
this.throttleMeasure = this.getThrottleMeasure(options.throttleTime || 100)
|
|
33
|
+
this.throttleMeasure = this.getThrottleMeasure(this.options.throttleTime || 100)
|
|
30
34
|
|
|
31
35
|
// 记录上一次相交的比例
|
|
32
36
|
this.previousIntersectionRatio = []
|
|
@@ -65,7 +69,7 @@ class RNIntersectionObserver {
|
|
|
65
69
|
|
|
66
70
|
observe (selector, callback) {
|
|
67
71
|
if (this.observerRefs) {
|
|
68
|
-
console.
|
|
72
|
+
console.warn('"observe" call can be only called once in IntersectionObserver')
|
|
69
73
|
return
|
|
70
74
|
}
|
|
71
75
|
let targetRef = null
|
|
@@ -75,7 +79,7 @@ class RNIntersectionObserver {
|
|
|
75
79
|
targetRef = this.component.__selectRef(selector, 'node')
|
|
76
80
|
}
|
|
77
81
|
if (!targetRef || targetRef.length === 0) {
|
|
78
|
-
console.
|
|
82
|
+
console.warn('intersection observer target not found')
|
|
79
83
|
return
|
|
80
84
|
}
|
|
81
85
|
this.observerRefs = isArray(targetRef) ? targetRef : [targetRef]
|
|
@@ -85,9 +89,9 @@ class RNIntersectionObserver {
|
|
|
85
89
|
|
|
86
90
|
_getWindowRect () {
|
|
87
91
|
if (this.windowRect) return this.windowRect
|
|
88
|
-
const navigation = getFocusedNavigation()
|
|
92
|
+
const navigation = getFocusedNavigation() || {}
|
|
89
93
|
const screen = Dimensions.get('screen')
|
|
90
|
-
const navigationLayout = navigation.layout
|
|
94
|
+
const navigationLayout = navigation.layout || {
|
|
91
95
|
x: 0,
|
|
92
96
|
y: 0,
|
|
93
97
|
width: screen.width,
|
|
@@ -96,7 +100,7 @@ class RNIntersectionObserver {
|
|
|
96
100
|
|
|
97
101
|
const windowRect = {
|
|
98
102
|
top: navigationLayout.y + this.margins.top,
|
|
99
|
-
left:
|
|
103
|
+
left: this.margins.left,
|
|
100
104
|
right: navigationLayout.width - this.margins.right,
|
|
101
105
|
bottom: navigationLayout.y + navigationLayout.height - this.margins.bottom
|
|
102
106
|
}
|
|
@@ -84,12 +84,7 @@ const getComputedStyle = (config = []) => {
|
|
|
84
84
|
return wrapFn((nodeInstance, resolve) => {
|
|
85
85
|
config = new Set(config)
|
|
86
86
|
const res = {}
|
|
87
|
-
const
|
|
88
|
-
const defaultStyle = nodeInstance.instance.defaultStyle || {}
|
|
89
|
-
const computedStyle = {
|
|
90
|
-
...defaultStyle,
|
|
91
|
-
...styles
|
|
92
|
-
}
|
|
87
|
+
const computedStyle = nodeInstance.instance.style || {}
|
|
93
88
|
config.forEach((key) => {
|
|
94
89
|
const humpKey = dash2hump(key)
|
|
95
90
|
// 取 style 的 key 是根据传入的 key 来设置,传什么设置什么 key,只不过取值需要做兼容
|
|
@@ -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
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { successHandle, failHandle } from '../../../common/js'
|
|
2
2
|
import { parseUrlQuery as parseUrl } from '@mpxjs/utils'
|
|
3
|
+
import { nextTick } from '../next-tick'
|
|
3
4
|
|
|
4
5
|
function getBasePath (navigation) {
|
|
5
6
|
if (navigation) {
|
|
@@ -75,14 +76,23 @@ function navigateBack (options = {}) {
|
|
|
75
76
|
const navigation = Object.values(global.__mpxPagesMap || {})[0]?.[1]
|
|
76
77
|
const navigationHelper = global.__navigationHelper
|
|
77
78
|
if (navigation && navigationHelper) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
79
|
+
const delta = options.delta || 1
|
|
80
|
+
const routeLength = navigation.getState().routes.length
|
|
81
|
+
if (delta >= routeLength && global.__mpx?.config.rnConfig.onAppBack?.(delta - routeLength + 1)) {
|
|
82
|
+
nextTick(() => {
|
|
83
|
+
const res = { errMsg: 'navigateBack:ok' }
|
|
84
|
+
successHandle(res, options.success, options.complete)
|
|
85
|
+
})
|
|
86
|
+
} else {
|
|
87
|
+
navigation.pop(delta)
|
|
88
|
+
navigationHelper.lastSuccessCallback = () => {
|
|
89
|
+
const res = { errMsg: 'navigateBack:ok' }
|
|
90
|
+
successHandle(res, options.success, options.complete)
|
|
91
|
+
}
|
|
92
|
+
navigationHelper.lastFailCallback = (msg) => {
|
|
93
|
+
const res = { errMsg: `navigateBack:fail ${msg}` }
|
|
94
|
+
failHandle(res, options.fail, options.complete)
|
|
95
|
+
}
|
|
86
96
|
}
|
|
87
97
|
}
|
|
88
98
|
}
|
|
@@ -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
|
}
|