From 6896a1f8af9417fd20cec4d0eef8170d51bcb0b3 Mon Sep 17 00:00:00 2001 From: CrescentLeaf Date: Sat, 13 Sep 2025 00:37:25 +0800 Subject: [PATCH] refactor: Avatar.jsx -> .tsx --- client/ui/Avatar.jsx | 15 --------------- client/ui/Avatar.tsx | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 15 deletions(-) delete mode 100644 client/ui/Avatar.jsx create mode 100644 client/ui/Avatar.tsx diff --git a/client/ui/Avatar.jsx b/client/ui/Avatar.jsx deleted file mode 100644 index 619410b..0000000 --- a/client/ui/Avatar.jsx +++ /dev/null @@ -1,15 +0,0 @@ -export default function Avatar({ src, text, icon = 'person', ...props } = {}) { - return ( - src ? - {'(头像)' - - : ( - text ? - { - text.substring(0, 0) - } - - : - ) - ) -} diff --git a/client/ui/Avatar.tsx b/client/ui/Avatar.tsx new file mode 100644 index 0000000..4bdbbb5 --- /dev/null +++ b/client/ui/Avatar.tsx @@ -0,0 +1,25 @@ +interface Args extends React.HTMLAttributes { + src?: string + text?: string + icon?: string + avatarRef?: React.LegacyRef +} + +export default function Avatar({ + src, + text, + icon = 'person', + avatarRef, + ...props +}: Args) { + if (src != null) + return + else if (text != null) + return + { + text.substring(0, 0) + } + + else + return +}