From 60e0d9816c559a09d6f374e91ceb16d131fcdcb7 Mon Sep 17 00:00:00 2001 From: yijinc Date: Mon, 13 Feb 2023 14:51:42 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix(types):=20hideLoading.Option=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20noConflict=20=E5=8F=AF=E9=80=89=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/taro/types/api/ui/interaction.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/taro/types/api/ui/interaction.d.ts b/packages/taro/types/api/ui/interaction.d.ts index cba0d4ff6c11..30b2c3ab48ad 100644 --- a/packages/taro/types/api/ui/interaction.d.ts +++ b/packages/taro/types/api/ui/interaction.d.ts @@ -113,6 +113,8 @@ declare module '../../index' { namespace hideLoading { interface Option { + /** 2.22.1 以上版本 toast 和 loading 相关接口可以相互混用,此参数可用于取消混用特性 */ + noConflict?: boolean /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: (res: TaroGeneral.CallbackResult) => void /** 接口调用失败的回调函数 */ From ac748458a59c9c7a6946dd0d9b33ccbef8952478 Mon Sep 17 00:00:00 2001 From: Zakary Date: Tue, 14 Feb 2023 11:19:16 +0800 Subject: [PATCH 2/4] fix(types): update hide loading & model typings --- packages/taro/types/api/ui/interaction.d.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/taro/types/api/ui/interaction.d.ts b/packages/taro/types/api/ui/interaction.d.ts index 30b2c3ab48ad..2db00a625304 100644 --- a/packages/taro/types/api/ui/interaction.d.ts +++ b/packages/taro/types/api/ui/interaction.d.ts @@ -102,6 +102,10 @@ declare module '../../index' { namespace hideToast { interface Option { + /** 目前 toast 和 loading 相关接口可以相互混用,此参数可用于取消混用特性 + * @default false + */ + noConflict?: boolean /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: (res: TaroGeneral.CallbackResult) => void /** 接口调用失败的回调函数 */ @@ -113,7 +117,9 @@ declare module '../../index' { namespace hideLoading { interface Option { - /** 2.22.1 以上版本 toast 和 loading 相关接口可以相互混用,此参数可用于取消混用特性 */ + /** 目前 toast 和 loading 相关接口可以相互混用,此参数可用于取消混用特性 + * @default false + */ noConflict?: boolean /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: (res: TaroGeneral.CallbackResult) => void From bd33f282935f92e2d27056b888616e68f159891f Mon Sep 17 00:00:00 2001 From: Zakary Date: Tue, 14 Feb 2023 11:20:02 +0800 Subject: [PATCH 3/4] =?UTF-8?q?feat(h5):=20=E6=94=AF=E6=8C=81=20noConflict?= =?UTF-8?q?=20=E5=8F=82=E6=95=B0=EF=BC=8C=E4=B8=8E=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E4=BF=9D=E6=8C=81=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/taro-h5/src/api/ui/interaction/index.ts | 8 ++++---- packages/taro-h5/src/api/ui/interaction/toast.ts | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/taro-h5/src/api/ui/interaction/index.ts b/packages/taro-h5/src/api/ui/interaction/index.ts index 9da9b2fac25b..dfff71154062 100644 --- a/packages/taro-h5/src/api/ui/interaction/index.ts +++ b/packages/taro-h5/src/api/ui/interaction/index.ts @@ -71,10 +71,10 @@ const showToast: typeof Taro.showToast = (options = { title: '' }) => { return handle.success({ errMsg }) } -const hideToast: typeof Taro.hideToast = ({ success, fail, complete } = {}) => { +const hideToast: typeof Taro.hideToast = ({ noConflict = false, success, fail, complete } = {}) => { const handle = new MethodHandler({ name: 'hideToast', success, fail, complete }) if (!toast.el) return handle.success() - toast.hide(0, 'toast') + toast.hide(0, noConflict ? 'toast' : '') return handle.success() } @@ -116,10 +116,10 @@ const showLoading: typeof Taro.showLoading = (options = { title: '' }) => { return handle.success({ errMsg }) } -const hideLoading: typeof Taro.hideLoading = ({ success, fail, complete } = {}) => { +const hideLoading: typeof Taro.hideLoading = ({ noConflict = false, success, fail, complete } = {}) => { const handle = new MethodHandler({ name: 'hideLoading', success, fail, complete }) if (!toast.el) return handle.success() - toast.hide(0, 'loading') + toast.hide(0, noConflict ? 'loading' : '') return handle.success() } diff --git a/packages/taro-h5/src/api/ui/interaction/toast.ts b/packages/taro-h5/src/api/ui/interaction/toast.ts index a791b8f2c3b8..1132334c4e5b 100644 --- a/packages/taro-h5/src/api/ui/interaction/toast.ts +++ b/packages/taro-h5/src/api/ui/interaction/toast.ts @@ -215,8 +215,8 @@ export default class Toast { return '' } - hide (duration = 0, type) { - if (this.type !== type) return + hide (duration = 0, type = '') { + if (type && type !== this.type) return if (this.hideOpacityTimer) clearTimeout(this.hideOpacityTimer) if (this.hideDisplayTimer) clearTimeout(this.hideDisplayTimer) From eee79f4ef9f74cbcf6f3b0629c2f6a9b4f3412b8 Mon Sep 17 00:00:00 2001 From: yijinc Date: Tue, 14 Feb 2023 13:41:26 +0800 Subject: [PATCH 4/4] =?UTF-8?q?fix(types):=20hideLoading.Option/hideToast.?= =?UTF-8?q?Option=20=E6=B7=BB=E5=8A=A0=20noConflict=20=E5=8F=AF=E9=80=89?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/taro/types/api/ui/interaction.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/taro/types/api/ui/interaction.d.ts b/packages/taro/types/api/ui/interaction.d.ts index cba0d4ff6c11..7dcc50f8b24f 100644 --- a/packages/taro/types/api/ui/interaction.d.ts +++ b/packages/taro/types/api/ui/interaction.d.ts @@ -102,6 +102,8 @@ declare module '../../index' { namespace hideToast { interface Option { + /** 目前 toast 和 loading 相关接口可以相互混用,此参数可用于取消混用特性。默认 false */ + noConflict?: boolean /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: (res: TaroGeneral.CallbackResult) => void /** 接口调用失败的回调函数 */ @@ -113,6 +115,8 @@ declare module '../../index' { namespace hideLoading { interface Option { + /** 目前 toast 和 loading 相关接口可以相互混用,此参数可用于取消混用特性。默认 false */ + noConflict?: boolean /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: (res: TaroGeneral.CallbackResult) => void /** 接口调用失败的回调函数 */