|
@@ -193,30 +193,13 @@ const AvatarSelector: React.FC<AvatarSelectorProps> = ({
|
|
|
<DialogHeader>
|
|
<DialogHeader>
|
|
|
<DialogTitle>选择头像</DialogTitle>
|
|
<DialogTitle>选择头像</DialogTitle>
|
|
|
<DialogDescription>
|
|
<DialogDescription>
|
|
|
- 从已有头像中选择,或上传新头像
|
|
|
|
|
|
|
+ 上传新头像或从已有头像中选择
|
|
|
</DialogDescription>
|
|
</DialogDescription>
|
|
|
</DialogHeader>
|
|
</DialogHeader>
|
|
|
|
|
|
|
|
<div className="space-y-4">
|
|
<div className="space-y-4">
|
|
|
- {/* 上传区域 */}
|
|
|
|
|
- <Card>
|
|
|
|
|
- <CardContent className="pt-6">
|
|
|
|
|
- <MinioUploader
|
|
|
|
|
- uploadPath={uploadPath}
|
|
|
|
|
- accept={accept}
|
|
|
|
|
- maxSize={maxSize}
|
|
|
|
|
- onUploadSuccess={handleUploadSuccess}
|
|
|
|
|
- buttonText={uploadButtonText}
|
|
|
|
|
- size="minimal"
|
|
|
|
|
- />
|
|
|
|
|
- <p className="text-sm text-gray-500 mt-2">
|
|
|
|
|
- 上传后请从下方列表中选择新上传的头像
|
|
|
|
|
- </p>
|
|
|
|
|
- </CardContent>
|
|
|
|
|
- </Card>
|
|
|
|
|
-
|
|
|
|
|
{/* 头像列表 */}
|
|
{/* 头像列表 */}
|
|
|
- <div className="space-y-2 max-h-96 overflow-y-auto">
|
|
|
|
|
|
|
+ <div className="space-y-2 max-h-96 overflow-y-auto p-1">
|
|
|
{isLoading ? (
|
|
{isLoading ? (
|
|
|
<Card>
|
|
<Card>
|
|
|
<CardContent className="text-center py-8">
|
|
<CardContent className="text-center py-8">
|
|
@@ -224,8 +207,30 @@ const AvatarSelector: React.FC<AvatarSelectorProps> = ({
|
|
|
<p className="text-gray-500 mt-2">加载中...</p>
|
|
<p className="text-gray-500 mt-2">加载中...</p>
|
|
|
</CardContent>
|
|
</CardContent>
|
|
|
</Card>
|
|
</Card>
|
|
|
- ) : avatars.length > 0 ? (
|
|
|
|
|
|
|
+ ) : (
|
|
|
<div className="grid grid-cols-4 gap-3">
|
|
<div className="grid grid-cols-4 gap-3">
|
|
|
|
|
+ {/* 上传区域 - 作为第一项 */}
|
|
|
|
|
+ <div className="relative cursor-pointer transition-all duration-200">
|
|
|
|
|
+ <div className="rounded-lg border-2 border-dashed border-gray-300 hover:border-primary transition-colors hover:scale-105">
|
|
|
|
|
+ <div className="p-2 h-24 flex items-center justify-center">
|
|
|
|
|
+ <MinioUploader
|
|
|
|
|
+ uploadPath={uploadPath}
|
|
|
|
|
+ accept={accept}
|
|
|
|
|
+ maxSize={maxSize}
|
|
|
|
|
+ onUploadSuccess={handleUploadSuccess}
|
|
|
|
|
+ buttonText="上传"
|
|
|
|
|
+ size="minimal"
|
|
|
|
|
+ displayMode="card"
|
|
|
|
|
+ showUploadList={false}
|
|
|
|
|
+ />
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <p className="text-xs text-center mt-1 text-muted-foreground">
|
|
|
|
|
+ 上传新头像
|
|
|
|
|
+ </p>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ {/* 现有头像列表 */}
|
|
|
{avatars.map((file) => (
|
|
{avatars.map((file) => (
|
|
|
<div
|
|
<div
|
|
|
key={file.id}
|
|
key={file.id}
|
|
@@ -256,7 +261,7 @@ const AvatarSelector: React.FC<AvatarSelectorProps> = ({
|
|
|
)}
|
|
)}
|
|
|
|
|
|
|
|
<div className="absolute top-1 right-1">
|
|
<div className="absolute top-1 right-1">
|
|
|
- <Eye
|
|
|
|
|
|
|
+ <Eye
|
|
|
className="h-4 w-4 text-white bg-black/50 rounded-full p-0.5 cursor-pointer hover:bg-black/70"
|
|
className="h-4 w-4 text-white bg-black/50 rounded-full p-0.5 cursor-pointer hover:bg-black/70"
|
|
|
onClick={(e) => {
|
|
onClick={(e) => {
|
|
|
e.stopPropagation();
|
|
e.stopPropagation();
|
|
@@ -271,17 +276,22 @@ const AvatarSelector: React.FC<AvatarSelectorProps> = ({
|
|
|
</p>
|
|
</p>
|
|
|
</div>
|
|
</div>
|
|
|
))}
|
|
))}
|
|
|
- </div>
|
|
|
|
|
- ) : (
|
|
|
|
|
- <Card>
|
|
|
|
|
- <CardContent className="text-center py-8">
|
|
|
|
|
- <div className="flex flex-col items-center">
|
|
|
|
|
- <Upload className="h-12 w-12 text-gray-400 mb-4" />
|
|
|
|
|
- <p className="text-gray-600">暂无符合条件的头像</p>
|
|
|
|
|
- <p className="text-sm text-gray-500 mt-2">请先上传头像文件</p>
|
|
|
|
|
|
|
+
|
|
|
|
|
+ {/* 空状态 - 当没有头像时显示 */}
|
|
|
|
|
+ {avatars.length === 0 && (
|
|
|
|
|
+ <div className="col-span-3">
|
|
|
|
|
+ <Card>
|
|
|
|
|
+ <CardContent className="text-center py-8">
|
|
|
|
|
+ <div className="flex flex-col items-center">
|
|
|
|
|
+ <Upload className="h-12 w-12 text-gray-400 mb-4" />
|
|
|
|
|
+ <p className="text-gray-600">暂无头像</p>
|
|
|
|
|
+ <p className="text-sm text-gray-500 mt-2">请上传头像文件</p>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </CardContent>
|
|
|
|
|
+ </Card>
|
|
|
</div>
|
|
</div>
|
|
|
- </CardContent>
|
|
|
|
|
- </Card>
|
|
|
|
|
|
|
+ )}
|
|
|
|
|
+ </div>
|
|
|
)}
|
|
)}
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|