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(universal-alert): support bytedance #73

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
6 changes: 3 additions & 3 deletions packages/alert/README-zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ alert 警告框


## 支持
<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="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 Expand Up @@ -34,6 +34,6 @@ Alert({
| 成员 | 类型 | 描述 | 默认值 | 支持 |
| ------------------ | -------- | --------------------------------- | :-------: | :----------: |
| options | `object` | alert 参数 | - | - |
| options.title | `string` | alert 标题,仅在小程序中支持 | - | <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"> |
| options.title | `string` | alert 标题,仅在小程序中支持 | - | <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"> |
| options.content | `string` | alert 内容 | - | |
| options.buttonText | `string` | alert 确认按钮文字,不支持web环境 | - | <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"> |
| options.buttonText | `string` | alert 确认按钮文字,不支持web环境 | - | <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"> |
6 changes: 3 additions & 3 deletions packages/alert/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Alert component for feedback.


## 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="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 Expand Up @@ -34,6 +34,6 @@ Alert({
| Property | Type | Description | Default | Supported |
| ------------------ | -------- | ----------------------------------------------------- | :-------: | :----------: |
| options | `object` | alert arguments | - | |
| options.title | `string` | alert title,support only in mini app | - | <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"> |
| options.title | `string` | alert title,support only in mini app | - | <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"> |
| options.content | `string` | alert content | - | |
| options.buttonText | `string` | alert button text,web environments are not supported | - | <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"> |
| options.buttonText | `string` | alert button text,web environments are not supported | - | <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"> |
6 changes: 3 additions & 3 deletions packages/alert/docs-template/README-zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ alert 警告框


## 支持
__icon_web__ __icon_weex__ __icon_miniapp_mp__ __icon_miniapp_wx__
__icon_web__ __icon_weex__ __icon_miniapp_mp__ __icon_miniapp_wx__ __icon_microapp_tt__

## 安装

Expand Down Expand Up @@ -34,6 +34,6 @@ Alert({
| 成员 | 类型 | 描述 | 默认值 | 支持 |
| ------------------ | -------- | --------------------------------- | :-------: | :----------: |
| options | `object` | alert 参数 | - | - |
| options.title | `string` | alert 标题,仅在小程序中支持 | - | __icon_miniapp_mp__ __icon_miniapp_wx__ |
| options.title | `string` | alert 标题,仅在小程序中支持 | - | __icon_miniapp_mp__ __icon_miniapp_wx__ __icon_microapp_tt__ |
| options.content | `string` | alert 内容 | - | |
| options.buttonText | `string` | alert 确认按钮文字,不支持web环境 | - | __icon_weex__ __icon_miniapp_mp__ __icon_miniapp_wx__ |
| options.buttonText | `string` | alert 确认按钮文字,不支持web环境 | - | __icon_weex__ __icon_miniapp_mp__ __icon_miniapp_wx__ __icon_microapp_tt__ |
6 changes: 3 additions & 3 deletions packages/alert/docs-template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Alert component for feedback.


## Support
__icon_web__ __icon_weex__ __icon_miniapp_mp__ __icon_miniapp_wx__
__icon_web__ __icon_weex__ __icon_miniapp_mp__ __icon_miniapp_wx__ __icon_microapp_tt__

## Install

Expand Down Expand Up @@ -34,6 +34,6 @@ Alert({
| Property | Type | Description | Default | Supported |
| ------------------ | -------- | ----------------------------------------------------- | :-------: | :----------: |
| options | `object` | alert arguments | - | |
| options.title | `string` | alert title,support only in mini app | - | __icon_miniapp_mp__ __icon_miniapp_wx__ |
| options.title | `string` | alert title,support only in mini app | - | __icon_miniapp_mp__ __icon_miniapp_wx__ __icon_microapp_tt__ |
| options.content | `string` | alert content | - | |
| options.buttonText | `string` | alert button text,web environments are not supported | - | __icon_weex__ __icon_miniapp_mp__ __icon_miniapp_wx__ |
| options.buttonText | `string` | alert button text,web environments are not supported | - | __icon_weex__ __icon_miniapp_mp__ __icon_miniapp_wx__ __icon_microapp_tt__ |
4 changes: 2 additions & 2 deletions packages/alert/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "universal-alert",
"author": "rax",
"version": "1.0.2",
"version": "1.1.0",
"license": "BSD-3-Clause",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand All @@ -19,7 +19,7 @@
"npm": ">=3.0.0"
},
"dependencies": {
"universal-env": "^2.0.0"
"universal-env": "^3.0.0"
},
"devDependencies": {
"@types/jest": "^24.0.12",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Options } from '../../types';
import { Options } from '../types';

declare const my: any;

Expand Down
23 changes: 23 additions & 0 deletions packages/alert/src/bytedance-microapp/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Options } from '../types';

declare const tt: any;

const alert = (options: Options): Promise<null> => {
return new Promise((resolve, reject): void => {
const { title = '', content = '', buttonText = '确定' } = options;
tt.showModal({
title,
content,
showCancel: false,
confirmText: buttonText,
success: (): void => {
resolve();
},
fail: (): void => {
reject();
}
});
});
};

export default alert;
12 changes: 8 additions & 4 deletions packages/alert/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { isWeb, isWeex, isMiniApp, isWeChatMiniprogram } from 'universal-env';
import { isWeb, isWeex, isMiniApp, 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 './ali-miniapp/index';
import weChatModule from './wechat-miniprogram/index';
import byteDanceModule from './bytedance-microapp/index';

import { Alert } from './types';

Expand All @@ -16,8 +17,11 @@ if (isWeex) {
if (isMiniApp) {
alert = miniAppModule;
}
if (isWeChatMiniprogram) {
if (isWeChatMiniProgram) {
alert = weChatModule;
}
if (isByteDanceMicroApp) {
alert = byteDanceModule;
}

export default alert;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Options } from '../../types';
import { Options } from '../types';

declare const wx: any;

Expand Down