|
|
@ -2,23 +2,27 @@ import { Button, ButtonProps } from 'antd' |
|
|
|
import { useStyle } from './style' |
|
|
|
|
|
|
|
export interface ActionProps extends ButtonProps { |
|
|
|
as?: string |
|
|
|
as?: string |
|
|
|
} |
|
|
|
|
|
|
|
const Action = ({ title, as, children, ...props }: ActionProps) => { |
|
|
|
|
|
|
|
const { styles } = useStyle() |
|
|
|
const { styles } = useStyle() |
|
|
|
|
|
|
|
const isLink = as === 'a' || props.type === 'link' |
|
|
|
//fixme 如果外部同时设置 as={'a'} disabled={true} ,这里a标签会置灰,但是仍可点击,为什么不直接用Button?
|
|
|
|
const Comp = isLink ? 'a' : Button |
|
|
|
return ( |
|
|
|
<span className={styles.container}> |
|
|
|
const isLink = as === 'a' || props.type === 'link' |
|
|
|
const Comp = isLink ? 'a' : Button |
|
|
|
return ( |
|
|
|
<span className={styles.container}> |
|
|
|
<Comp {...props} |
|
|
|
type={isLink ? 'link' : props.type} |
|
|
|
className={as === 'a' ? styles.actionA : ''}>{title ?? children}</Comp> |
|
|
|
onClick={(e) => { |
|
|
|
if (props.onClick && !props.disabled) { |
|
|
|
props.onClick(e) |
|
|
|
} |
|
|
|
}} |
|
|
|
type={isLink ? 'link' : props.type} |
|
|
|
className={as === 'a' ? styles.actionA : ''}>{title ?? children}</Comp> |
|
|
|
</span> |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
|
|
|
|
export default Action |