From 2720f7e4f193350b791665567b06ecbc35bb4f5f Mon Sep 17 00:00:00 2001 From: "xuying.xu" Date: Thu, 21 Mar 2024 20:02:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20guide=E8=B6=85=E5=87=BA=E8=8C=83?= =?UTF-8?q?=E5=9B=B4=E4=B8=8D=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/f2/src/components/guide/views/Arc.tsx | 2 ++ packages/f2/src/components/guide/views/Image.tsx | 2 ++ packages/f2/src/components/guide/views/Line.tsx | 3 +++ packages/f2/src/components/guide/views/Lottie.tsx | 2 ++ packages/f2/src/components/guide/views/Point.tsx | 3 ++- packages/f2/src/components/guide/views/Rect.tsx | 4 +++- packages/f2/src/components/guide/views/Tag.tsx | 3 ++- packages/f2/src/components/guide/views/Text.tsx | 1 + packages/f2/src/components/guide/withGuide.tsx | 2 -- 9 files changed, 17 insertions(+), 5 deletions(-) diff --git a/packages/f2/src/components/guide/views/Arc.tsx b/packages/f2/src/components/guide/views/Arc.tsx index 82ee058c2..4229a429e 100644 --- a/packages/f2/src/components/guide/views/Arc.tsx +++ b/packages/f2/src/components/guide/views/Arc.tsx @@ -11,6 +11,8 @@ export interface ArcGuideProps extends GuideProps { export default (props: ArcGuideProps) => { const { theme = {} } = props; const { coord, points, style, animation } = deepMix({ ...theme.line }, props); + const checkNaN = points.some((d)=> isNaN(d.x) || isNaN(d.y)) + if(checkNaN) return null; const start = points[0] || {}; const end = points[1] || {}; diff --git a/packages/f2/src/components/guide/views/Image.tsx b/packages/f2/src/components/guide/views/Image.tsx index e88cd0328..028a64d65 100644 --- a/packages/f2/src/components/guide/views/Image.tsx +++ b/packages/f2/src/components/guide/views/Image.tsx @@ -22,6 +22,8 @@ export default (props: ImageGuideProps, context) => { const cfg = deepMix({}, defaultProps, props); const { points, style, attrs, offsetX, offsetY, src, animation } = cfg; const { x, y } = points[0] || {}; + if(isNaN(x) || isNaN(y)) return null; + const { height = 0, width = 0 } = { ...attrs, ...style }; const heightNum = context.px2hd(height + 'px'); const widthNum = context.px2hd(width + 'px'); diff --git a/packages/f2/src/components/guide/views/Line.tsx b/packages/f2/src/components/guide/views/Line.tsx index 95ba5ae00..f1e2085ef 100644 --- a/packages/f2/src/components/guide/views/Line.tsx +++ b/packages/f2/src/components/guide/views/Line.tsx @@ -13,6 +13,9 @@ export interface LineGuideProps extends GuideProps { export default (props: LineGuideProps, context) => { const { theme = {} } = props; const { points, style, offsetX, offsetY, animation } = deepMix({ ...theme.line }, props); + const checkNaN = points.some((d)=> isNaN(d.x) || isNaN(d.y)) + if(checkNaN) return; + const { x: x1, y: y1 } = points[0] || {}; const { x: x2, y: y2 } = points[1] || {}; diff --git a/packages/f2/src/components/guide/views/Lottie.tsx b/packages/f2/src/components/guide/views/Lottie.tsx index ec1ab2d5d..582f70501 100644 --- a/packages/f2/src/components/guide/views/Lottie.tsx +++ b/packages/f2/src/components/guide/views/Lottie.tsx @@ -28,6 +28,8 @@ export default (props: LottieGuideProps, context) => { const cfg = deepMix({}, defaultProps, props); const { points, style, offsetX, offsetY, lottieJson, animation, options } = cfg; const { x, y } = points[0] || {}; + if(isNaN(x) || isNaN(y)) return null; + const { height = 0, width = 0 } = style; const offsetXNum = context.px2hd(offsetX); diff --git a/packages/f2/src/components/guide/views/Point.tsx b/packages/f2/src/components/guide/views/Point.tsx index 51e4be8d1..cb5e998d1 100644 --- a/packages/f2/src/components/guide/views/Point.tsx +++ b/packages/f2/src/components/guide/views/Point.tsx @@ -14,7 +14,8 @@ export default (props: PointGuideProps, context) => { const { theme } = props; const { points, style, offsetX, offsetY, animation } = deepMix({ ...theme.point }, props); const { x, y } = points[0] || {}; - + if(isNaN(x) || isNaN(y)) return null; + const offsetXNum = context.px2hd(offsetX); const offsetYNum = context.px2hd(offsetY); const posX = x + (offsetXNum || 0); diff --git a/packages/f2/src/components/guide/views/Rect.tsx b/packages/f2/src/components/guide/views/Rect.tsx index 494746347..d297193a4 100644 --- a/packages/f2/src/components/guide/views/Rect.tsx +++ b/packages/f2/src/components/guide/views/Rect.tsx @@ -11,7 +11,9 @@ export interface RectGuideProps extends GuideProps { export default (props: RectGuideProps) => { const { theme = {} } = props; const { points, style, animation } = deepMix({ ...theme.rect }, props); - + const checkNaN = points.some((d)=> isNaN(d.x) || isNaN(d.y)) + if(checkNaN) return null; + const start = points[0] || {}; const end = points[1] || {}; diff --git a/packages/f2/src/components/guide/views/Tag.tsx b/packages/f2/src/components/guide/views/Tag.tsx index b1b6125f2..97e88a0e0 100644 --- a/packages/f2/src/components/guide/views/Tag.tsx +++ b/packages/f2/src/components/guide/views/Tag.tsx @@ -95,7 +95,8 @@ export default class Tag extends Component { textStyle, } = px2hd(cfg); const { x, y } = points[0] || {}; - + if(isNaN(x) || isNaN(y)) return null; + const offsetXNum = context.px2hd(offsetX); const offsetYNum = context.px2hd(offsetY); let posX = x + (offsetXNum || 0); diff --git a/packages/f2/src/components/guide/views/Text.tsx b/packages/f2/src/components/guide/views/Text.tsx index 0599582e0..27659a390 100644 --- a/packages/f2/src/components/guide/views/Text.tsx +++ b/packages/f2/src/components/guide/views/Text.tsx @@ -16,6 +16,7 @@ export default (props: TextGuideProps, context) => { const { points, style, offsetX, offsetY, content, animation } = deepMix({ ...theme.text }, props); const { x, y } = points[0] || {}; + if(isNaN(x) || isNaN(y)) return null; const offsetXNum = context.px2hd(offsetX); const offsetYNum = context.px2hd(offsetY); const posX = x + (offsetXNum || 0); diff --git a/packages/f2/src/components/guide/withGuide.tsx b/packages/f2/src/components/guide/withGuide.tsx index 685a685e0..de7e08e7c 100644 --- a/packages/f2/src/components/guide/withGuide.tsx +++ b/packages/f2/src/components/guide/withGuide.tsx @@ -81,8 +81,6 @@ export default function( const { width, height } = context; const points = this.convertPoints(records); const theme = this.getGuideTheme(); - const checkNaN = points.some((d)=> isNaN(d.x) || isNaN(d.y)) - if(checkNaN) return; return (