Skip to content

Commit

Permalink
feat: 不管异步成功失败都执行代码
Browse files Browse the repository at this point in the history
  • Loading branch information
crazyair committed Mar 27, 2024
1 parent c061f18 commit 0bc4e47
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions components/typography/Base/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,20 +203,19 @@ const Base = React.forwardRef<HTMLElement, BlockProps>((props, ref) => {
const text =
typeof copyConfig.text === 'function' ? await copyConfig.text() : copyConfig.text;
copy(text || String(children) || '', copyOptions);
setCopyLoading(false);

setCopied(true);

// Trigger tips update
cleanCopyId();
copyIdRef.current = setTimeout(() => {
setCopied(false);
}, 3000);

copyConfig.onCopy?.(e);
} catch (error) {
setCopyLoading(false);
/* empty */
}
setCopyLoading(false);
setCopied(true);

// Trigger tips update
cleanCopyId();
copyIdRef.current = setTimeout(() => {
setCopied(false);
}, 3000);

copyConfig.onCopy?.(e);
};

React.useEffect(() => cleanCopyId, []);
Expand Down

0 comments on commit 0bc4e47

Please sign in to comment.