Skip to content

Commit

Permalink
Merge pull request #13282 from yijinc/next
Browse files Browse the repository at this point in the history
fix(types): hideLoading.Option 添加 noConflict 可选字段
  • Loading branch information
ZakaryCode authored Feb 14, 2023
2 parents bc113c8 + c5337ae commit 6e01e15
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
8 changes: 4 additions & 4 deletions packages/taro-h5/src/api/ui/interaction/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down Expand Up @@ -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()
}

Expand Down
4 changes: 2 additions & 2 deletions packages/taro-h5/src/api/ui/interaction/toast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions packages/taro/types/api/ui/interaction.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ declare module '../../index' {

namespace hideToast {
interface Option {
/** 目前 toast 和 loading 相关接口可以相互混用,此参数可用于取消混用特性
* @default false
*/
noConflict?: boolean
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
complete?: (res: TaroGeneral.CallbackResult) => void
/** 接口调用失败的回调函数 */
Expand All @@ -113,6 +117,10 @@ declare module '../../index' {

namespace hideLoading {
interface Option {
/** 目前 toast 和 loading 相关接口可以相互混用,此参数可用于取消混用特性
* @default false
*/
noConflict?: boolean
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
complete?: (res: TaroGeneral.CallbackResult) => void
/** 接口调用失败的回调函数 */
Expand Down

0 comments on commit 6e01e15

Please sign in to comment.