File tree Expand file tree Collapse file tree 3 files changed +15
-0
lines changed
packages/form/src/components Expand file tree Collapse file tree 3 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,9 @@ export type ProFormCaptchaProps = ProFormFieldItemProps<InputProps> & {
1515 /** @name 获取验证码的方法 */
1616 onGetCaptcha : ( mobile : string ) => Promise < void > ;
1717
18+ /** @name 计时回调 */
19+ onTiming ?: ( count : number ) => void ;
20+
1821 /** @name 渲染按钮的文字 */
1922 captchaTextRender ?: ( timing : boolean , count : number ) => React . ReactNode ;
2023
@@ -42,6 +45,7 @@ const BaseProFormCaptcha: React.FC<ProFormCaptchaProps> = React.forwardRef(
4245 name,
4346 phoneName,
4447 fieldProps,
48+ onTiming,
4549 captchaTextRender = ( paramsTiming , paramsCount ) => {
4650 return paramsTiming ? `${ paramsCount } 秒后重新获取` : '获取验证码' ;
4751 } ,
@@ -89,6 +93,13 @@ const BaseProFormCaptcha: React.FC<ProFormCaptchaProps> = React.forwardRef(
8993 return ( ) => clearInterval ( interval ) ;
9094 // eslint-disable-next-line react-hooks/exhaustive-deps
9195 } , [ timing ] ) ;
96+
97+ useEffect ( ( ) => {
98+ if ( onTiming ) {
99+ onTiming ( count ) ;
100+ }
101+ } , [ count , onTiming ] ) ;
102+
92103 return (
93104 < div
94105 style = { {
Original file line number Diff line number Diff line change @@ -58,6 +58,9 @@ export default () => {
5858 reject ( ) ;
5959 } ) ;
6060 } }
61+ onTiming = { ( count ) => {
62+ console . log ( 'timing:' , count ) ;
63+ } }
6164 fieldRef = { captchaRef }
6265 fieldProps = { { ref : inputRef } }
6366 name = "code"
Original file line number Diff line number Diff line change @@ -141,6 +141,7 @@ ProFormCaptcha 是为了支持中后台中常见的验证码功能开发的组
141141| 参数 | 说明 | 类型 | 默认值 |
142142| --- | --- | --- | --- |
143143| onGetCaptcha | 点击获取验证码的事件,如果配置了 phoneName 会自动注入 | ` (phone)=>Promise<any> ` | - |
144+ | onTiming | 计时数字监听 | ` (count: number)=>void ` | - |
144145| captchaProps | 获取验证码按钮的 props,与 antd 的 props 相同 | ` ButtonProps ` | - |
145146| countDown | 倒计时的秒数 | number | 60 |
146147| captchaTextRender | 渲染计时的文案 | ` (timing: boolean, count: number) => React.ReactNode ` | - |
You can’t perform that action at this time.
0 commit comments