From 59639fecf91a21fb0bfaedfbd91bf59ea45a56e3 Mon Sep 17 00:00:00 2001 From: lixiaobing Date: Wed, 13 Apr 2022 14:20:19 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DpreviewImage=20?= =?UTF-8?q?=E9=A2=84=E8=A7=88=E5=9B=BE=E7=89=87API=E7=9A=84current?= =?UTF-8?q?=E5=BF=85=E9=A1=BB=E6=98=AFurls=E5=85=B6=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=E4=B8=80=E4=B8=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/taro-rn/src/lib/previewImage/index.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/taro-rn/src/lib/previewImage/index.tsx b/packages/taro-rn/src/lib/previewImage/index.tsx index 108cfad63383..6e2a2c98dd12 100644 --- a/packages/taro-rn/src/lib/previewImage/index.tsx +++ b/packages/taro-rn/src/lib/previewImage/index.tsx @@ -26,9 +26,9 @@ export function previewImage(obj: Taro.previewImage.Option): void { complete }: any = obj || {} const index = urls.indexOf(current) - if (index === -1) { - throw new Error('"current" or "urls" is invalid') - } + // if (index === -1) { + // throw new Error('"current" or "urls" is invalid') + // } let sibling function backhandler() { From c00c1e753e8f02514031339d1493684d350b67c6 Mon Sep 17 00:00:00 2001 From: lixiaobing Date: Tue, 19 Apr 2022 19:18:03 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96previewImage?= =?UTF-8?q?=E9=A2=84=E8=A7=88=E5=9B=BE=E7=89=87api=E7=9A=84=E4=BC=A0?= =?UTF-8?q?=E5=8F=82=E6=A0=A1=E9=AA=8C=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/taro-rn/src/lib/previewImage/index.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/taro-rn/src/lib/previewImage/index.tsx b/packages/taro-rn/src/lib/previewImage/index.tsx index 6e2a2c98dd12..5d63152a932e 100644 --- a/packages/taro-rn/src/lib/previewImage/index.tsx +++ b/packages/taro-rn/src/lib/previewImage/index.tsx @@ -25,10 +25,13 @@ export function previewImage(obj: Taro.previewImage.Option): void { fail, complete }: any = obj || {} - const index = urls.indexOf(current) - // if (index === -1) { - // throw new Error('"current" or "urls" is invalid') - // } + + let index = 0 + if (urls.length === 0) { + throw new Error('"current" or "urls" is invalid') + } else { + index = Math.max(current, urls.indexOf(current)) + } let sibling function backhandler() { From 50d784535630e78908c14ca17f6ce7905492b8be Mon Sep 17 00:00:00 2001 From: lixiaobing Date: Wed, 20 Apr 2022 14:27:36 +0800 Subject: [PATCH 3/4] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96previewImage?= =?UTF-8?q?=E9=A2=84=E8=A7=88=E5=9B=BE=E7=89=87api=E7=9A=84=E4=BC=A0?= =?UTF-8?q?=E5=8F=82=E6=A0=A1=E9=AA=8C=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/taro-rn/src/lib/previewImage/index.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/taro-rn/src/lib/previewImage/index.tsx b/packages/taro-rn/src/lib/previewImage/index.tsx index 5d63152a932e..299b68a01f4b 100644 --- a/packages/taro-rn/src/lib/previewImage/index.tsx +++ b/packages/taro-rn/src/lib/previewImage/index.tsx @@ -27,10 +27,11 @@ export function previewImage(obj: Taro.previewImage.Option): void { }: any = obj || {} let index = 0 - if (urls.length === 0) { - throw new Error('"current" or "urls" is invalid') + if (!urls || urls.length === 0) { + throw new Error('待预览的图片列表"urls"不能为空') } else { - index = Math.max(current, urls.indexOf(current)) + urls.indexOf(current) === -1 ? console.warn('显示的图片不在预览列表当中') : '' + index = Math.max(0, urls.indexOf(current)) } let sibling From 7e872cb05741761acb8a8ea77a8b924468a37fc0 Mon Sep 17 00:00:00 2001 From: lixiaobing Date: Thu, 21 Apr 2022 09:09:33 +0800 Subject: [PATCH 4/4] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E9=A2=84=E8=A7=88?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E6=A0=A1=E9=AA=8C=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/taro-rn/src/lib/previewImage/index.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/taro-rn/src/lib/previewImage/index.tsx b/packages/taro-rn/src/lib/previewImage/index.tsx index 299b68a01f4b..1d265c69183e 100644 --- a/packages/taro-rn/src/lib/previewImage/index.tsx +++ b/packages/taro-rn/src/lib/previewImage/index.tsx @@ -28,10 +28,11 @@ export function previewImage(obj: Taro.previewImage.Option): void { let index = 0 if (!urls || urls.length === 0) { - throw new Error('待预览的图片列表"urls"不能为空') + throw new Error('the list of images to be previewed "urls" cannot be empty') } else { - urls.indexOf(current) === -1 ? console.warn('显示的图片不在预览列表当中') : '' - index = Math.max(0, urls.indexOf(current)) + const _index = urls.indexOf(current) + _index === -1 ? console.warn('the displayed image is not in the preview list') : '' + index = Math.max(0, _index) } let sibling