Skip to content

Commit

Permalink
feat: toast support bytedance-microapp (#69)
Browse files Browse the repository at this point in the history
* feat: toast support bytedance-microapp

* fix: docs

* fix: directory unification

* fix: version

Co-authored-by: siteng.xst <siteng.xst@alibaba-inc.com>
  • Loading branch information
lovesong and siteng.xst authored Apr 21, 2020
1 parent 6b3fb58 commit 91ac4e7
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 6 deletions.
1 change: 1 addition & 0 deletions packages/toast/README-zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

## 支持
<img alt="browser" src="https://gw.alicdn.com/tfs/TB1uYFobGSs3KVjSZPiXXcsiVXa-200-200.svg" width="25px" height="25px" /> <img alt="weex" src="https://gw.alicdn.com/tfs/TB1jM0ebMaH3KVjSZFjXXcFWpXa-200-200.svg" width="25px" height="25px" /> <img alt="miniApp" src="https://gw.alicdn.com/tfs/TB1bBpmbRCw3KVjSZFuXXcAOpXa-200-200.svg" width="25px" height="25px" /> <img alt="wechatMiniprogram" src="https://img.alicdn.com/tfs/TB1slcYdxv1gK0jSZFFXXb0sXXa-200-200.svg" width="25px" height="25px">
<img alt="bytedanceMicroApp" src="https://gw.alicdn.com/tfs/TB1jFtVzO_1gK0jSZFqXXcpaXXa-200-200.svg" width="25px" height="25px">

## 安装

Expand Down
1 change: 1 addition & 0 deletions packages/toast/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Universal toast, you can choose how many seconds after disappearing

## Support
<img alt="browser" src="https://gw.alicdn.com/tfs/TB1uYFobGSs3KVjSZPiXXcsiVXa-200-200.svg" width="25px" height="25px" /> <img alt="weex" src="https://gw.alicdn.com/tfs/TB1jM0ebMaH3KVjSZFjXXcFWpXa-200-200.svg" width="25px" height="25px" /> <img alt="miniApp" src="https://gw.alicdn.com/tfs/TB1bBpmbRCw3KVjSZFuXXcAOpXa-200-200.svg" width="25px" height="25px" /> <img alt="wechatMiniprogram" src="https://img.alicdn.com/tfs/TB1slcYdxv1gK0jSZFFXXb0sXXa-200-200.svg" width="25px" height="25px">
<img alt="bytedanceMicroApp" src="https://gw.alicdn.com/tfs/TB1jFtVzO_1gK0jSZFqXXcpaXXa-200-200.svg" width="25px" height="25px">

## Install

Expand Down
2 changes: 1 addition & 1 deletion packages/toast/docs-template/README-zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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__

## 安装

Expand Down
2 changes: 1 addition & 1 deletion packages/toast/docs-template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion packages/toast/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "universal-toast",
"author": "rax",
"version": "1.0.4",
"version": "1.1.0",
"description": "",
"main": "lib/index.js",
"files": [
Expand Down
9 changes: 6 additions & 3 deletions packages/toast/src/index.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -16,6 +17,8 @@ if (isWeb) {
Toast = miniAppModule;
} else if (isWeChatMiniProgram) {
Toast = weChatModule;
} else if (isByteDanceMicroApp) {
Toast = byteDanceModule;
} else {
// Web as default
Toast = webModule;
Expand Down
File renamed without changes.
23 changes: 23 additions & 0 deletions packages/toast/src/miniapp/bytedance-microapp/index.ts
Original file line number Diff line number Diff line change
@@ -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;
File renamed without changes.

0 comments on commit 91ac4e7

Please sign in to comment.