@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
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { successHandle, failHandle, isBrowser, throwSSRWarning } from '../../../common/js'
|
|
2
|
+
import { hasOwn } from '@mpxjs/utils'
|
|
2
3
|
|
|
3
4
|
function setStorage (options = {}) {
|
|
4
5
|
if (!isBrowser) {
|
|
@@ -11,10 +12,10 @@ function setStorage (options = {}) {
|
|
|
11
12
|
setStorageSync(key, data)
|
|
12
13
|
|
|
13
14
|
const res = { errMsg: 'setStorage:ok' }
|
|
14
|
-
|
|
15
|
+
successHandle(res, success, complete)
|
|
15
16
|
} catch (err) {
|
|
16
17
|
const res = { errMsg: `setStorage:fail ${err}` }
|
|
17
|
-
|
|
18
|
+
failHandle(res, fail, complete)
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
|
|
@@ -43,10 +44,10 @@ function getStorage (options = {}) {
|
|
|
43
44
|
|
|
44
45
|
if (result) {
|
|
45
46
|
const res = { errMsg: 'getStorage:ok', data: data }
|
|
46
|
-
|
|
47
|
+
successHandle(res, success, complete)
|
|
47
48
|
} else {
|
|
48
49
|
const res = { errMsg: 'getStorage:fail', data: null }
|
|
49
|
-
|
|
50
|
+
failHandle(res, fail, complete)
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
53
|
|
|
@@ -86,10 +87,10 @@ function getStorageInfo (options = {}) {
|
|
|
86
87
|
const info = getStorageInfoSync()
|
|
87
88
|
|
|
88
89
|
const res = Object.assign({}, { errMsg: 'getStorageInfo:ok' }, info)
|
|
89
|
-
|
|
90
|
+
successHandle(res, success, complete)
|
|
90
91
|
} catch (err) {
|
|
91
92
|
const res = { errMsg: `getStorageInfo:fail ${err}` }
|
|
92
|
-
|
|
93
|
+
failHandle(res, fail, complete)
|
|
93
94
|
}
|
|
94
95
|
}
|
|
95
96
|
|
|
@@ -116,10 +117,10 @@ function removeStorage (options = { key: '' }) {
|
|
|
116
117
|
removeStorageSync(key)
|
|
117
118
|
|
|
118
119
|
const res = { errMsg: 'removeStorage:ok' }
|
|
119
|
-
|
|
120
|
+
successHandle(res, success, complete)
|
|
120
121
|
} catch (err) {
|
|
121
122
|
const res = { errMsg: `removeStorage:fail ${err}` }
|
|
122
|
-
|
|
123
|
+
failHandle(res, fail, complete)
|
|
123
124
|
}
|
|
124
125
|
}
|
|
125
126
|
|
|
@@ -142,10 +143,10 @@ function clearStorage (options = {}) {
|
|
|
142
143
|
clearStorageSync()
|
|
143
144
|
|
|
144
145
|
const res = { errMsg: 'clearStorage:ok' }
|
|
145
|
-
|
|
146
|
+
successHandle(res, success, complete)
|
|
146
147
|
} catch (err) {
|
|
147
148
|
const res = { errMsg: `clearStorage:fail ${err}` }
|
|
148
|
-
|
|
149
|
+
failHandle(res, fail, complete)
|
|
149
150
|
}
|
|
150
151
|
}
|
|
151
152
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import AsyncStorage from '@react-native-async-storage/async-storage'
|
|
2
|
-
import { envError,
|
|
2
|
+
import { envError, successHandle, failHandle, defineUnsupportedProps } from '../../../common/js'
|
|
3
|
+
import { hasOwn } from '@mpxjs/utils'
|
|
3
4
|
function setStorage (options) {
|
|
4
5
|
const { key, data, success, fail, complete } = options
|
|
5
6
|
let obj = {}
|
|
@@ -13,13 +14,13 @@ function setStorage (options) {
|
|
|
13
14
|
const result = {
|
|
14
15
|
errMsg: `setStorage:fail ${err}`
|
|
15
16
|
}
|
|
16
|
-
|
|
17
|
+
failHandle(result, fail, complete)
|
|
17
18
|
return
|
|
18
19
|
}
|
|
19
20
|
const result = {
|
|
20
21
|
errMsg: 'setStorage:ok'
|
|
21
22
|
}
|
|
22
|
-
|
|
23
|
+
successHandle(result, success, complete)
|
|
23
24
|
})
|
|
24
25
|
}
|
|
25
26
|
|
|
@@ -31,7 +32,7 @@ function getStorage (options) {
|
|
|
31
32
|
const result = {
|
|
32
33
|
errMsg: 'getStorage:fail parameter error: parameter.key should be String instead of Undefined;'
|
|
33
34
|
}
|
|
34
|
-
|
|
35
|
+
failHandle(result, fail, complete)
|
|
35
36
|
return
|
|
36
37
|
}
|
|
37
38
|
AsyncStorage.getItem(key, (err, res) => {
|
|
@@ -39,7 +40,7 @@ function getStorage (options) {
|
|
|
39
40
|
const result = {
|
|
40
41
|
errMsg: `getStorage:fail ${err || 'data not found'}`
|
|
41
42
|
}
|
|
42
|
-
|
|
43
|
+
failHandle(result, fail, complete)
|
|
43
44
|
return
|
|
44
45
|
}
|
|
45
46
|
let item
|
|
@@ -55,7 +56,7 @@ function getStorage (options) {
|
|
|
55
56
|
errMsg: 'getStorage:ok',
|
|
56
57
|
data
|
|
57
58
|
}
|
|
58
|
-
|
|
59
|
+
successHandle(result, success, complete)
|
|
59
60
|
})
|
|
60
61
|
}
|
|
61
62
|
|
|
@@ -68,7 +69,7 @@ function getStorageInfo (options) {
|
|
|
68
69
|
const result = {
|
|
69
70
|
errMsg: `getStorage:fail ${err}`
|
|
70
71
|
}
|
|
71
|
-
|
|
72
|
+
failHandle(result, fail, complete)
|
|
72
73
|
return
|
|
73
74
|
}
|
|
74
75
|
const result = {
|
|
@@ -76,7 +77,7 @@ function getStorageInfo (options) {
|
|
|
76
77
|
errMsg: 'getStorageInfo:ok'
|
|
77
78
|
}
|
|
78
79
|
defineUnsupportedProps(result, ['currentSize', 'limitSize'])
|
|
79
|
-
|
|
80
|
+
successHandle(result, success, complete)
|
|
80
81
|
})
|
|
81
82
|
}
|
|
82
83
|
|
|
@@ -89,13 +90,13 @@ function removeStorage (options) {
|
|
|
89
90
|
const result = {
|
|
90
91
|
errMsg: `removeStorage:fail ${err}`
|
|
91
92
|
}
|
|
92
|
-
|
|
93
|
+
failHandle(result, fail, complete)
|
|
93
94
|
return
|
|
94
95
|
}
|
|
95
96
|
const result = {
|
|
96
97
|
errMsg: 'removeStorage:ok'
|
|
97
98
|
}
|
|
98
|
-
|
|
99
|
+
successHandle(result, success, complete)
|
|
99
100
|
})
|
|
100
101
|
}
|
|
101
102
|
|
|
@@ -110,13 +111,13 @@ function clearStorage (options) {
|
|
|
110
111
|
const result = {
|
|
111
112
|
errMsg: `clearStorage:fail ${err}`
|
|
112
113
|
}
|
|
113
|
-
|
|
114
|
+
failHandle(result, fail, complete)
|
|
114
115
|
return
|
|
115
116
|
}
|
|
116
117
|
const result = {
|
|
117
118
|
errMsg: 'clearStorage:ok'
|
|
118
119
|
}
|
|
119
|
-
|
|
120
|
+
successHandle(result, success, complete)
|
|
120
121
|
})
|
|
121
122
|
}
|
|
122
123
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ENV_OBJ, changeOpts, envError, handleSuccess } from '../../../common/js'
|
|
1
|
+
import { ENV_OBJ, changeOpts, envError, handleSuccess, defineUnsupportedProps } from '../../../common/js'
|
|
2
2
|
|
|
3
3
|
function getSystemInfo (options = {}) {
|
|
4
4
|
const opts = changeOpts(options)
|
|
@@ -32,7 +32,11 @@ function getSystemInfoSync () {
|
|
|
32
32
|
return res
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
const getDeviceInfo =
|
|
35
|
+
const getDeviceInfo = function () {
|
|
36
|
+
const res = ENV_OBJ.getDeviceBaseInfo
|
|
37
|
+
defineUnsupportedProps(res, ['deviceAbi', 'benchmarkLevel', 'cpuType'])
|
|
38
|
+
return res
|
|
39
|
+
}
|
|
36
40
|
|
|
37
41
|
const getWindowInfo = ENV_OBJ.getWindowInfo || envError('getWindowInfo')
|
|
38
42
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { envError, isBrowser, throwSSRWarning,
|
|
1
|
+
import { envError, isBrowser, throwSSRWarning, successHandle } from '../../../common/js'
|
|
2
2
|
|
|
3
3
|
function getSystemInfoSync () {
|
|
4
4
|
if (!isBrowser) {
|
|
@@ -76,7 +76,7 @@ function getSystemInfo (options = {}) {
|
|
|
76
76
|
}
|
|
77
77
|
const info = getSystemInfoSync()
|
|
78
78
|
const res = Object.assign({ errMsg: 'getSystemInfo:ok' }, info)
|
|
79
|
-
|
|
79
|
+
successHandle(res, options.success, options.complete)
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
const getDeviceInfo = envError('getDeviceInfo')
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import DeviceInfo from 'react-native-device-info'
|
|
2
2
|
import { Platform, PixelRatio, Dimensions, StatusBar } from 'react-native'
|
|
3
3
|
import { initialWindowMetrics } from 'react-native-safe-area-context'
|
|
4
|
-
import {
|
|
4
|
+
import { successHandle, failHandle, defineUnsupportedProps } from '../../../common/js'
|
|
5
5
|
|
|
6
6
|
const getWindowInfo = function () {
|
|
7
7
|
const dimensionsWindow = Dimensions.get('window')
|
|
@@ -84,12 +84,12 @@ const getSystemInfo = function (options) {
|
|
|
84
84
|
Object.assign(systemInfo, {
|
|
85
85
|
errMsg: 'setStorage:ok'
|
|
86
86
|
})
|
|
87
|
-
|
|
87
|
+
successHandle(systemInfo, success, complete)
|
|
88
88
|
} catch (err) {
|
|
89
89
|
const result = {
|
|
90
90
|
errMsg: `getSystemInfo:fail ${err}`
|
|
91
91
|
}
|
|
92
|
-
|
|
92
|
+
failHandle(result, fail, complete)
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { successHandle, failHandle } from '../../../common/js'
|
|
2
|
+
import { hasOwn } from '@mpxjs/utils'
|
|
2
3
|
import Vue from 'vue'
|
|
3
4
|
|
|
4
5
|
function setTabBarStyle (options = {}) {
|
|
@@ -20,9 +21,9 @@ function setTabBarStyle (options = {}) {
|
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
if (resolved) {
|
|
23
|
-
|
|
24
|
+
successHandle(resolved, options.success, options.complete)
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
+
failHandle(rejected, options.fail, options.complete)
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
function setTabBarItem (options = {}) {
|
|
@@ -49,9 +50,9 @@ function setTabBarItem (options = {}) {
|
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
if (resolved) {
|
|
52
|
-
|
|
53
|
+
successHandle(resolved, options.success, options.complete)
|
|
53
54
|
}
|
|
54
|
-
|
|
55
|
+
failHandle(rejected, options.fail, options.complete)
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
function showTabBar (options = {}) {
|
|
@@ -65,9 +66,9 @@ function showTabBar (options = {}) {
|
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
if (resolved) {
|
|
68
|
-
|
|
69
|
+
successHandle(resolved, options.success, options.complete)
|
|
69
70
|
}
|
|
70
|
-
|
|
71
|
+
failHandle(rejected, options.fail, options.complete)
|
|
71
72
|
}
|
|
72
73
|
|
|
73
74
|
function hideTabBar (options = {}) {
|
|
@@ -81,9 +82,9 @@ function hideTabBar (options = {}) {
|
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
if (resolved) {
|
|
84
|
-
|
|
85
|
+
successHandle(resolved, options.success, options.complete)
|
|
85
86
|
}
|
|
86
|
-
|
|
87
|
+
failHandle(rejected, options.fail, options.complete)
|
|
87
88
|
}
|
|
88
89
|
|
|
89
90
|
export {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { successHandle, createDom, getRootElement } from '../../../common/js'
|
|
2
2
|
import '../../../common/stylus/Toast.styl'
|
|
3
3
|
import '../../../common/stylus/Loading.styl'
|
|
4
4
|
|
|
@@ -71,11 +71,10 @@ export default class Toast {
|
|
|
71
71
|
this.title.textContent = opts.title || ''
|
|
72
72
|
|
|
73
73
|
this.toast.classList.add('show')
|
|
74
|
-
|
|
75
74
|
opts.duration >= 0 && this.hide({ duration: opts.duration }, type)
|
|
76
75
|
|
|
77
76
|
const errMsg = type === 'loading' ? 'showLoading:ok' : 'showToast:ok'
|
|
78
|
-
|
|
77
|
+
successHandle({ errMsg }, opts.success, opts.complete)
|
|
79
78
|
}
|
|
80
79
|
|
|
81
80
|
hide (options = {}, type) {
|
|
@@ -83,7 +82,7 @@ export default class Toast {
|
|
|
83
82
|
|
|
84
83
|
const duration = options.duration || 0
|
|
85
84
|
const errMsg = type === 'loading' ? 'hideLoading:ok' : 'hideToast:ok'
|
|
86
|
-
|
|
85
|
+
successHandle({ errMsg }, options.success, options.complete)
|
|
87
86
|
|
|
88
87
|
if (this.hideTimer) {
|
|
89
88
|
clearTimeout(this.hideTimer)
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './rnToast'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './rnToast'
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { View, Text, Image, StyleSheet, ActivityIndicator } from 'react-native'
|
|
2
|
+
import { successHandle, failHandle } from '../../../common/js'
|
|
3
|
+
import { Portal } from '@ant-design/react-native'
|
|
4
|
+
import successPng from './success.png'
|
|
5
|
+
import errorPng from './error.png'
|
|
6
|
+
|
|
7
|
+
let toastKey
|
|
8
|
+
let isLoadingShow
|
|
9
|
+
let tId // show duration 计时id
|
|
10
|
+
const styles = StyleSheet.create({
|
|
11
|
+
toastContent: {
|
|
12
|
+
minWdth: 150,
|
|
13
|
+
maxWidth: '60%',
|
|
14
|
+
backgroundColor: 'rgba(20, 20, 20, 0.7)',
|
|
15
|
+
paddingTop: 15,
|
|
16
|
+
paddingBottom: 15,
|
|
17
|
+
paddingLeft: 20,
|
|
18
|
+
paddingRight: 20,
|
|
19
|
+
borderRadius: 5,
|
|
20
|
+
display: 'flex',
|
|
21
|
+
flexDirection: 'column',
|
|
22
|
+
justifyContent: 'center',
|
|
23
|
+
alignItems: 'center'
|
|
24
|
+
},
|
|
25
|
+
toastWrap: {
|
|
26
|
+
left: 0,
|
|
27
|
+
right: 0,
|
|
28
|
+
top: 0,
|
|
29
|
+
bottom: 0,
|
|
30
|
+
zIndex: 10000,
|
|
31
|
+
position: "absolute",
|
|
32
|
+
display: 'flex',
|
|
33
|
+
justifyContent: 'center',
|
|
34
|
+
alignItems: 'center'
|
|
35
|
+
},
|
|
36
|
+
toastImg: {
|
|
37
|
+
width: 40,
|
|
38
|
+
height: 40,
|
|
39
|
+
marginLeft: 'auto',
|
|
40
|
+
marginRight: 'auto',
|
|
41
|
+
marginBottom: 10
|
|
42
|
+
},
|
|
43
|
+
toastText: {
|
|
44
|
+
textAlign: 'center',
|
|
45
|
+
color: '#ffffff',
|
|
46
|
+
fontSize: 14,
|
|
47
|
+
lineHeight: 18,
|
|
48
|
+
height: 18,
|
|
49
|
+
overflow: 'hidden'
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
function showToast (options) {
|
|
53
|
+
const { title, icon = 'success', image, duration = 1500, mask = false, success, fail, complete, isLoading } = options
|
|
54
|
+
let ToastView
|
|
55
|
+
const iconImg = {
|
|
56
|
+
success: successPng,
|
|
57
|
+
fail: errorPng
|
|
58
|
+
}
|
|
59
|
+
const pointerEvents = mask ? 'auto' : 'none'
|
|
60
|
+
isLoadingShow = isLoading
|
|
61
|
+
if (tId) {
|
|
62
|
+
clearTimeout(tId)
|
|
63
|
+
}
|
|
64
|
+
tId = null
|
|
65
|
+
if (image || icon === 'success' || icon === 'error') {
|
|
66
|
+
ToastView = <View style={styles.toastWrap} pointerEvents={pointerEvents}>
|
|
67
|
+
<View style={styles.toastContent}>
|
|
68
|
+
<Image source={image || iconImg[icon]} style={styles.toastImg}></Image>
|
|
69
|
+
<Text style={styles.toastText}>{title}</Text>
|
|
70
|
+
</View>
|
|
71
|
+
</View>
|
|
72
|
+
} else if (icon === 'loading') {
|
|
73
|
+
ToastView = <View style={styles.toastWrap} pointerEvents={pointerEvents}>
|
|
74
|
+
<View style={styles.toastContent}>
|
|
75
|
+
<ActivityIndicator
|
|
76
|
+
animating
|
|
77
|
+
style={{ marginBottom: 10 }}
|
|
78
|
+
size='small'
|
|
79
|
+
color='#eee'
|
|
80
|
+
/>
|
|
81
|
+
<Text style={styles.toastText}>{title}</Text>
|
|
82
|
+
</View>
|
|
83
|
+
</View>
|
|
84
|
+
} else {
|
|
85
|
+
ToastView = <View style={styles.toastWrap} pointerEvents={pointerEvents}>
|
|
86
|
+
<View style={styles.toastContent}>
|
|
87
|
+
<Text numberOfLines={2} style={{ ...styles.toastText, ...(icon === 'none' ? {
|
|
88
|
+
height: 36
|
|
89
|
+
} : {}) }}>{title}</Text>
|
|
90
|
+
</View>
|
|
91
|
+
</View>
|
|
92
|
+
}
|
|
93
|
+
try {
|
|
94
|
+
if (toastKey) {
|
|
95
|
+
Portal.remove(toastKey)
|
|
96
|
+
}
|
|
97
|
+
toastKey = Portal.add(ToastView)
|
|
98
|
+
if (!isLoading) {
|
|
99
|
+
tId = setTimeout(() => {
|
|
100
|
+
Portal.remove(toastKey)
|
|
101
|
+
toastKey = null
|
|
102
|
+
}, duration)
|
|
103
|
+
}
|
|
104
|
+
const result = {
|
|
105
|
+
errMsg: 'showToast:ok'
|
|
106
|
+
}
|
|
107
|
+
successHandle(result, success, complete)
|
|
108
|
+
} catch (e) {
|
|
109
|
+
const result = {
|
|
110
|
+
errMsg: `showToast:fail invalid ${e}`
|
|
111
|
+
}
|
|
112
|
+
failHandle(result, fail, complete)
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function hideToast(options) {
|
|
117
|
+
const { noConflict = false, success, fail, complete } = options
|
|
118
|
+
|
|
119
|
+
if (isLoadingShow && noConflict) {
|
|
120
|
+
return
|
|
121
|
+
}
|
|
122
|
+
try {
|
|
123
|
+
if (toastKey) {
|
|
124
|
+
Portal.remove(toastKey)
|
|
125
|
+
toastKey = null
|
|
126
|
+
}
|
|
127
|
+
const result = {
|
|
128
|
+
errMsg: 'hideToast:ok'
|
|
129
|
+
}
|
|
130
|
+
successHandle(result, success, complete)
|
|
131
|
+
} catch (e) {
|
|
132
|
+
const result = {
|
|
133
|
+
errMsg: `hideToast:fail invalid ${e}`
|
|
134
|
+
}
|
|
135
|
+
failHandle(result, fail, complete)
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function showLoading (options) {
|
|
140
|
+
const { title, mask, success, fail, complete } = options
|
|
141
|
+
showToast({
|
|
142
|
+
title,
|
|
143
|
+
mask,
|
|
144
|
+
icon: 'loading',
|
|
145
|
+
isLoading: true,
|
|
146
|
+
success () {
|
|
147
|
+
const result = {
|
|
148
|
+
errMsg: 'showLoading:ok'
|
|
149
|
+
}
|
|
150
|
+
successHandle(result, success, complete)
|
|
151
|
+
},
|
|
152
|
+
fail (res) {
|
|
153
|
+
const result = {
|
|
154
|
+
errMsg: res.errMsg.replace('showToast', 'showLoading')
|
|
155
|
+
}
|
|
156
|
+
failHandle(result, success, complete)
|
|
157
|
+
}
|
|
158
|
+
})
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function hideLoading (options) {
|
|
162
|
+
const { noConflict = false, success, fail, complete } = options
|
|
163
|
+
if (!isLoadingShow && noConflict) {
|
|
164
|
+
return
|
|
165
|
+
}
|
|
166
|
+
isLoadingShow = false
|
|
167
|
+
try {
|
|
168
|
+
if (toastKey) {
|
|
169
|
+
Portal.remove(toastKey)
|
|
170
|
+
toastKey = null
|
|
171
|
+
}
|
|
172
|
+
const result = {
|
|
173
|
+
errMsg: 'hideLoading:ok'
|
|
174
|
+
}
|
|
175
|
+
successHandle(result, success, complete)
|
|
176
|
+
} catch (e) {
|
|
177
|
+
const result = {
|
|
178
|
+
errMsg: `hideLoading:fail invalid ${e}`
|
|
179
|
+
}
|
|
180
|
+
failHandle(result, fail, complete)
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export {
|
|
185
|
+
showToast,
|
|
186
|
+
hideToast,
|
|
187
|
+
showLoading,
|
|
188
|
+
hideLoading
|
|
189
|
+
}
|
|
Binary file
|
package/src/platform/index.js
CHANGED
|
File without changes
|
|
File without changes
|