From e7726a01eb57a3985b91c561f195a5d8c5c40b7c Mon Sep 17 00:00:00 2001 From: xiaoyatong Date: Thu, 27 Jun 2024 16:22:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dimage=E5=AE=BD?= =?UTF-8?q?=E9=AB=98=E5=A4=84=E7=90=86=E5=87=BD=E6=95=B0,=E8=B0=83?= =?UTF-8?q?=E6=95=B4swipe=E7=89=88=E6=9C=AC=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/nutui-taro-demo-rn/scripts/taro/adapted.js | 1 - src/config.json | 2 +- src/packages/image/image.taro.tsx | 13 ++++++++++--- src/packages/image/image.tsx | 4 +++- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/packages/nutui-taro-demo-rn/scripts/taro/adapted.js b/packages/nutui-taro-demo-rn/scripts/taro/adapted.js index e69d6f6a16..23dc22bb7e 100644 --- a/packages/nutui-taro-demo-rn/scripts/taro/adapted.js +++ b/packages/nutui-taro-demo-rn/scripts/taro/adapted.js @@ -33,5 +33,4 @@ exports = module.exports = [ 'configprovider', 'input', 'swipe', - 'icon', ] diff --git a/src/config.json b/src/config.json index 0ad450dcda..46c6a358db 100644 --- a/src/config.json +++ b/src/config.json @@ -861,7 +861,7 @@ "author": "swag~jun" }, { - "version": "2.0.0", + "version": "3.0.0", "name": "Swipe", "type": "component", "cName": "滑动手势", diff --git a/src/packages/image/image.taro.tsx b/src/packages/image/image.taro.tsx index 1b841cfe58..959cc85b5f 100644 --- a/src/packages/image/image.taro.tsx +++ b/src/packages/image/image.taro.tsx @@ -14,7 +14,6 @@ import { import { Image as ImageIcon, ImageError } from '@nutui/icons-react-taro' import classNames from 'classnames' import { BaseEventOrig } from '@tarojs/components/types/common' -import { pxCheck } from '@/utils/px-check' import { harmonyAndRn } from '@/utils/platform-taro' export interface ImageProps extends Omit { @@ -50,6 +49,10 @@ export const Image: FunctionComponent> = (props) => { const [innerLoading, setInnerLoading] = useState(true) const [isError, setIsError] = useState(false) + const pxCheck = (value: string | number): string => { + return Number.isNaN(Number(value)) ? String(value) : `${value}px` + } + // 图片加载 const handleLoad = (e: BaseEventOrig) => { setIsError(false) @@ -85,7 +88,11 @@ export const Image: FunctionComponent> = (props) => { overflow: radius !== undefined && radius !== null ? 'hidden' : '', borderRadius: // eslint-disable-next-line no-nested-ternary - radius != null ? (Taro.getEnv() === 'RN' ? radius : pxCheck(radius)) : '', + radius !== undefined && radius != null + ? Taro.getEnv() === 'RN' + ? radius + : pxCheck(radius) + : '', } const imgStyle: any = { @@ -127,7 +134,7 @@ export const Image: FunctionComponent> = (props) => { handleLoad(e)} diff --git a/src/packages/image/image.tsx b/src/packages/image/image.tsx index 7dbe30c088..331125335c 100644 --- a/src/packages/image/image.tsx +++ b/src/packages/image/image.tsx @@ -9,7 +9,6 @@ import React, { import { Image as ImageIcon, ImageError } from '@nutui/icons-react' import classNames from 'classnames' import { BasicComponent, ComponentDefaults } from '@/utils/typings' -import { pxCheck } from '@/utils/px-check' export interface ImageProps extends BasicComponent { src: string @@ -82,6 +81,9 @@ export const Image: FunctionComponent< const [isError, setIsError] = useState(false) const [complete, setComplete] = useState(false) const imgRef = useRef(null) + const pxCheck = (value: string | number): string => { + return Number.isNaN(Number(value)) ? String(value) : `${value}px` + } useEffect(() => { if (imgRef.current && imgRef.current.complete && !lazy) {