Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: toast support bytedance-microapp #69

Merged
merged 5 commits into from
Apr 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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;