From c640eb908f31137d7f594a159d7e279cae838a15 Mon Sep 17 00:00:00 2001 From: wangcuijuan Date: Wed, 27 Nov 2024 19:27:16 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E9=87=8D=E6=96=B0=E5=88=92=E5=88=86RN?= =?UTF-8?q?=E4=B8=8Bsystem=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/platform/api/system/index.ios.js | 86 +++++++++++++- .../src/platform/api/system/rnSystem.js | 105 ++++++------------ .../src/platform/api/system/rnWindowInfo.js | 42 ------- 3 files changed, 117 insertions(+), 116 deletions(-) delete mode 100644 packages/api-proxy/src/platform/api/system/rnWindowInfo.js diff --git a/packages/api-proxy/src/platform/api/system/index.ios.js b/packages/api-proxy/src/platform/api/system/index.ios.js index b108997da8..57273d1c96 100644 --- a/packages/api-proxy/src/platform/api/system/index.ios.js +++ b/packages/api-proxy/src/platform/api/system/index.ios.js @@ -1 +1,85 @@ -export * from './rnSystem' +import DeviceInfo from 'react-native-device-info' +import { PixelRatio } from 'react-native' +import { successHandle, failHandle, defineUnsupportedProps } from '../../../common/js' +import { getWindowInfo, getLaunchOptionsSync, getEnterOptionsSync } from './rnSystem' + +const getSystemInfoSync = function () { + const windowInfo = getWindowInfo() + const { screenWidth, screenHeight, safeArea } = windowInfo + + const result = { + brand: DeviceInfo.getBrand(), + model: DeviceInfo.getModel(), + system: `${DeviceInfo.getSystemName()} ${DeviceInfo.getSystemVersion()}`, + platform: DeviceInfo.isEmulatorSync() ? 'emulator' : DeviceInfo.getSystemName(), + deviceOrientation: screenWidth > screenHeight ? 'portrait' : 'landscape', + statusBarHeight: safeArea.top, + fontSizeSetting: PixelRatio.getFontScale(), + ...windowInfo + } + defineUnsupportedProps(result, [ + 'language', + 'version', + 'SDKVersion', + 'benchmarkLevel', + 'albumAuthorized', + 'cameraAuthorized', + 'locationAuthorized', + 'microphoneAuthorized', + 'notificationAuthorized', + 'phoneCalendarAuthorized', + 'host', + 'enableDebug', + 'notificationAlertAuthorized', + 'notificationBadgeAuthorized', + 'notificationSoundAuthorized', + 'bluetoothEnabled', + 'locationEnabled', + 'wifiEnabled', + 'locationReducedAccuracy', + 'theme' + ]) + return result +} + +const getSystemInfo = function (options = {}) { + const { success, fail, complete } = options + try { + const systemInfo = getSystemInfoSync() + Object.assign(systemInfo, { + errMsg: 'setStorage:ok' + }) + successHandle(systemInfo, success, complete) + } catch (err) { + const result = { + errMsg: `getSystemInfo:fail ${err}` + } + failHandle(result, fail, complete) + } +} + +const getDeviceInfo = function () { + const deviceInfo = {} + if (__mpx_mode__ === 'android') { + const deviceAbi = DeviceInfo.supported64BitAbisSync() || [] + deviceInfo.deviceAbi = deviceAbi[0] || null + } + defineUnsupportedProps(deviceInfo, ['benchmarkLevel', 'abi', 'cpuType']) + Object.assign(deviceInfo, { + brand: DeviceInfo.getBrand(), + model: DeviceInfo.getModel(), + system: `${DeviceInfo.getSystemName()} ${DeviceInfo.getSystemVersion()}`, + platform: DeviceInfo.isEmulatorSync() ? 'emulator' : DeviceInfo.getSystemName(), + memorySize: DeviceInfo.getTotalMemorySync() / (1024 * 1024) + }) + return deviceInfo +} + +export { + getSystemInfo, + getSystemInfoSync, + getDeviceInfo, + getWindowInfo, + getLaunchOptionsSync, + getEnterOptionsSync +} diff --git a/packages/api-proxy/src/platform/api/system/rnSystem.js b/packages/api-proxy/src/platform/api/system/rnSystem.js index 058d9f550f..be6507ef59 100644 --- a/packages/api-proxy/src/platform/api/system/rnSystem.js +++ b/packages/api-proxy/src/platform/api/system/rnSystem.js @@ -1,78 +1,40 @@ -import DeviceInfo from 'react-native-device-info' -import { PixelRatio } from 'react-native' -import { successHandle, failHandle, defineUnsupportedProps } from '../../../common/js' -import { getWindowInfo } from './rnWindowInfo' +import { PixelRatio, Dimensions } from 'react-native' +import { initialWindowMetrics } from 'react-native-safe-area-context' +import { getFocusedNavigation } from '../../../common/js' -const getSystemInfoSync = function () { - const windowInfo = getWindowInfo() - const { screenWidth, screenHeight, safeArea } = windowInfo - - const result = { - brand: DeviceInfo.getBrand(), - model: DeviceInfo.getModel(), - system: `${DeviceInfo.getSystemName()} ${DeviceInfo.getSystemVersion()}`, - platform: DeviceInfo.isEmulatorSync() ? 'emulator' : DeviceInfo.getSystemName(), - deviceOrientation: screenWidth > screenHeight ? 'portrait' : 'landscape', - statusBarHeight: safeArea.top, - fontSizeSetting: PixelRatio.getFontScale(), - ...windowInfo - } - defineUnsupportedProps(result, [ - 'language', - 'version', - 'SDKVersion', - 'benchmarkLevel', - 'albumAuthorized', - 'cameraAuthorized', - 'locationAuthorized', - 'microphoneAuthorized', - 'notificationAuthorized', - 'phoneCalendarAuthorized', - 'host', - 'enableDebug', - 'notificationAlertAuthorized', - 'notificationBadgeAuthorized', - 'notificationSoundAuthorized', - 'bluetoothEnabled', - 'locationEnabled', - 'wifiEnabled', - 'locationReducedAccuracy', - 'theme' - ]) - return result -} - -const getSystemInfo = function (options = {}) { - const { success, fail, complete } = options +const getWindowInfo = function () { + const dimensionsScreen = Dimensions.get('screen') + const navigation = getFocusedNavigation() + const insets = Object.assign(initialWindowMetrics?.insets, navigation?.insets) + let safeArea = {} + const { top = 0, bottom = 0, left = 0, right = 0 } = insets + const screenHeight = dimensionsScreen.height + const screenWidth = dimensionsScreen.width + const layout = navigation?.layout || {} + const layoutHeight = layout.height || 0 + const layoutWidth = layout.width || 0 + const windowHeight = layoutHeight || screenHeight try { - const systemInfo = getSystemInfoSync() - Object.assign(systemInfo, { - errMsg: 'setStorage:ok' - }) - successHandle(systemInfo, success, complete) - } catch (err) { - const result = { - errMsg: `getSystemInfo:fail ${err}` + safeArea = { + left, + right: screenWidth - right, + top, + bottom: screenHeight - bottom, + height: screenHeight - top - bottom, + width: screenWidth - left - right } - failHandle(result, fail, complete) + } catch (error) { } -} - -const getDeviceInfo = function () { - const deviceInfo = {} - if (__mpx_mode__ === 'android') { - const deviceAbi = DeviceInfo.supported64BitAbisSync() || [] - deviceInfo.deviceAbi = deviceAbi[0] || null + const result = { + pixelRatio: PixelRatio.get(), + windowWidth: layoutWidth || screenWidth, + windowHeight, // 取不到layout的时候有个兜底 + screenWidth: screenWidth, + screenHeight: screenHeight, + screenTop: screenHeight - windowHeight, + safeArea } - defineUnsupportedProps(deviceInfo, ['benchmarkLevel', 'abi', 'cpuType']) - Object.assign(deviceInfo, { - brand: DeviceInfo.getBrand(), - model: DeviceInfo.getModel(), - system: `${DeviceInfo.getSystemName()} ${DeviceInfo.getSystemVersion()}`, - platform: DeviceInfo.isEmulatorSync() ? 'emulator' : DeviceInfo.getSystemName(), - memorySize: DeviceInfo.getTotalMemorySync() / (1024 * 1024) - }) - return deviceInfo + return result } const getLaunchOptionsSync = function () { @@ -91,9 +53,6 @@ const getEnterOptionsSync = function () { } export { - getSystemInfo, - getSystemInfoSync, - getDeviceInfo, getWindowInfo, getLaunchOptionsSync, getEnterOptionsSync diff --git a/packages/api-proxy/src/platform/api/system/rnWindowInfo.js b/packages/api-proxy/src/platform/api/system/rnWindowInfo.js deleted file mode 100644 index 13e8c771b5..0000000000 --- a/packages/api-proxy/src/platform/api/system/rnWindowInfo.js +++ /dev/null @@ -1,42 +0,0 @@ -import { PixelRatio, Dimensions } from 'react-native' -import { initialWindowMetrics } from 'react-native-safe-area-context' -import { getFocusedNavigation } from '../../../common/js' - -const getWindowInfo = function () { - const dimensionsScreen = Dimensions.get('screen') - const navigation = getFocusedNavigation() - const insets = Object.assign(initialWindowMetrics?.insets, navigation?.insets) - let safeArea = {} - const { top = 0, bottom = 0, left = 0, right = 0 } = insets - const screenHeight = dimensionsScreen.height - const screenWidth = dimensionsScreen.width - const layout = navigation?.layout || {} - const layoutHeight = layout.height || 0 - const layoutWidth = layout.width || 0 - const windowHeight = layoutHeight || screenHeight - try { - safeArea = { - left, - right: screenWidth - right, - top, - bottom: screenHeight - bottom, - height: screenHeight - top - bottom, - width: screenWidth - left - right - } - } catch (error) { - } - const result = { - pixelRatio: PixelRatio.get(), - windowWidth: layoutWidth || screenWidth, - windowHeight, // 取不到layout的时候有个兜底 - screenWidth: screenWidth, - screenHeight: screenHeight, - screenTop: screenHeight - windowHeight, - safeArea - } - return result -} - -export { - getWindowInfo -} From f0009cd104a833425f98883be84c38deffeba1fd Mon Sep 17 00:00:00 2001 From: wangcuijuan Date: Thu, 28 Nov 2024 17:18:57 +0800 Subject: [PATCH 02/10] =?UTF-8?q?fix=20toast=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/api-proxy/src/platform/api/toast/rnToast.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/api-proxy/src/platform/api/toast/rnToast.jsx b/packages/api-proxy/src/platform/api/toast/rnToast.jsx index 0fd46a89f2..d92c02e6e0 100644 --- a/packages/api-proxy/src/platform/api/toast/rnToast.jsx +++ b/packages/api-proxy/src/platform/api/toast/rnToast.jsx @@ -85,7 +85,7 @@ function showToast (options = {}) { ToastView = {title} From b0a6f9a5415adba07e8dd4ac74c49a5e74f8207a Mon Sep 17 00:00:00 2001 From: wangcuijuan Date: Tue, 3 Dec 2024 10:57:33 +0800 Subject: [PATCH 03/10] =?UTF-8?q?=E8=A1=A5=E5=85=85windowstatusbar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/api-proxy/src/platform/api/system/index.ios.js | 3 +-- packages/api-proxy/src/platform/api/system/rnSystem.js | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/api-proxy/src/platform/api/system/index.ios.js b/packages/api-proxy/src/platform/api/system/index.ios.js index 57273d1c96..403650f8a8 100644 --- a/packages/api-proxy/src/platform/api/system/index.ios.js +++ b/packages/api-proxy/src/platform/api/system/index.ios.js @@ -5,7 +5,7 @@ import { getWindowInfo, getLaunchOptionsSync, getEnterOptionsSync } from './rnSy const getSystemInfoSync = function () { const windowInfo = getWindowInfo() - const { screenWidth, screenHeight, safeArea } = windowInfo + const { screenWidth, screenHeight } = windowInfo const result = { brand: DeviceInfo.getBrand(), @@ -13,7 +13,6 @@ const getSystemInfoSync = function () { system: `${DeviceInfo.getSystemName()} ${DeviceInfo.getSystemVersion()}`, platform: DeviceInfo.isEmulatorSync() ? 'emulator' : DeviceInfo.getSystemName(), deviceOrientation: screenWidth > screenHeight ? 'portrait' : 'landscape', - statusBarHeight: safeArea.top, fontSizeSetting: PixelRatio.getFontScale(), ...windowInfo } diff --git a/packages/api-proxy/src/platform/api/system/rnSystem.js b/packages/api-proxy/src/platform/api/system/rnSystem.js index be6507ef59..3740c5d8c3 100644 --- a/packages/api-proxy/src/platform/api/system/rnSystem.js +++ b/packages/api-proxy/src/platform/api/system/rnSystem.js @@ -32,6 +32,7 @@ const getWindowInfo = function () { screenWidth: screenWidth, screenHeight: screenHeight, screenTop: screenHeight - windowHeight, + statusBarHeight: safeArea.top, safeArea } return result From 010a7f9944c3ae088a8f5b3c14ab87d5ec353ec6 Mon Sep 17 00:00:00 2001 From: wangcuijuan Date: Wed, 4 Dec 2024 20:54:20 +0800 Subject: [PATCH 04/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9toast=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E5=B1=95=E7=A4=BA=E7=AD=89=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/platform/api/toast/rnToast.jsx | 63 +++++++++++++------ 1 file changed, 44 insertions(+), 19 deletions(-) diff --git a/packages/api-proxy/src/platform/api/toast/rnToast.jsx b/packages/api-proxy/src/platform/api/toast/rnToast.jsx index d92c02e6e0..fae97a2f6a 100644 --- a/packages/api-proxy/src/platform/api/toast/rnToast.jsx +++ b/packages/api-proxy/src/platform/api/toast/rnToast.jsx @@ -1,24 +1,27 @@ -import { View, Text, Image, StyleSheet, ActivityIndicator } from 'react-native' +import { View, Text, Image, StyleSheet, ActivityIndicator, Dimensions } from 'react-native' import { successHandle, failHandle } from '../../../common/js' import { Portal } from '@ant-design/react-native' let toastKey let isLoadingShow +const dimensionsScreen = Dimensions.get('screen') +const screenHeight = dimensionsScreen.height +const contentTop = parseInt(screenHeight * 0.35) let tId // show duration 计时id const styles = StyleSheet.create({ toastContent: { - minWdth: 150, maxWidth: '60%', backgroundColor: 'rgba(20, 20, 20, 0.7)', paddingTop: 15, paddingBottom: 15, - paddingLeft: 20, - paddingRight: 20, + paddingLeft: 10, + paddingRight: 10, borderRadius: 5, display: 'flex', flexDirection: 'column', justifyContent: 'center', - alignItems: 'center' + alignItems: 'center', + marginTop: contentTop // 小程序里面展示偏上一点 }, toastWrap: { left: 0, @@ -28,27 +31,46 @@ const styles = StyleSheet.create({ zIndex: 10000, position: "absolute", display: 'flex', - justifyContent: 'center', alignItems: 'center' }, + toastHasIcon: { + height: 110, + width: 120 + }, toastImg: { width: 40, height: 40, marginLeft: 'auto', - marginRight: 'auto', - marginBottom: 10 + marginRight: 'auto' }, toastText: { textAlign: 'center', color: '#ffffff', - fontSize: 14, + fontSize: 12, lineHeight: 18, height: 18, - overflow: 'hidden' + overflow: 'hidden', + marginTop: 10 } }) +function cutStr(str) { // 如果有icon的话展示一行,超过14个字符不展示 + let count = 0 + let i = 0 + let cutString = '' + while(count <= 14 && str[i]) { + if (str.charCodeAt(i) > 0x7F) { + count = count + 2 + } else { + count++ + } + cutString += str[i++] + } + return cutString +} + function showToast (options = {}) { - const { title, icon = 'success', image, duration = 1500, mask = false, success, fail, complete, isLoading } = options + const { icon = 'success', image, duration = 1500, mask = false, success, fail, complete, isLoading } = options + let title = options.title let ToastView const successPng = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFwAAABcAgMAAACegTrLAAAADFBMVEUAAAD////R0dHj4+PcME2AAAAAAXRSTlMAQObYZgAAANNJREFUSMft1FEKwkAMBNBGyBFyH4/gR8f+ehSPLtiyQ+wM2C8Rmp+WQN90N8tOZ/1/4Sbb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FSZVkHIqNp8KKjhomzYy/gxuvHbC859xCuoWLdxVR++s/6zOtdlBfJo2xkYiAWXtazNtFvb5LUDTfvouf7tY1U/wV+PzG+n2b7UKR++rn9gAbbOMP15Apn875bSR0AXX84tRl5HzDnyPIbCnBdkDtRaYg87gtbOxf9KB5m3zNyMEtNuYuBtxUCzpH9lZ4OIB3p2WbK+YBh4J17IeCml0Ns2949Dv4Oylm5F7LCwDnCF+hxP6rjLNdyqPOSaCEy2Tsp1/0m9+wWfUoLAzd+32B7ok8fIas1IngTPWOk116jBNqXMeWqnOszRizrUVXPQnmdvqZnlXqNVFaFKUf9iWQpK3uGD/HxOk4E+5BmoTFN/g/T33Q/5rVGC9NlkQKQ/30m11JdlAZuen+Nrcbm16spN+VY2oIA58jrd70xdLJ0RPkOdCnZzsd6eonWvN5O+fRlJn/3wjXKaczkWNhJZ8egM0UA3IXj99DqTgeBt5P407LCQeN3B9ttKMiJY3zO3JzlzQvA/n5mYZnXQYErEKAL9vuohWKZwMtigZbvNtoCbEEPZsEDNgFuIcLTwaLsdaS4g8c+oxvFHhz2DP/hX3KmL0cxH1iD+yimmHUL8uAZgS9F6TF6VR46gKcHRVYJvNMX4EeRHjvaNFNMo504r6stic36h/0GHxa6nCGA15eSHoGhcfRal30CtjmFL43ja3mcdS3AO/AAv5jXm5AelrAOLUEx7BJONWPUFH32PbD9/0QBrzH1KqS/XX8KafI0grx/c2UfmZZsJ5AmLZ+iIyj9SwIg9BjwtS6yDK1B96AWWoF0APRnJ3ON2Pz7I4R+iLiCBPgcaqNvkCYvF5iIxV5JpBt3q/WS4homB2EBbRci3V8o4Hov012rAq77swfi38oQZ7JEIBFIBBKBRCARSAQSgUQgEUgEEoFEICCBfwDKNlghU/F3VgAAAABJRU5ErkJggg==' @@ -61,32 +83,35 @@ function showToast (options = {}) { if (tId) { clearTimeout(tId) } + if (icon !== 'none') { + title = cutStr(title) + } tId = null if (image || icon === 'success' || icon === 'error') { ToastView = - + - {title} + { title ? {title} : null } } else if (icon === 'loading') { ToastView = - + - {title} + { title ? {title} : null } } else { ToastView = - {title} + { title ? {title} : null } } From fe1fff738d4cce00eff2821a35f004a9df9104a6 Mon Sep 17 00:00:00 2001 From: wangcuijuan Date: Mon, 9 Dec 2024 11:31:26 +0800 Subject: [PATCH 05/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9promise=E4=B8=BA?= =?UTF-8?q?=E6=97=A2=E5=8F=AF=E4=BB=A5success=E4=B9=9F=E8=83=BDthen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/api-proxy/src/common/js/promisify.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/api-proxy/src/common/js/promisify.js b/packages/api-proxy/src/common/js/promisify.js index 3eb20590b4..3f19af391a 100644 --- a/packages/api-proxy/src/common/js/promisify.js +++ b/packages/api-proxy/src/common/js/promisify.js @@ -70,14 +70,22 @@ function promisify (listObj, whiteList, customBlackList) { result[key] = function (...args) { const obj = args[0] || {} // 不需要转换 or 用户已定义回调,则不处理 - if (!promisifyFilter(key) || obj.success || obj.fail) { + if (!promisifyFilter(key)) { return listObj[key].apply(ENV_OBJ, args) } else { // 其他情况进行转换 if (!args[0]) args.unshift(obj) let returned const promise = new Promise((resolve, reject) => { - obj.success = resolve - obj.fail = reject + const originSuccess = obj.success + const originFail = obj.fail + obj.success = function (res) { + originSuccess && originSuccess.call(this, res) + resolve(res) + } + obj.fail = function (e) { + originFail && originFail.call(this, e) + reject(e) + } returned = listObj[key].apply(ENV_OBJ, args) }) promise.__returned = returned From 081d50c6844d7bf62d13dca7870f37f5e3597b5f Mon Sep 17 00:00:00 2001 From: wangcuijuan Date: Mon, 9 Dec 2024 20:03:21 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AE=BE=E7=BD=AEtitle?= =?UTF-8?q?=E7=9A=84=E6=8E=A5=E6=94=B6key?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api-proxy/src/platform/api/set-navigation-bar/index.ios.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/api-proxy/src/platform/api/set-navigation-bar/index.ios.js b/packages/api-proxy/src/platform/api/set-navigation-bar/index.ios.js index 3f83c65f34..1171cd7b68 100644 --- a/packages/api-proxy/src/platform/api/set-navigation-bar/index.ios.js +++ b/packages/api-proxy/src/platform/api/set-navigation-bar/index.ios.js @@ -7,7 +7,7 @@ function setNavigationBarTitle (options = {}) { failHandle({ errMsg: 'setNavigationBarTitle:fail' }, fail, complete) } else { nextTick(() => { - navigation.setOptions({ headerTitle: title }) + navigation.setOptions({ title }) successHandle({ errMsg: 'setNavigationBarTitle:ok' }, success, complete) }) } From d5cba1f606d20ddc900c785ebde95b53e26c9eb7 Mon Sep 17 00:00:00 2001 From: wangcuijuan Date: Tue, 10 Dec 2024 17:02:54 +0800 Subject: [PATCH 07/10] =?UTF-8?q?=E8=A1=A5=E5=85=A8=E5=85=9C=E5=BA=95?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/api-proxy/src/platform/api/system/rnSystem.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/api-proxy/src/platform/api/system/rnSystem.js b/packages/api-proxy/src/platform/api/system/rnSystem.js index 3740c5d8c3..2284971c9b 100644 --- a/packages/api-proxy/src/platform/api/system/rnSystem.js +++ b/packages/api-proxy/src/platform/api/system/rnSystem.js @@ -4,13 +4,15 @@ import { getFocusedNavigation } from '../../../common/js' const getWindowInfo = function () { const dimensionsScreen = Dimensions.get('screen') - const navigation = getFocusedNavigation() - const insets = Object.assign(initialWindowMetrics?.insets, navigation?.insets) + const navigation = getFocusedNavigation() || {} + const initialWindowMetricsInset = initialWindowMetrics?.insets || {} + const navigationInsets = navigation.insets || {} + const insets = Object.assign(initialWindowMetricsInset, navigationInsets) let safeArea = {} const { top = 0, bottom = 0, left = 0, right = 0 } = insets const screenHeight = dimensionsScreen.height const screenWidth = dimensionsScreen.width - const layout = navigation?.layout || {} + const layout = navigation.layout || {} const layoutHeight = layout.height || 0 const layoutWidth = layout.width || 0 const windowHeight = layoutHeight || screenHeight From c06d826bb22252a8bc3796770760789687e6eb53 Mon Sep 17 00:00:00 2001 From: wangcuijuan Date: Tue, 10 Dec 2024 17:14:18 +0800 Subject: [PATCH 08/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9...=E4=B8=BAobject.assi?= =?UTF-8?q?gn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/api-proxy/src/platform/api/request/index.web.js | 4 ++-- packages/api-proxy/src/platform/api/system/index.ios.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/api-proxy/src/platform/api/request/index.web.js b/packages/api-proxy/src/platform/api/request/index.web.js index d16e3a420d..789cdff222 100644 --- a/packages/api-proxy/src/platform/api/request/index.web.js +++ b/packages/api-proxy/src/platform/api/request/index.web.js @@ -108,9 +108,9 @@ function request (options = { url: '' }) { statusCode: response.status, header: response.headers, data: response.data, - stack: realError.stack, - ...realError + stack: realError.stack } + Object.assign(res, realError) failHandle(res, fail, complete) }) diff --git a/packages/api-proxy/src/platform/api/system/index.ios.js b/packages/api-proxy/src/platform/api/system/index.ios.js index 403650f8a8..6633441b55 100644 --- a/packages/api-proxy/src/platform/api/system/index.ios.js +++ b/packages/api-proxy/src/platform/api/system/index.ios.js @@ -13,9 +13,9 @@ const getSystemInfoSync = function () { system: `${DeviceInfo.getSystemName()} ${DeviceInfo.getSystemVersion()}`, platform: DeviceInfo.isEmulatorSync() ? 'emulator' : DeviceInfo.getSystemName(), deviceOrientation: screenWidth > screenHeight ? 'portrait' : 'landscape', - fontSizeSetting: PixelRatio.getFontScale(), - ...windowInfo + fontSizeSetting: PixelRatio.getFontScale() } + Object.assign(result, windowInfo) defineUnsupportedProps(result, [ 'language', 'version', From a2ec8cc27cf467caa7a202c6174419af8e43d13c Mon Sep 17 00:00:00 2001 From: wangcuijuan Date: Tue, 10 Dec 2024 17:17:41 +0800 Subject: [PATCH 09/10] =?UTF-8?q?=E8=A1=A5=E5=85=85=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/create-intersection-observer/rnIntersectionObserver.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/api-proxy/src/platform/api/create-intersection-observer/rnIntersectionObserver.js b/packages/api-proxy/src/platform/api/create-intersection-observer/rnIntersectionObserver.js index 1f4a2d523b..059ae453b0 100644 --- a/packages/api-proxy/src/platform/api/create-intersection-observer/rnIntersectionObserver.js +++ b/packages/api-proxy/src/platform/api/create-intersection-observer/rnIntersectionObserver.js @@ -85,7 +85,7 @@ class RNIntersectionObserver { _getWindowRect () { if (this.windowRect) return this.windowRect - const navigation = getFocusedNavigation() + const navigation = getFocusedNavigation() || {} const screen = Dimensions.get('screen') const navigationLayout = navigation.layout || { x: 0, From 11ca26752894917392a1af37bd74a7358f1e4592 Mon Sep 17 00:00:00 2001 From: wangcuijuan Date: Thu, 12 Dec 2024 14:48:02 +0800 Subject: [PATCH 10/10] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E6=97=A0=E7=94=A8?= =?UTF-8?q?=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/platform/api/request/index.web.js | 3 +-- .../src/platform/api/toast/rnToast.jsx | 20 +------------------ 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/packages/api-proxy/src/platform/api/request/index.web.js b/packages/api-proxy/src/platform/api/request/index.web.js index 789cdff222..b3c04364c3 100644 --- a/packages/api-proxy/src/platform/api/request/index.web.js +++ b/packages/api-proxy/src/platform/api/request/index.web.js @@ -107,8 +107,7 @@ function request (options = { url: '' }) { errMsg: `request:fail ${err}`, statusCode: response.status, header: response.headers, - data: response.data, - stack: realError.stack + data: response.data } Object.assign(res, realError) failHandle(res, fail, complete) diff --git a/packages/api-proxy/src/platform/api/toast/rnToast.jsx b/packages/api-proxy/src/platform/api/toast/rnToast.jsx index fae97a2f6a..e780ffb556 100644 --- a/packages/api-proxy/src/platform/api/toast/rnToast.jsx +++ b/packages/api-proxy/src/platform/api/toast/rnToast.jsx @@ -53,24 +53,9 @@ const styles = StyleSheet.create({ marginTop: 10 } }) -function cutStr(str) { // 如果有icon的话展示一行,超过14个字符不展示 - let count = 0 - let i = 0 - let cutString = '' - while(count <= 14 && str[i]) { - if (str.charCodeAt(i) > 0x7F) { - count = count + 2 - } else { - count++ - } - cutString += str[i++] - } - return cutString -} function showToast (options = {}) { - const { icon = 'success', image, duration = 1500, mask = false, success, fail, complete, isLoading } = options - let title = options.title + const { title, icon = 'success', image, duration = 1500, mask = false, success, fail, complete, isLoading } = options let ToastView const successPng = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFwAAABcAgMAAACegTrLAAAADFBMVEUAAAD////R0dHj4+PcME2AAAAAAXRSTlMAQObYZgAAANNJREFUSMft1FEKwkAMBNBGyBFyH4/gR8f+ehSPLtiyQ+wM2C8Rmp+WQN90N8tOZ/1/4SbbYfpp+sBVMqafgGQKs+FvkjF8GR6aj4M8NB+GT8OX5i+GT8OX4aH5MHwZHpoPw+c3fA0xGl/zYBrP92o8vwVwF3NO8tySjXmINQLAs/WX9S8bP9UGJUZSi8MAuUqsj75payPxuWn1BmrjewCCfAvA4Fmjvx8HQL4HiJEHeRmg5k2+B8gTFeRFwL7NzREB/sCKwsG7KN2VSb7XMp31i3oBatNdEForTOoAAAAASUVORK5CYII=' const errorPng = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFwAAABcCAYAAADj79JYAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgA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iWQpK3uGD/HxOk4E+5BmoTFN/g/T33Q/5rVGC9NlkQKQ/30m11JdlAZuen+Nrcbm16spN+VY2oIA58jrd70xdLJ0RPkOdCnZzsd6eonWvN5O+fRlJn/3wjXKaczkWNhJZ8egM0UA3IXj99DqTgeBt5P407LCQeN3B9ttKMiJY3zO3JzlzQvA/n5mYZnXQYErEKAL9vuohWKZwMtigZbvNtoCbEEPZsEDNgFuIcLTwaLsdaS4g8c+oxvFHhz2DP/hX3KmL0cxH1iD+yimmHUL8uAZgS9F6TF6VR46gKcHRVYJvNMX4EeRHjvaNFNMo504r6stic36h/0GHxa6nCGA15eSHoGhcfRal30CtjmFL43ja3mcdS3AO/AAv5jXm5AelrAOLUEx7BJONWPUFH32PbD9/0QBrzH1KqS/XX8KafI0grx/c2UfmZZsJ5AmLZ+iIyj9SwIg9BjwtS6yDK1B96AWWoF0APRnJ3ON2Pz7I4R+iLiCBPgcaqNvkCYvF5iIxV5JpBt3q/WS4homB2EBbRci3V8o4Hov012rAq77swfi38oQZ7JEIBFIBBKBRCARSAQSgUQgEUgEEoFEICCBfwDKNlghU/F3VgAAAABJRU5ErkJggg==' @@ -83,9 +68,6 @@ function showToast (options = {}) { if (tId) { clearTimeout(tId) } - if (icon !== 'none') { - title = cutStr(title) - } tId = null if (image || icon === 'success' || icon === 'error') { ToastView =