feat: 更新图片展示逻辑,增加获取数量并使用ImageGrid组件优化图片展示

This commit is contained in:
shiyu
2025-06-22 17:24:50 +08:00
parent 49c84658b5
commit ec2ff921f9
+21 -65
View File
@@ -1,7 +1,7 @@
import React, { useState, useEffect, useCallback } from 'react'; import React, { useState, useEffect, useCallback } from 'react';
import { import {
Card, Button, Space, Modal, message, Typography, Card, Button, Space, Modal, message, Typography,
Row, Col, Image, Form, Input, Avatar, Row, Col, Form, Input, Avatar,
Tag, Tooltip, Spin, Empty, Statistic, Tag, Tooltip, Spin, Empty, Statistic,
Select, Grid Select, Grid
} from 'antd'; } from 'antd';
@@ -17,6 +17,7 @@ import {
type FaceClusterResponse, type UpdateClusterRequest type FaceClusterResponse, type UpdateClusterRequest
} from '../../api'; } from '../../api';
import type { PictureResponse } from '../../api/pictureApi'; import type { PictureResponse } from '../../api/pictureApi';
import ImageGrid from '../../components/image/ImageGrid/ImageGrid';
const { Title, Text, Paragraph } = Typography; const { Title, Text, Paragraph } = Typography;
const { confirm } = Modal; const { confirm } = Modal;
@@ -69,7 +70,7 @@ const FaceExplore: React.FC = () => {
const fetchClusterPictures = useCallback(async (clusterId: number) => { const fetchClusterPictures = useCallback(async (clusterId: number) => {
setPicturesLoading(true); setPicturesLoading(true);
try { try {
const response = await getMyPicturesByCluster(clusterId, 1, 50); const response = await getMyPicturesByCluster(clusterId, 1, 100); // 增加获取数量
if (response.success) { if (response.success) {
const actualData = response.data?.data || response.data; const actualData = response.data?.data || response.data;
setClusterPictures(Array.isArray(actualData) ? actualData : []); setClusterPictures(Array.isArray(actualData) ? actualData : []);
@@ -443,72 +444,27 @@ const FaceExplore: React.FC = () => {
open={isPictureModalVisible} open={isPictureModalVisible}
onCancel={() => setIsPictureModalVisible(false)} onCancel={() => setIsPictureModalVisible(false)}
footer={null} footer={null}
width={800} width="90vw"
style={{ maxWidth: 1200 }}
destroyOnClose destroyOnClose
> >
<Spin spinning={picturesLoading}> <div style={{
{clusterPictures.length > 0 ? ( maxHeight: '70vh',
<div style={{ overflowY: 'auto',
display: 'grid', padding: '16px 0'
gridTemplateColumns: 'repeat(auto-fill, minmax(120px, 1fr))', }}>
gap: 16, <ImageGrid
maxHeight: 500, dataSource={clusterPictures}
overflowY: 'auto', loading={picturesLoading}
padding: '8px' emptyText="该聚类中暂无图片"
}}> showPagination={false}
{clusterPictures.map(picture => ( pageSize={50}
<div key={picture.id} style={{ textAlign: 'center' }}> selectable={false}
<Avatar queryParams={{}}
size={100} />
src={picture.thumbnailPath || picture.path} </div>
style={{
border: '2px solid #f0f0f0',
cursor: 'pointer',
transition: 'all 0.3s ease',
marginBottom: 8
}}
/>
<div style={{
fontSize: '11px',
color: '#666',
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
maxWidth: '120px'
}}>
{picture.name || `图片${picture.id}`}
</div>
<div style={{ marginTop: 4 }}>
<Image
width={0}
height={0}
src={picture.path}
style={{ display: 'none' }}
preview={{
src: picture.path,
mask: (
<div style={{
fontSize: '10px',
color: '#fff',
background: 'rgba(0,0,0,0.6)',
padding: '2px 6px',
borderRadius: 4,
cursor: 'pointer'
}}>
</div>
)
}}
/>
</div>
</div>
))}
</div>
) : (
<Empty description="暂无图片" />
)}
</Spin>
</Modal> </Modal>
</div> </div>
); );
}; };