Pārlūkot izejas kodu

🐛 fix(components): 修复头像选择器清除功能类型错误

- 将value类型从number改为number | null,支持空值状态
- 将onChange参数类型从number改为number | null,匹配空值场景
- 修复清除头像时传递0而非null的错误,确保类型一致性
yourname 4 mēneši atpakaļ
vecāks
revīzija
dc3bb8a974

+ 3 - 3
src/client/admin-shadcn/components/AvatarSelector.tsx

@@ -14,8 +14,8 @@ import type { InferResponseType } from 'hono/client';
 type FileType = InferResponseType<typeof fileClient.$get, 200>['data'][0]
 
 interface AvatarSelectorProps {
-  value?: number;
-  onChange: (fileId: number) => void;
+  value?: number | null;
+  onChange: (fileId: number | null) => void;
   accept?: string;
   maxSize?: number;
   uploadPath?: string;
@@ -122,7 +122,7 @@ const AvatarSelector: React.FC<AvatarSelectorProps> = ({
 
   const handleRemoveAvatar = (e: React.MouseEvent) => {
     e.stopPropagation();
-    onChange(0);
+    onChange(null as any);
   };
 
   return (