@mpxjs/api-proxy 2.9.66 → 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 -12
- 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 +10 -8
- package/src/platform/api/route/index.ios.js +19 -24
- 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 +24 -86
- package/src/platform/api/toast/rnToast.jsx +23 -16
- package/src/platform/index.js +6 -6
- package/LICENSE +0 -433
- package/src/platform/api/action-sheet/index.android.js +0 -1
- package/src/platform/api/animation/index.android.js +0 -1
- package/src/platform/api/app/index.android.js +0 -1
- package/src/platform/api/base/index.android.js +0 -1
- package/src/platform/api/clipboard-data/index.android.js +0 -1
- package/src/platform/api/create-selector-query/index.android.js +0 -1
- package/src/platform/api/device/network/index.android.js +0 -1
- package/src/platform/api/keyboard/index.android.js +0 -1
- 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/location/index.android.js +0 -1
- package/src/platform/api/make-phone-call/index.android.js +0 -1
- package/src/platform/api/modal/index.android.js +0 -1
- package/src/platform/api/next-tick/index.android.js +0 -1
- package/src/platform/api/request/index.android.js +0 -1
- package/src/platform/api/route/index.android.js +0 -1
- package/src/platform/api/screen-brightness/index.android.js +0 -1
- package/src/platform/api/set-navigation-bar/index.android.js +0 -1
- package/src/platform/api/socket/index.android.js +0 -1
- package/src/platform/api/storage/index.android.js +0 -1
- package/src/platform/api/system/index.android.js +0 -1
- package/src/platform/api/toast/index.android.js +0 -1
- package/src/platform/api/vibrate/index.android.js +0 -1
- package/src/platform/api/window/index.android.js +0 -1
|
@@ -1,20 +1,6 @@
|
|
|
1
1
|
import { successHandle, failHandle } from '../../../common/js'
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
function parseUrl (url) {
|
|
5
|
-
let path = url
|
|
6
|
-
let query = ''
|
|
7
|
-
const queryIndex = url.indexOf('?')
|
|
8
|
-
if (queryIndex >= 0) {
|
|
9
|
-
path = url.slice(0, queryIndex)
|
|
10
|
-
query = url.slice(queryIndex)
|
|
11
|
-
}
|
|
12
|
-
const queryObj = parseQuery(query || '?')
|
|
13
|
-
return {
|
|
14
|
-
path,
|
|
15
|
-
queryObj
|
|
16
|
-
}
|
|
17
|
-
}
|
|
2
|
+
import { parseUrlQuery as parseUrl } from '@mpxjs/utils'
|
|
3
|
+
import { nextTick } from '../next-tick'
|
|
18
4
|
|
|
19
5
|
function getBasePath (navigation) {
|
|
20
6
|
if (navigation) {
|
|
@@ -90,14 +76,23 @@ function navigateBack (options = {}) {
|
|
|
90
76
|
const navigation = Object.values(global.__mpxPagesMap || {})[0]?.[1]
|
|
91
77
|
const navigationHelper = global.__navigationHelper
|
|
92
78
|
if (navigation && navigationHelper) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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
|
+
}
|
|
101
96
|
}
|
|
102
97
|
}
|
|
103
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
|
}
|
|
@@ -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
|
+
}
|
|
@@ -40,9 +40,15 @@ const getDeviceInfo = function () {
|
|
|
40
40
|
|
|
41
41
|
const getWindowInfo = ENV_OBJ.getWindowInfo || envError('getWindowInfo')
|
|
42
42
|
|
|
43
|
+
const getLaunchOptionsSync = ENV_OBJ.getLaunchOptionsSync || envError('getLaunchOptionsSync')
|
|
44
|
+
|
|
45
|
+
const getEnterOptionsSync = ENV_OBJ.getEnterOptionsSync || envError('getEnterOptionsSync')
|
|
46
|
+
|
|
43
47
|
export {
|
|
44
48
|
getSystemInfo,
|
|
45
49
|
getSystemInfoSync,
|
|
46
50
|
getDeviceInfo,
|
|
47
|
-
getWindowInfo
|
|
51
|
+
getWindowInfo,
|
|
52
|
+
getLaunchOptionsSync,
|
|
53
|
+
getEnterOptionsSync
|
|
48
54
|
}
|
|
@@ -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
|
+
}
|
|
@@ -8,9 +8,15 @@ const getDeviceInfo = ENV_OBJ.getDeviceInfo || envError('getDeviceInfo')
|
|
|
8
8
|
|
|
9
9
|
const getWindowInfo = ENV_OBJ.getWindowInfo || envError('getWindowInfo')
|
|
10
10
|
|
|
11
|
+
const getLaunchOptionsSync = ENV_OBJ.getLaunchOptionsSync || envError('getLaunchOptionsSync')
|
|
12
|
+
|
|
13
|
+
const getEnterOptionsSync = ENV_OBJ.getEnterOptionsSync || envError('getEnterOptionsSync')
|
|
14
|
+
|
|
11
15
|
export {
|
|
12
16
|
getSystemInfo,
|
|
13
17
|
getSystemInfoSync,
|
|
14
18
|
getDeviceInfo,
|
|
15
|
-
getWindowInfo
|
|
19
|
+
getWindowInfo,
|
|
20
|
+
getLaunchOptionsSync,
|
|
21
|
+
getEnterOptionsSync
|
|
16
22
|
}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isBrowser, throwSSRWarning, successHandle } from '../../../common/js'
|
|
2
2
|
|
|
3
|
-
function
|
|
4
|
-
if (!isBrowser) {
|
|
5
|
-
throwSSRWarning('getSystemInfoSync API is running in non browser environments')
|
|
6
|
-
return
|
|
7
|
-
}
|
|
3
|
+
const getDeviceInfo = function () {
|
|
8
4
|
const ua = navigator.userAgent.split('(')[1]?.split(')')[0] || ''
|
|
9
5
|
const phones = new Map([
|
|
10
6
|
['iPhone', /iPhone|iPad|iPod|iOS/i],
|
|
@@ -37,20 +33,57 @@ function getSystemInfoSync () {
|
|
|
37
33
|
} else {
|
|
38
34
|
system = `Android ${ua.replace(/^.*Android ([\d.]+);.*$/, '$1')}`
|
|
39
35
|
}
|
|
40
|
-
|
|
41
36
|
return {
|
|
42
|
-
|
|
37
|
+
abi: null,
|
|
38
|
+
deviceAbi: null,
|
|
39
|
+
benchmarkLevel: null,
|
|
40
|
+
brand,
|
|
43
41
|
model: brand,
|
|
42
|
+
system,
|
|
43
|
+
platform: navigator.platform,
|
|
44
|
+
cpuType: null,
|
|
45
|
+
memorySize: null
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const getWindowInfo = function () {
|
|
50
|
+
return {
|
|
44
51
|
pixelRatio: window.devicePixelRatio,
|
|
45
52
|
screenWidth: window.screen.width,
|
|
46
53
|
screenHeight: window.screen.height,
|
|
47
54
|
windowWidth: document.documentElement.clientWidth,
|
|
48
55
|
windowHeight: document.documentElement.clientHeight,
|
|
49
56
|
statusBarHeight: null,
|
|
57
|
+
safeArea: null,
|
|
58
|
+
screenTop: null
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function getSystemInfoSync () {
|
|
63
|
+
if (!isBrowser) {
|
|
64
|
+
throwSSRWarning('getSystemInfoSync API is running in non browser environments')
|
|
65
|
+
return
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const {
|
|
69
|
+
pixelRatio,
|
|
70
|
+
screenWidth,
|
|
71
|
+
screenHeight,
|
|
72
|
+
windowWidth,
|
|
73
|
+
windowHeight,
|
|
74
|
+
statusBarHeight,
|
|
75
|
+
safeArea
|
|
76
|
+
} = getWindowInfo()
|
|
77
|
+
const {
|
|
78
|
+
benchmarkLevel,
|
|
79
|
+
brand,
|
|
80
|
+
model,
|
|
81
|
+
system,
|
|
82
|
+
platform
|
|
83
|
+
} = getDeviceInfo()
|
|
84
|
+
const result = Object.assign({
|
|
50
85
|
language: navigator.language,
|
|
51
86
|
version: null,
|
|
52
|
-
system,
|
|
53
|
-
platform: navigator.platform,
|
|
54
87
|
fontSizeSetting: null,
|
|
55
88
|
SDKVersion: null,
|
|
56
89
|
benchmarkLevel: null,
|
|
@@ -64,9 +97,23 @@ function getSystemInfoSync () {
|
|
|
64
97
|
notificationSoundAuthorized: null,
|
|
65
98
|
bluetoothEnabled: null,
|
|
66
99
|
locationEnabled: null,
|
|
67
|
-
wifiEnabled: null
|
|
68
|
-
|
|
69
|
-
|
|
100
|
+
wifiEnabled: null
|
|
101
|
+
}, {
|
|
102
|
+
pixelRatio,
|
|
103
|
+
screenWidth,
|
|
104
|
+
screenHeight,
|
|
105
|
+
windowWidth,
|
|
106
|
+
windowHeight,
|
|
107
|
+
statusBarHeight,
|
|
108
|
+
safeArea
|
|
109
|
+
}, {
|
|
110
|
+
benchmarkLevel,
|
|
111
|
+
brand,
|
|
112
|
+
model,
|
|
113
|
+
system,
|
|
114
|
+
platform
|
|
115
|
+
})
|
|
116
|
+
return result
|
|
70
117
|
}
|
|
71
118
|
|
|
72
119
|
function getSystemInfo (options = {}) {
|
|
@@ -79,13 +126,27 @@ function getSystemInfo (options = {}) {
|
|
|
79
126
|
successHandle(res, options.success, options.complete)
|
|
80
127
|
}
|
|
81
128
|
|
|
82
|
-
const
|
|
129
|
+
const getEnterOptionsSync = function () {
|
|
130
|
+
if (!isBrowser) {
|
|
131
|
+
throwSSRWarning('getEnterOptionsSync API is running in non browser environments')
|
|
132
|
+
return
|
|
133
|
+
}
|
|
134
|
+
return global.__mpxEnterOptions || {}
|
|
135
|
+
}
|
|
83
136
|
|
|
84
|
-
const
|
|
137
|
+
const getLaunchOptionsSync = function () {
|
|
138
|
+
if (!isBrowser) {
|
|
139
|
+
throwSSRWarning('getLaunchOptionsSync API is running in non browser environments')
|
|
140
|
+
return
|
|
141
|
+
}
|
|
142
|
+
return global.__mpxEnterOptions || {}
|
|
143
|
+
}
|
|
85
144
|
|
|
86
145
|
export {
|
|
87
146
|
getSystemInfo,
|
|
88
147
|
getSystemInfoSync,
|
|
89
148
|
getDeviceInfo,
|
|
90
|
-
getWindowInfo
|
|
149
|
+
getWindowInfo,
|
|
150
|
+
getLaunchOptionsSync,
|
|
151
|
+
getEnterOptionsSync
|
|
91
152
|
}
|
|
@@ -1,23 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Platform, PixelRatio, Dimensions, StatusBar } from 'react-native'
|
|
1
|
+
import { PixelRatio, Dimensions } from 'react-native'
|
|
3
2
|
import { initialWindowMetrics } from 'react-native-safe-area-context'
|
|
4
|
-
import {
|
|
3
|
+
import { getFocusedNavigation } from '../../../common/js'
|
|
5
4
|
|
|
6
5
|
const getWindowInfo = function () {
|
|
7
6
|
const dimensionsScreen = Dimensions.get('screen')
|
|
8
|
-
const navigation = getFocusedNavigation()
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
7
|
+
const navigation = getFocusedNavigation() || {}
|
|
8
|
+
const initialWindowMetricsInset = initialWindowMetrics?.insets || {}
|
|
9
|
+
const navigationInsets = navigation.insets || {}
|
|
10
|
+
const insets = Object.assign(initialWindowMetricsInset, navigationInsets)
|
|
13
11
|
let safeArea = {}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
const screenHeight = dimensionsScreen.height
|
|
19
|
-
const screenWidth = dimensionsScreen.width
|
|
20
|
-
const layout = navigation?.layout || {}
|
|
12
|
+
const { top = 0, bottom = 0, left = 0, right = 0 } = insets
|
|
13
|
+
const screenHeight = __mpx_mode__ === 'ios' ? dimensionsScreen.height : dimensionsScreen.height - bottom // 解决安卓开启屏幕内三建导航安卓把安全区计算进去后产生的影响
|
|
14
|
+
const screenWidth = __mpx_mode__ === 'ios' ? dimensionsScreen.width : dimensionsScreen.width - right
|
|
15
|
+
const layout = navigation.layout || {}
|
|
21
16
|
const layoutHeight = layout.height || 0
|
|
22
17
|
const layoutWidth = layout.width || 0
|
|
23
18
|
const windowHeight = layoutHeight || screenHeight
|
|
@@ -39,86 +34,29 @@ const getWindowInfo = function () {
|
|
|
39
34
|
screenWidth: screenWidth,
|
|
40
35
|
screenHeight: screenHeight,
|
|
41
36
|
screenTop: screenHeight - windowHeight,
|
|
42
|
-
safeArea
|
|
43
|
-
}
|
|
44
|
-
return result
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const getSystemInfoSync = function () {
|
|
48
|
-
const windowInfo = getWindowInfo()
|
|
49
|
-
const { screenWidth, screenHeight, safeArea } = windowInfo
|
|
50
|
-
|
|
51
|
-
const result = {
|
|
52
|
-
brand: DeviceInfo.getBrand(),
|
|
53
|
-
model: DeviceInfo.getModel(),
|
|
54
|
-
system: `${DeviceInfo.getSystemName()} ${DeviceInfo.getSystemVersion()}`,
|
|
55
|
-
platform: DeviceInfo.isEmulatorSync() ? 'emulator' : DeviceInfo.getSystemName(),
|
|
56
|
-
deviceOrientation: screenWidth > screenHeight ? 'portrait' : 'landscape',
|
|
57
37
|
statusBarHeight: safeArea.top,
|
|
58
|
-
|
|
59
|
-
...windowInfo
|
|
38
|
+
safeArea
|
|
60
39
|
}
|
|
61
|
-
defineUnsupportedProps(result, [
|
|
62
|
-
'language',
|
|
63
|
-
'version',
|
|
64
|
-
'SDKVersion',
|
|
65
|
-
'benchmarkLevel',
|
|
66
|
-
'albumAuthorized',
|
|
67
|
-
'cameraAuthorized',
|
|
68
|
-
'locationAuthorized',
|
|
69
|
-
'microphoneAuthorized',
|
|
70
|
-
'notificationAuthorized',
|
|
71
|
-
'phoneCalendarAuthorized',
|
|
72
|
-
'host',
|
|
73
|
-
'enableDebug',
|
|
74
|
-
'notificationAlertAuthorized',
|
|
75
|
-
'notificationBadgeAuthorized',
|
|
76
|
-
'notificationSoundAuthorized',
|
|
77
|
-
'bluetoothEnabled',
|
|
78
|
-
'locationEnabled',
|
|
79
|
-
'wifiEnabled',
|
|
80
|
-
'locationReducedAccuracy',
|
|
81
|
-
'theme'
|
|
82
|
-
])
|
|
83
40
|
return result
|
|
84
41
|
}
|
|
85
42
|
|
|
86
|
-
const
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
successHandle(systemInfo, success, complete)
|
|
94
|
-
} catch (err) {
|
|
95
|
-
const result = {
|
|
96
|
-
errMsg: `getSystemInfo:fail ${err}`
|
|
97
|
-
}
|
|
98
|
-
failHandle(result, fail, complete)
|
|
43
|
+
const getLaunchOptionsSync = function () {
|
|
44
|
+
const options = global.__mpxEnterOptions || {}
|
|
45
|
+
const { path, scene, query } = options
|
|
46
|
+
return {
|
|
47
|
+
path,
|
|
48
|
+
scene,
|
|
49
|
+
query
|
|
99
50
|
}
|
|
100
51
|
}
|
|
101
52
|
|
|
102
|
-
const
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
const deviceAbi = DeviceInfo.supported64BitAbisSync() || []
|
|
106
|
-
deviceInfo.deviceAbi = deviceAbi[0] || null
|
|
107
|
-
}
|
|
108
|
-
defineUnsupportedProps(deviceInfo, ['benchmarkLevel', 'abi', 'cpuType'])
|
|
109
|
-
Object.assign(deviceInfo, {
|
|
110
|
-
brand: DeviceInfo.getBrand(),
|
|
111
|
-
model: DeviceInfo.getModel(),
|
|
112
|
-
system: `${DeviceInfo.getSystemName()} ${DeviceInfo.getSystemVersion()}`,
|
|
113
|
-
platform: DeviceInfo.isEmulatorSync() ? 'emulator' : DeviceInfo.getSystemName(),
|
|
114
|
-
memorySize: DeviceInfo.getTotalMemorySync() / (1024 * 1024)
|
|
115
|
-
})
|
|
116
|
-
return deviceInfo
|
|
53
|
+
const getEnterOptionsSync = function () {
|
|
54
|
+
const result = getLaunchOptionsSync()
|
|
55
|
+
return result
|
|
117
56
|
}
|
|
118
57
|
|
|
119
58
|
export {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
getWindowInfo
|
|
59
|
+
getWindowInfo,
|
|
60
|
+
getLaunchOptionsSync,
|
|
61
|
+
getEnterOptionsSync
|
|
124
62
|
}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { View, Text, Image, StyleSheet, ActivityIndicator } from 'react-native'
|
|
1
|
+
import { View, Text, Image, StyleSheet, ActivityIndicator, Dimensions } from 'react-native'
|
|
2
2
|
import { successHandle, failHandle } from '../../../common/js'
|
|
3
3
|
import { Portal } from '@ant-design/react-native'
|
|
4
4
|
|
|
5
5
|
let toastKey
|
|
6
6
|
let isLoadingShow
|
|
7
|
+
const dimensionsScreen = Dimensions.get('screen')
|
|
8
|
+
const screenHeight = dimensionsScreen.height
|
|
9
|
+
const contentTop = parseInt(screenHeight * 0.35)
|
|
7
10
|
let tId // show duration 计时id
|
|
8
11
|
const styles = StyleSheet.create({
|
|
9
12
|
toastContent: {
|
|
10
|
-
minWdth: 150,
|
|
11
13
|
maxWidth: '60%',
|
|
12
14
|
backgroundColor: 'rgba(20, 20, 20, 0.7)',
|
|
13
15
|
paddingTop: 15,
|
|
@@ -18,7 +20,8 @@ const styles = StyleSheet.create({
|
|
|
18
20
|
display: 'flex',
|
|
19
21
|
flexDirection: 'column',
|
|
20
22
|
justifyContent: 'center',
|
|
21
|
-
alignItems: 'center'
|
|
23
|
+
alignItems: 'center',
|
|
24
|
+
marginTop: contentTop // 小程序里面展示偏上一点
|
|
22
25
|
},
|
|
23
26
|
toastWrap: {
|
|
24
27
|
left: 0,
|
|
@@ -28,25 +31,29 @@ const styles = StyleSheet.create({
|
|
|
28
31
|
zIndex: 10000,
|
|
29
32
|
position: "absolute",
|
|
30
33
|
display: 'flex',
|
|
31
|
-
justifyContent: 'center',
|
|
32
34
|
alignItems: 'center'
|
|
33
35
|
},
|
|
36
|
+
toastHasIcon: {
|
|
37
|
+
height: 110,
|
|
38
|
+
width: 120
|
|
39
|
+
},
|
|
34
40
|
toastImg: {
|
|
35
41
|
width: 40,
|
|
36
42
|
height: 40,
|
|
37
43
|
marginLeft: 'auto',
|
|
38
|
-
marginRight: 'auto'
|
|
39
|
-
marginBottom: 10
|
|
44
|
+
marginRight: 'auto'
|
|
40
45
|
},
|
|
41
46
|
toastText: {
|
|
42
47
|
textAlign: 'center',
|
|
43
48
|
color: '#ffffff',
|
|
44
|
-
fontSize:
|
|
49
|
+
fontSize: 12,
|
|
45
50
|
lineHeight: 18,
|
|
46
51
|
height: 18,
|
|
47
|
-
overflow: 'hidden'
|
|
52
|
+
overflow: 'hidden',
|
|
53
|
+
marginTop: 10
|
|
48
54
|
}
|
|
49
55
|
})
|
|
56
|
+
|
|
50
57
|
function showToast (options = {}) {
|
|
51
58
|
const { title, icon = 'success', image, duration = 1500, mask = false, success, fail, complete, isLoading } = options
|
|
52
59
|
let ToastView
|
|
@@ -64,29 +71,29 @@ function showToast (options = {}) {
|
|
|
64
71
|
tId = null
|
|
65
72
|
if (image || icon === 'success' || icon === 'error') {
|
|
66
73
|
ToastView = <View style={styles.toastWrap} pointerEvents={pointerEvents}>
|
|
67
|
-
<View style={styles.toastContent}>
|
|
74
|
+
<View style={[styles.toastContent, styles.toastHasIcon]}>
|
|
68
75
|
<Image style={ styles.toastImg } source={{uri: image || iconImg[icon]}}></Image>
|
|
69
|
-
<Text style={styles.toastText}>{title}</Text>
|
|
76
|
+
{ title ? <Text style={styles.toastText}>{title}</Text> : null }
|
|
70
77
|
</View>
|
|
71
78
|
</View>
|
|
72
79
|
} else if (icon === 'loading') {
|
|
73
80
|
ToastView = <View style={styles.toastWrap} pointerEvents={pointerEvents}>
|
|
74
|
-
<View style={styles.toastContent}>
|
|
81
|
+
<View style={[styles.toastContent, styles.toastHasIcon]}>
|
|
75
82
|
<ActivityIndicator
|
|
76
83
|
animating
|
|
77
|
-
style={{ marginBottom: 10 }}
|
|
78
84
|
size='small'
|
|
79
85
|
color='#eee'
|
|
80
86
|
/>
|
|
81
|
-
<Text style={styles.toastText}>{title}</Text>
|
|
87
|
+
{ title ? <Text style={styles.toastText}>{title}</Text> : null }
|
|
82
88
|
</View>
|
|
83
89
|
</View>
|
|
84
90
|
} else {
|
|
85
91
|
ToastView = <View style={styles.toastWrap} pointerEvents={pointerEvents}>
|
|
86
92
|
<View style={styles.toastContent}>
|
|
87
|
-
<Text numberOfLines={2} style={{ ...styles.toastText, ...(icon === 'none' ? {
|
|
88
|
-
height:
|
|
89
|
-
|
|
93
|
+
{ title ? <Text numberOfLines={2} style={{ ...styles.toastText, ...(icon === 'none' ? {
|
|
94
|
+
height: 'auto',
|
|
95
|
+
marginTop: 0
|
|
96
|
+
} : {}) }}>{title}</Text> : null }
|
|
90
97
|
</View>
|
|
91
98
|
</View>
|
|
92
99
|
}
|