Skip to content

Commit

Permalink
feat(Alert): 添加 async 模式
Browse files Browse the repository at this point in the history
  • Loading branch information
shaodahong committed Jan 17, 2019
1 parent dd3a57b commit 26bf2ac
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
15 changes: 13 additions & 2 deletions docs/src/mobile/alert/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ class A extends React.Component {
return (
<Cell>
<Cell.Row
onClick={() => {
Alert('基本使用')
onClick={async () => {
await Alert('基本使用')
console.log(123)
}}
>
基本使用
Expand Down Expand Up @@ -72,6 +73,16 @@ class A extends React.Component {
>
confirm 模式
</Cell.Row>
<Cell.Row
onClick={async () => {
await Alert.async({
title: '异步模式',
desc: '我是一个描述'
})
}}
>
异步模式
</Cell.Row>
</Cell>
)
}
Expand Down
33 changes: 11 additions & 22 deletions packages/alert/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,35 +50,14 @@ class AlertCom extends React.Component<AlertProps, any> {
{name}
</Button>
)
// let composeClassName
// if (index === 0) {
// composeClassName = cn('x-alert__btn-y', className)
// } else if (index === 1) {
// composeClassName = cn('x-alert__btn-n', className)
// } else {
// composeClassName = cn('x-alert__btn-y', className)
// }
// return (
// <Report
// className={composeClassName}
// {...otherProps}
// onClick={e => {
// onClick && onClick(e)
// onClose && onClose(e)
// }}
// key={index}
// >
// {name}
// </Report>
// )
})}
</div>
</div>
)
}
}

export default function Alert(params: AlertProps, callback: Function) {
function Alert(params: AlertProps, callback: Function) {
let composeParams: AlertProps = params
if (typeof params === 'string') {
composeParams = {
Expand Down Expand Up @@ -128,3 +107,13 @@ export default function Alert(params: AlertProps, callback: Function) {
close
}
}

Alert.async = async (params: AlertProps) => {
return new Promise(resolve => {
Alert(params, () => {
resolve()
})
})
}

export default Alert

0 comments on commit 26bf2ac

Please sign in to comment.