diff --git a/packages/confirm/README-zh_CN.md b/packages/confirm/README-zh_CN.md index 46584906..a03994f1 100644 --- a/packages/confirm/README-zh_CN.md +++ b/packages/confirm/README-zh_CN.md @@ -3,7 +3,7 @@ confirm 确认框 ## 支持 -browser weex miniApp wechatMiniprogram +browser weex miniApp wechatMiniprogram bytedanceMicroApp ## 安装 diff --git a/packages/confirm/README.md b/packages/confirm/README.md index 78f12a75..bcca494f 100644 --- a/packages/confirm/README.md +++ b/packages/confirm/README.md @@ -3,7 +3,7 @@ Confirm component for feedback. ## Support -browser weex miniApp wechatMiniprogram +browser weex miniApp wechatMiniprogram bytedanceMicroApp ## Install diff --git a/packages/confirm/docs-template/README-zh_CN.md b/packages/confirm/docs-template/README-zh_CN.md index 793b3a52..8db5a364 100644 --- a/packages/confirm/docs-template/README-zh_CN.md +++ b/packages/confirm/docs-template/README-zh_CN.md @@ -3,7 +3,7 @@ confirm 确认框 ## 支持 -__icon_web__ __icon_weex__ __icon_miniapp_mp__ __icon_miniapp_wx__ +__icon_web__ __icon_weex__ __icon_miniapp_mp__ __icon_miniapp_wx__ __icon_microapp_tt__ ## 安装 diff --git a/packages/confirm/docs-template/README.md b/packages/confirm/docs-template/README.md index 117fe210..a08e12d2 100644 --- a/packages/confirm/docs-template/README.md +++ b/packages/confirm/docs-template/README.md @@ -3,7 +3,7 @@ Confirm 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 diff --git a/packages/confirm/package.json b/packages/confirm/package.json index 89d00cc7..aac629b5 100644 --- a/packages/confirm/package.json +++ b/packages/confirm/package.json @@ -1,7 +1,7 @@ { "name": "universal-confirm", "author": "rax", - "version": "1.0.2", + "version": "1.1.0", "license": "BSD-3-Clause", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/packages/confirm/src/miniapp/ali/index.ts b/packages/confirm/src/ali-miniapp/index.ts similarity index 92% rename from packages/confirm/src/miniapp/ali/index.ts rename to packages/confirm/src/ali-miniapp/index.ts index 71ce9c9f..32301d71 100644 --- a/packages/confirm/src/miniapp/ali/index.ts +++ b/packages/confirm/src/ali-miniapp/index.ts @@ -1,4 +1,4 @@ -import { Options } from '../../types'; +import { Options } from '../types'; declare const my: any; diff --git a/packages/confirm/src/bytedance-microapp/index.ts b/packages/confirm/src/bytedance-microapp/index.ts new file mode 100644 index 00000000..de19deb0 --- /dev/null +++ b/packages/confirm/src/bytedance-microapp/index.ts @@ -0,0 +1,23 @@ +import { Options } from '../types'; + +declare const tt: any; + +const confirm = (options: Options): Promise => { + return new Promise((resolve, reject): void => { + const { title = '', content = '', confirmButtonText = '确定', cancelButtonText = '取消' } = options; + tt.showModal({ + title, + content, + confirmText: confirmButtonText, + cancelText: cancelButtonText, + success: ({ confirm }): void => { + confirm ? resolve(true) : resolve(false); + }, + fail: (): void => { + reject(); + } + }); + }); +}; + +export default confirm; diff --git a/packages/confirm/src/index.ts b/packages/confirm/src/index.ts index 39f797e6..646f9919 100644 --- a/packages/confirm/src/index.ts +++ b/packages/confirm/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 './ali-miniapp/index'; +import weChatModule from './wechat-miniprogram/index'; +import byteDanceModule from './bytedance-microapp/index'; let confirm: any = () => {}; @@ -18,5 +19,8 @@ if (isMiniApp) { if (isWeChatMiniProgram) { confirm = weChatModule; } +if (isByteDanceMicroApp) { + confirm = byteDanceModule; +} export default confirm; diff --git a/packages/confirm/src/miniapp/wechat/index.ts b/packages/confirm/src/wechat-miniprogram/index.ts similarity index 93% rename from packages/confirm/src/miniapp/wechat/index.ts rename to packages/confirm/src/wechat-miniprogram/index.ts index 72d4139a..6f6ff1bd 100644 --- a/packages/confirm/src/miniapp/wechat/index.ts +++ b/packages/confirm/src/wechat-miniprogram/index.ts @@ -1,4 +1,4 @@ -import { Options } from '../../types'; +import { Options } from '../types'; declare const wx: any;