diff --git a/packages/toast/README-zh_CN.md b/packages/toast/README-zh_CN.md index ab1e986b..feb305e8 100644 --- a/packages/toast/README-zh_CN.md +++ b/packages/toast/README-zh_CN.md @@ -4,6 +4,7 @@ ## 支持 browser weex miniApp wechatMiniprogram +bytedanceMicroApp ## 安装 diff --git a/packages/toast/README.md b/packages/toast/README.md index d5dd11f0..3ba38919 100644 --- a/packages/toast/README.md +++ b/packages/toast/README.md @@ -4,6 +4,7 @@ Universal toast, you can choose how many seconds after disappearing ## Support browser weex miniApp wechatMiniprogram +bytedanceMicroApp ## Install diff --git a/packages/toast/docs-template/README-zh_CN.md b/packages/toast/docs-template/README-zh_CN.md index 07456d1f..ee716115 100644 --- a/packages/toast/docs-template/README-zh_CN.md +++ b/packages/toast/docs-template/README-zh_CN.md @@ -3,7 +3,7 @@ 通用弱提示,可选择多少秒之后消失 ## 支持 -__icon_web__ __icon_weex__ __icon_miniapp_mp__ __icon_miniapp_wx__ +__icon_web__ __icon_weex__ __icon_miniapp_mp__ __icon_miniapp_wx__ __icon_miniapp_tt__ ## 安装 diff --git a/packages/toast/docs-template/README.md b/packages/toast/docs-template/README.md index 3494bcb4..093d544a 100644 --- a/packages/toast/docs-template/README.md +++ b/packages/toast/docs-template/README.md @@ -3,7 +3,7 @@ Universal toast, you can choose how many seconds after disappearing ## Support -__icon_web__ __icon_weex__ __icon_miniapp_mp__ __icon_miniapp_wx__ +__icon_web__ __icon_weex__ __icon_miniapp_mp__ __icon_miniapp_wx__ __icon_miniapp_tt__ ## Install diff --git a/packages/toast/package.json b/packages/toast/package.json index 37466974..a4736d43 100644 --- a/packages/toast/package.json +++ b/packages/toast/package.json @@ -1,7 +1,7 @@ { "name": "universal-toast", "author": "rax", - "version": "1.0.4", + "version": "1.1.0", "description": "", "main": "lib/index.js", "files": [ diff --git a/packages/toast/src/index.ts b/packages/toast/src/index.ts index 41b3301e..50616033 100644 --- a/packages/toast/src/index.ts +++ b/packages/toast/src/index.ts @@ -1,8 +1,9 @@ -import { isWeex, isMiniApp, isWeb, isWeChatMiniProgram } from 'universal-env'; +import { isWeex, isMiniApp, isWeb, isWeChatMiniProgram, isByteDanceMicroApp } from 'universal-env'; import webModule from './web/index'; import weexModule from './weex/index'; -import miniAppModule from './miniapp/ali/index'; -import weChatModule from './miniapp/wechat/index'; +import miniAppModule from './miniapp/ali-miniapp/index'; +import weChatModule from './miniapp/wechat-miniprogram/index'; +import byteDanceModule from './miniapp/bytedance-microapp/index'; import { ToastOption } from './types'; let Toast: ToastOption = {} as any; @@ -16,6 +17,8 @@ if (isWeb) { Toast = miniAppModule; } else if (isWeChatMiniProgram) { Toast = weChatModule; +} else if (isByteDanceMicroApp) { + Toast = byteDanceModule; } else { // Web as default Toast = webModule; diff --git a/packages/toast/src/miniapp/ali/index.ts b/packages/toast/src/miniapp/ali-miniapp/index.ts similarity index 100% rename from packages/toast/src/miniapp/ali/index.ts rename to packages/toast/src/miniapp/ali-miniapp/index.ts diff --git a/packages/toast/src/miniapp/bytedance-microapp/index.ts b/packages/toast/src/miniapp/bytedance-microapp/index.ts new file mode 100644 index 00000000..0eab5b0c --- /dev/null +++ b/packages/toast/src/miniapp/bytedance-microapp/index.ts @@ -0,0 +1,23 @@ +import {LONG_DELAY, SHORT_DELAY} from '../../utils/index'; +import { ToastOption } from '../../types'; + +declare const tt: any; + +let Toast: ToastOption = { + SHORT: SHORT_DELAY, + LONG: LONG_DELAY, + + /* + * @param message {String} + * @param duration {Number} + * @param userStyle {Object} user defined style + */ + show(message: string = '', duration: number = SHORT_DELAY): void { + tt.showToast({ + title: message, + duration + }); + }, +}; + +export default Toast; diff --git a/packages/toast/src/miniapp/wechat/index.ts b/packages/toast/src/miniapp/wechat-miniprogram/index.ts similarity index 100% rename from packages/toast/src/miniapp/wechat/index.ts rename to packages/toast/src/miniapp/wechat-miniprogram/index.ts