From 2d9bc7f9d3b16cba75a383f52feb53fdcdfbf3e3 Mon Sep 17 00:00:00 2001 From: JakeQuc Date: Tue, 2 May 2023 09:31:18 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E9=87=8D=E6=9E=84=20useSendingBtn?= =?UTF-8?q?=20=E8=BF=94=E5=9B=9E=E7=9A=84=20type?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/about/changelog.md | 2 +- docs/demos/DetailPresentDemo2.tsx | 78 ++++++++++++++++--------------- docs/demos/UseSendingBtnDemo.tsx | 6 +-- package.json | 2 +- src/SendingBtn/index.tsx | 10 ++-- src/hooks/useSendingBtn.tsx | 4 +- 6 files changed, 53 insertions(+), 49 deletions(-) diff --git a/docs/about/changelog.md b/docs/about/changelog.md index 4679f47..db23f51 100644 --- a/docs/about/changelog.md +++ b/docs/about/changelog.md @@ -8,7 +8,7 @@ order: 2 > 说明: 在 1.8.5 之前该 package 均不是稳定版本,因此在 1.0.0 版本之前均可以无破坏性升级到 1.8.5 版本,如果后边有破坏性的改变该 更改日志将会使用文字说明,若无说明则无新特性或破坏性改变(会尽量避免破坏性的改变) -#### version 1.8.12 +#### version 1.8.12 / 1.8.13 - 修改部分 demo 和导出 重构部分类型 diff --git a/docs/demos/DetailPresentDemo2.tsx b/docs/demos/DetailPresentDemo2.tsx index e20f10e..6f3c9d3 100644 --- a/docs/demos/DetailPresentDemo2.tsx +++ b/docs/demos/DetailPresentDemo2.tsx @@ -1,4 +1,4 @@ -import { DetailPresent, Space, Switch } from 'art-antd-react'; +import { Card, DetailPresent, Space, Switch } from 'art-antd-react'; import { useState } from 'react'; const Demo1 = () => { @@ -32,44 +32,46 @@ const Demo1 = () => { }; return ( - - setFilterNil(v)} - /> - - title="谋圣信息" - filterNil={filterNil} - detail={{ - ...responseData, - friend: responseData.friend.user, - hobby: responseData.hobby.join('、'), + + + setFilterNil(v)} + /> + + title="谋圣信息" + filterNil={filterNil} + detail={{ + ...responseData, + friend: responseData.friend.user, + hobby: responseData.hobby.join('、'), - sketch: ( - - {responseData.sketch} - - ), - }} - // 值为空的时候的占位符 - placeholder="-" - keyMapLabel={keyMapLabel} - // 自定义每一项单独的配置 - keyMapItemProps={{ - sketch: { - labelStyle: { color: '#f00' }, - // 独占3列 - span: 3, - }, - }} - /> - + sketch: ( + + {responseData.sketch} + + ), + }} + // 值为空的时候的占位符 + placeholder="-" + keyMapLabel={keyMapLabel} + // 自定义每一项单独的配置 + keyMapItemProps={{ + sketch: { + labelStyle: { color: '#f00' }, + // 独占3列 + span: 3, + }, + }} + /> + + ); }; diff --git a/docs/demos/UseSendingBtnDemo.tsx b/docs/demos/UseSendingBtnDemo.tsx index 0907344..d7bd119 100644 --- a/docs/demos/UseSendingBtnDemo.tsx +++ b/docs/demos/UseSendingBtnDemo.tsx @@ -3,10 +3,10 @@ import { message, useSendingBtn } from 'art-antd-react'; import { useState } from 'react'; const UseSendingBtnDemo = () => { - const [loadig, setLoading] = useState(false); + const [loading, setLoading] = useState(false); const { SendingBtn, runCounter } = useSendingBtn({ - loadig, + loading, onClick: sendCaptcha, totalDisableTime: 23, immediate: false, @@ -17,7 +17,7 @@ const UseSendingBtnDemo = () => { function sendCaptcha() { setLoading(true); setTimeout(() => { - runCounter(); + runCounter?.(); message.success(`发送的验证码为: ${Math.round(Math.random() * 10000)}`); setLoading(false); }, 3000); diff --git a/package.json b/package.json index 50970cf..52d989a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "art-antd-react", - "version": "1.8.12", + "version": "1.8.13", "private": false, "description": "A library of components to help you develop web pages quickly", "homepage": "https://oneqorg.github.io/art-antd-react/", diff --git a/src/SendingBtn/index.tsx b/src/SendingBtn/index.tsx index 561a185..a5d9c19 100644 --- a/src/SendingBtn/index.tsx +++ b/src/SendingBtn/index.tsx @@ -28,11 +28,11 @@ export interface SendingBtnProps extends ButtonProps { } export interface SendingBtnRefProps { - isCounter: boolean; - remainderTime: number; - runCounter: () => void; - setRemainderTime: (time: number) => void; - setIsCounter: (counter: boolean) => void; + isCounter?: boolean; + remainderTime?: number; + runCounter?: () => void; + setRemainderTime?: (time: number) => void; + setIsCounter?: (counter: boolean) => void; } // 1s 等于 1000 ms diff --git a/src/hooks/useSendingBtn.tsx b/src/hooks/useSendingBtn.tsx index a40614c..eaa7c39 100644 --- a/src/hooks/useSendingBtn.tsx +++ b/src/hooks/useSendingBtn.tsx @@ -1,7 +1,9 @@ import { useRef } from 'react'; import { SendingBtn, SendingBtnProps, SendingBtnRefProps } from '../SendingBtn'; -export const useSendingBtn = (config: SendingBtnProps) => { +export const useSendingBtn = ( + config: SendingBtnProps, +): SendingBtnRefProps & { SendingBtn: React.ReactNode } => { const ref = useRef(); return { -- Gitee