Skip to content

Commit

Permalink
feat(Toast): add hide
Browse files Browse the repository at this point in the history
  • Loading branch information
rorya.lyj committed Sep 4, 2020
1 parent b114a95 commit da0e6d1
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/toast/README-zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ Toast.show('Hi');
| message | `string` | 文字内容 | - |
| duration | `number` | 显示时长,单位为 ms | 2000 |
| options | `object` | 其他参数,微信小程序/字节跳动小程序平台可用配置,参考[文档](https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.showToast.html) | {} |

### `Toast.hide()`

隐藏Toast
4 changes: 4 additions & 0 deletions packages/toast/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ Toast.show('Hi');
| message | `string` | content of the message | - |
| duration | `number` | Time in millisecond before Toast is closed. | 2000 |
| options | `object` | Other options used by WeChat MiniProgram/ByteDance MicroApp, see [docs](https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.showToast.html) | {} |

### `Toast.hide()`

Hide toast
5 changes: 5 additions & 0 deletions packages/toast/docs-template/README-zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import Toast from 'universal-toast';

Toast.show('Hi');

Toast.hide();
```

## 方法
Expand All @@ -33,3 +34,7 @@ Toast.show('Hi');
| message | `string` | 文字内容 | - |
| duration | `number` | 显示时长,单位为 ms | 2000 |
| options | `object` | 其他参数,微信小程序/字节跳动小程序平台可用配置,参考[文档](https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.showToast.html) | {} |

### `Toast.hide()`

隐藏Toast
6 changes: 6 additions & 0 deletions packages/toast/docs-template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import Toast from 'universal-toast';
// import Toast from 'universal-toast/lib/quickapp;

Toast.show('Hi');

Toast.hide();
```

## Methods
Expand All @@ -32,3 +34,7 @@ Toast.show('Hi');
| message | `string` | content of the message | - |
| duration | `number` | Time in millisecond before Toast is closed. | 2000 |
| options | `object` | Other options used by WeChat MiniProgram/ByteDance MicroApp, see [docs](https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.showToast.html) | {} |

### `Toast.hide()`

Hide toast
4 changes: 4 additions & 0 deletions packages/toast/src/miniapp/ali-miniapp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ let Toast: ToastOption = {
duration
});
},

hide() {
my.hideToast();
}
};

export default Toast;
4 changes: 4 additions & 0 deletions packages/toast/src/miniapp/bytedance-microapp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ let Toast: ToastOption = {
...options
});
},

hide() {
tt.hideToast();
}
};

export default Toast;
4 changes: 4 additions & 0 deletions packages/toast/src/miniapp/wechat-miniprogram/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ let Toast: ToastOption = {
...options
});
},

hide() {
wx.hideToast();
}
};

export default Toast;
4 changes: 4 additions & 0 deletions packages/toast/src/quickapp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ const Toast: ToastOption = {
message,
duration
});
},

hide() {
console.error('hide toast not supported yet');
}
};

Expand Down
1 change: 1 addition & 0 deletions packages/toast/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export interface ToastOption {
SHORT: number;
LONG: number;
show: (message: string, duration?: number, options?: object) => void;
hide: () => void;
};
7 changes: 7 additions & 0 deletions packages/toast/src/web/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ let Toast: ToastOption = {
show(message: string, duration: number = SHORT_DELAY): void {
toast.push(message, duration);
},

hide() {
// remove all queued messages
while (queue.length) queue.pop();
hideToastWindow();
isProcessing = false;
}
};

export default Toast;
4 changes: 4 additions & 0 deletions packages/toast/src/weex/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ let Toast: ToastOption = {
});
}
},

hide() {
console.error('hide toast not supported yet');
}
};

export default Toast;

0 comments on commit da0e6d1

Please sign in to comment.