From 6e9449d0f300789017a95117554a6f961264170d Mon Sep 17 00:00:00 2001 From: Leo <98382335+gaoziman@users.noreply.github.com> Date: Sun, 19 Oct 2025 21:49:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E6=89=80=E6=9C=89=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E9=A1=B5=E9=9D=A2=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Dashboard 仪表盘:数据统计卡片、存储使用情况、快速操作 - Upload 上传页面:拖拽上传、批量上传、上传进度 - Gallery 图片库:瀑布流布局、筛选排序、批量操作 - Links 链接管理:链接列表、搜索筛选 - Tools 图片工具:压缩、裁剪、格式转换 - Storage 存储配置:OSS配置管理 - Analytics 统计分析:图表展示、数据分析 - Settings 设置页面:个人设置、系统配置 --- src/pages/Analytics/index.tsx | 63 +++ src/pages/Dashboard/index.tsx | 335 +++++++++++++++ src/pages/Gallery/index.tsx | 754 ++++++++++++++++++++++++++++++++++ src/pages/Links/index.tsx | 71 ++++ src/pages/Settings/index.tsx | 67 +++ src/pages/Storage/index.tsx | 74 ++++ src/pages/Tools/index.tsx | 73 ++++ src/pages/Upload/index.tsx | 120 ++++++ 8 files changed, 1557 insertions(+) create mode 100644 src/pages/Analytics/index.tsx create mode 100644 src/pages/Dashboard/index.tsx create mode 100644 src/pages/Gallery/index.tsx create mode 100644 src/pages/Links/index.tsx create mode 100644 src/pages/Settings/index.tsx create mode 100644 src/pages/Storage/index.tsx create mode 100644 src/pages/Tools/index.tsx create mode 100644 src/pages/Upload/index.tsx diff --git a/src/pages/Analytics/index.tsx b/src/pages/Analytics/index.tsx new file mode 100644 index 0000000..32ebee2 --- /dev/null +++ b/src/pages/Analytics/index.tsx @@ -0,0 +1,63 @@ +import React from 'react'; +import { Card, Row, Col, Statistic } from 'antd'; +import { ArrowUpOutlined, ArrowDownOutlined } from '@ant-design/icons'; +import { FUNCTIONAL_COLORS, PRIMARY_COLORS } from '../../theme/colors'; + +export const Analytics: React.FC = () => { + return ( +
+

统计分析

+ + + + + } + valueStyle={{ color: FUNCTIONAL_COLORS.SUCCESS }} + /> + + + + + } + valueStyle={{ color: PRIMARY_COLORS.PRIMARY }} + /> + + + + + + + + + + + + + + + +

+ 图表功能正在开发中... +

+
+
+ ); +}; diff --git a/src/pages/Dashboard/index.tsx b/src/pages/Dashboard/index.tsx new file mode 100644 index 0000000..5027b4c --- /dev/null +++ b/src/pages/Dashboard/index.tsx @@ -0,0 +1,335 @@ +import React from 'react'; +import { Card, Row, Col, Progress, Space } from 'antd'; +import { + CloudUploadOutlined, + FileImageOutlined, + DatabaseOutlined, + ArrowUpOutlined, +} from '@ant-design/icons'; +import { useStorageStore } from '../../stores/useStorageStore'; +import { PRIMARY_COLORS, FUNCTIONAL_COLORS, ACCENT_COLORS } from '../../theme/colors'; + +export const Dashboard: React.FC = () => { + const { storageStats } = useStorageStore(); + + const usedPercentage = storageStats + ? Math.round((storageStats.usedSpace / storageStats.totalSpace) * 100) + : 0; + + const formatBytes = (bytes: number) => { + if (bytes === 0) return '0 B'; + const k = 1024; + const sizes = ['B', 'KB', 'MB', 'GB', 'TB']; + const i = Math.floor(Math.log(bytes) / Math.log(k)); + return Math.round(bytes / Math.pow(k, i) * 100) / 100 + ' ' + sizes[i]; + }; + + // 统计卡片组件 - 全新极简设计 + const StatCard: React.FC<{ + title: string; + value: string | number; + icon: React.ReactNode; + bgGradient: string; + suffix?: string; + }> = ({ title, value, icon, bgGradient, suffix }) => ( +
{ + e.currentTarget.style.transform = 'translateY(-8px)'; + e.currentTarget.style.boxShadow = '0 20px 40px rgba(0, 0, 0, 0.12)'; + }} + onMouseLeave={(e) => { + e.currentTarget.style.transform = 'translateY(0)'; + e.currentTarget.style.boxShadow = 'none'; + }} + > + {/* 图标 */} +
+ {icon} +
+ + {/* 标题 */} +
+ {title} +
+ + {/* 数值 */} +
+ {value} + {suffix && ( + + {suffix} + + )} +
+
+ ); + + return ( +
+

仪表盘

+ + {/* 统计卡片 - 全新无边框渐变设计 */} + + + } + bgGradient="linear-gradient(135deg, #667eea 0%, #764ba2 100%)" + /> + + + } + bgGradient="linear-gradient(135deg, #10B981 0%, #059669 100%)" + /> + + + } + bgGradient="linear-gradient(135deg, #8B5CF6 0%, #6D28D9 100%)" + /> + + + } + bgGradient="linear-gradient(135deg, #EC4899 0%, #DB2777 100%)" + /> + + + + {/* 存储使用情况 */} + + + + 存储空间使用情况 + + } + className="hover-card" + bordered={false} + style={{ + borderRadius: 16, + boxShadow: '0 1px 3px rgba(0, 0, 0, 0.08)', + }} + > + +
+
+ + 已使用 {formatBytes(storageStats?.usedSpace || 0)} + + + 总计 {formatBytes(storageStats?.totalSpace || 0)} + +
+ +
+
+ 剩余空间:{formatBytes((storageStats?.totalSpace || 0) - (storageStats?.usedSpace || 0))} +
+
+
+ + + + + + { + e.currentTarget.style.transform = 'translateX(4px)'; + e.currentTarget.style.boxShadow = `0 4px 12px ${PRIMARY_COLORS.PRIMARY}20`; + }} + onMouseLeave={(e) => { + e.currentTarget.style.transform = 'translateX(0)'; + e.currentTarget.style.boxShadow = 'none'; + }} + > +
+ +
+ 上传新图片 +
+ { + e.currentTarget.style.transform = 'translateX(4px)'; + e.currentTarget.style.boxShadow = `0 4px 12px ${PRIMARY_COLORS.PRIMARY}20`; + }} + onMouseLeave={(e) => { + e.currentTarget.style.transform = 'translateX(0)'; + e.currentTarget.style.boxShadow = 'none'; + }} + > +
+ +
+ 浏览图片库 +
+ { + e.currentTarget.style.transform = 'translateX(4px)'; + e.currentTarget.style.boxShadow = `0 4px 12px ${PRIMARY_COLORS.PRIMARY}20`; + }} + onMouseLeave={(e) => { + e.currentTarget.style.transform = 'translateX(0)'; + e.currentTarget.style.boxShadow = 'none'; + }} + > +
+ +
+ 配置存储源 +
+
+
+ +
+
+ ); +}; diff --git a/src/pages/Gallery/index.tsx b/src/pages/Gallery/index.tsx new file mode 100644 index 0000000..2202fb5 --- /dev/null +++ b/src/pages/Gallery/index.tsx @@ -0,0 +1,754 @@ +import React, { useEffect } from 'react'; +import { Card, Empty, Space, Input, Select, Button, Checkbox, Tag, Tooltip } from 'antd'; +import { + SearchOutlined, + HeartOutlined, + HeartFilled, + DownloadOutlined, + DeleteOutlined, + EyeOutlined, +} from '@ant-design/icons'; +import Masonry from 'react-masonry-css'; +import { useGalleryStore } from '../../stores/useGalleryStore'; +import type { ImageItem } from '../../types'; + +// 模拟图片数据 - 使用不同尺寸的图片实现瀑布流效果 +const mockImages: ImageItem[] = [ + { + id: '1', + url: 'https://images.pexels.com/photos/1287145/pexels-photo-1287145.jpeg', + thumbnail: 'https://images.pexels.com/photos/1287145/pexels-photo-1287145.jpeg?auto=compress&cs=tinysrgb&w=400', + filename: 'landscape-sunset.jpg', + size: 2548000, + width: 1920, + height: 1080, // 16:9 横图 + format: 'jpg', + uploadedAt: new Date('2025-01-15'), + tags: ['风景', '日落'], + isFavorite: true, + storageSource: 'MinIO', + }, + { + id: '2', + url: 'https://images.pexels.com/photos/1366630/pexels-photo-1366630.jpeg', + thumbnail: 'https://images.pexels.com/photos/1366630/pexels-photo-1366630.jpeg?auto=compress&cs=tinysrgb&w=400', + filename: 'mountain-view.jpg', + size: 3120000, + width: 1080, + height: 1620, // 2:3 竖图 + format: 'jpg', + uploadedAt: new Date('2025-01-14'), + tags: ['山', '自然'], + isFavorite: false, + storageSource: 'MinIO', + }, + { + id: '3', + url: 'https://images.pexels.com/photos/1660995/pexels-photo-1660995.jpeg', + thumbnail: 'https://images.pexels.com/photos/1660995/pexels-photo-1660995.jpeg?auto=compress&cs=tinysrgb&w=400', + filename: 'ocean-waves.jpg', + size: 1890000, + width: 1200, + height: 1200, // 1:1 正方形 + format: 'jpg', + uploadedAt: new Date('2025-01-13'), + tags: ['海洋', '波浪'], + isFavorite: true, + storageSource: 'MinIO', + }, + { + id: '4', + url: 'https://images.pexels.com/photos/1179229/pexels-photo-1179229.jpeg', + thumbnail: 'https://images.pexels.com/photos/1179229/pexels-photo-1179229.jpeg?auto=compress&cs=tinysrgb&w=400', + filename: 'forest-path.jpg', + size: 2234000, + width: 1920, + height: 1080, + format: 'jpg', + uploadedAt: new Date('2025-01-12'), + tags: ['森林', '小径'], + isFavorite: false, + storageSource: 'MinIO', + }, + { + id: '5', + url: 'https://images.pexels.com/photos/1519088/pexels-photo-1519088.jpeg', + thumbnail: 'https://images.pexels.com/photos/1519088/pexels-photo-1519088.jpeg?auto=compress&cs=tinysrgb&w=400', + filename: 'city-skyline.jpg', + size: 2890000, + width: 2048, + height: 1365, + format: 'jpg', + uploadedAt: new Date('2025-01-11'), + tags: ['城市', '天际线'], + isFavorite: false, + storageSource: 'MinIO', + }, + { + id: '6', + url: 'https://images.pexels.com/photos/2387418/pexels-photo-2387418.jpeg', + thumbnail: 'https://images.pexels.com/photos/2387418/pexels-photo-2387418.jpeg?auto=compress&cs=tinysrgb&w=400', + filename: 'desert-dunes.jpg', + size: 2156000, + width: 1920, + height: 1280, + format: 'jpg', + uploadedAt: new Date('2025-01-10'), + tags: ['沙漠', '沙丘'], + isFavorite: true, + storageSource: 'MinIO', + }, + { + id: '7', + url: 'https://images.pexels.com/photos/1563356/pexels-photo-1563356.jpeg', + thumbnail: 'https://images.pexels.com/photos/1563356/pexels-photo-1563356.jpeg?auto=compress&cs=tinysrgb&w=400', + filename: 'aurora-night.jpg', + size: 2980000, + width: 1920, + height: 1280, + format: 'jpg', + uploadedAt: new Date('2025-01-09'), + tags: ['极光', '夜景'], + isFavorite: true, + storageSource: 'MinIO', + }, + { + id: '8', + url: 'https://images.pexels.com/photos/1108099/pexels-photo-1108099.jpeg', + thumbnail: 'https://images.pexels.com/photos/1108099/pexels-photo-1108099.jpeg?auto=compress&cs=tinysrgb&w=400', + filename: 'beach-sunset.jpg', + size: 2145000, + width: 1920, + height: 1080, + format: 'jpg', + uploadedAt: new Date('2025-01-08'), + tags: ['海滩', '日落'], + isFavorite: false, + storageSource: 'MinIO', + }, + { + id: '9', + url: 'https://images.pexels.com/photos/1643457/pexels-photo-1643457.jpeg', + thumbnail: 'https://images.pexels.com/photos/1643457/pexels-photo-1643457.jpeg?auto=compress&cs=tinysrgb&w=400', + filename: 'waterfall.jpg', + size: 3250000, + width: 2048, + height: 1365, + format: 'jpg', + uploadedAt: new Date('2025-01-07'), + tags: ['瀑布', '自然'], + isFavorite: false, + storageSource: 'MinIO', + }, + { + id: '10', + url: 'https://images.pexels.com/photos/1574844/pexels-photo-1574844.jpeg', + thumbnail: 'https://images.pexels.com/photos/1574844/pexels-photo-1574844.jpeg?auto=compress&cs=tinysrgb&w=400', + filename: 'starry-sky.jpg', + size: 2678000, + width: 1920, + height: 1280, + format: 'jpg', + uploadedAt: new Date('2025-01-06'), + tags: ['星空', '夜晚'], + isFavorite: true, + storageSource: 'MinIO', + }, + { + id: '11', + url: 'https://images.pexels.com/photos/1450353/pexels-photo-1450353.jpeg', + thumbnail: 'https://images.pexels.com/photos/1450353/pexels-photo-1450353.jpeg?auto=compress&cs=tinysrgb&w=400', + filename: 'autumn-forest.jpg', + size: 2234000, + width: 1920, + height: 1080, + format: 'jpg', + uploadedAt: new Date('2025-01-05'), + tags: ['秋天', '森林'], + isFavorite: false, + storageSource: 'MinIO', + }, + { + id: '12', + url: 'https://images.pexels.com/photos/2559941/pexels-photo-2559941.jpeg', + thumbnail: 'https://images.pexels.com/photos/2559941/pexels-photo-2559941.jpeg?auto=compress&cs=tinysrgb&w=400', + filename: 'mountain-lake.jpg', + size: 2890000, + width: 1920, + height: 1280, + format: 'jpg', + uploadedAt: new Date('2025-01-04'), + tags: ['湖泊', '山'], + isFavorite: true, + storageSource: 'MinIO', + }, + { + id: '13', + url: 'https://images.pexels.com/photos/1671324/pexels-photo-1671324.jpeg', + thumbnail: 'https://images.pexels.com/photos/1671324/pexels-photo-1671324.jpeg?auto=compress&cs=tinysrgb&w=400', + filename: 'tropical-beach.jpg', + size: 2456000, + width: 1920, + height: 1080, + format: 'jpg', + uploadedAt: new Date('2025-01-03'), + tags: ['热带', '海滩'], + isFavorite: false, + storageSource: 'MinIO', + }, + { + id: '14', + url: 'https://images.pexels.com/photos/1252869/pexels-photo-1252869.jpeg', + thumbnail: 'https://images.pexels.com/photos/1252869/pexels-photo-1252869.jpeg?auto=compress&cs=tinysrgb&w=400', + filename: 'misty-mountain.jpg', + size: 2123000, + width: 1920, + height: 1280, + format: 'jpg', + uploadedAt: new Date('2025-01-02'), + tags: ['雾', '山'], + isFavorite: false, + storageSource: 'MinIO', + }, + { + id: '15', + url: 'https://images.pexels.com/photos/1770809/pexels-photo-1770809.jpeg', + thumbnail: 'https://images.pexels.com/photos/1770809/pexels-photo-1770809.jpeg?auto=compress&cs=tinysrgb&w=400', + filename: 'cherry-blossom.jpg', + size: 2345000, + width: 2048, + height: 1365, + format: 'jpg', + uploadedAt: new Date('2025-01-01'), + tags: ['樱花', '春天'], + isFavorite: true, + storageSource: 'MinIO', + }, + { + id: '16', + url: 'https://images.pexels.com/photos/1166209/pexels-photo-1166209.jpeg', + thumbnail: 'https://images.pexels.com/photos/1166209/pexels-photo-1166209.jpeg?auto=compress&cs=tinysrgb&w=400', + filename: 'canyon-view.jpg', + size: 2987000, + width: 1920, + height: 1080, + format: 'jpg', + uploadedAt: new Date('2024-12-31'), + tags: ['峡谷', '风景'], + isFavorite: false, + storageSource: 'MinIO', + }, + { + id: '17', + url: 'https://images.pexels.com/photos/1619317/pexels-photo-1619317.jpeg', + thumbnail: 'https://images.pexels.com/photos/1619317/pexels-photo-1619317.jpeg?auto=compress&cs=tinysrgb&w=400', + filename: 'snowy-peak.jpg', + size: 2678000, + width: 1920, + height: 1280, + format: 'jpg', + uploadedAt: new Date('2024-12-30'), + tags: ['雪山', '冬天'], + isFavorite: true, + storageSource: 'MinIO', + }, + { + id: '18', + url: 'https://images.pexels.com/photos/1624438/pexels-photo-1624438.jpeg', + thumbnail: 'https://images.pexels.com/photos/1624438/pexels-photo-1624438.jpeg?auto=compress&cs=tinysrgb&w=400', + filename: 'lavender-field.jpg', + size: 2234000, + width: 2048, + height: 1365, + format: 'jpg', + uploadedAt: new Date('2024-12-29'), + tags: ['薰衣草', '花田'], + isFavorite: false, + storageSource: 'MinIO', + }, + { + id: '19', + url: 'https://images.pexels.com/photos/1454360/pexels-photo-1454360.jpeg', + thumbnail: 'https://images.pexels.com/photos/1454360/pexels-photo-1454360.jpeg?auto=compress&cs=tinysrgb&w=400', + filename: 'river-valley.jpg', + size: 2456000, + width: 1920, + height: 1080, + format: 'jpg', + uploadedAt: new Date('2024-12-28'), + tags: ['河流', '山谷'], + isFavorite: false, + storageSource: 'MinIO', + }, + { + id: '20', + url: 'https://images.pexels.com/photos/1434819/pexels-photo-1434819.jpeg', + thumbnail: 'https://images.pexels.com/photos/1434819/pexels-photo-1434819.jpeg?auto=compress&cs=tinysrgb&w=400', + filename: 'northern-lights.jpg', + size: 2890000, + width: 1920, + height: 1280, + format: 'jpg', + uploadedAt: new Date('2024-12-27'), + tags: ['极光', '北欧'], + isFavorite: true, + storageSource: 'MinIO', + }, + { + id: '21', + url: 'https://images.pexels.com/photos/1591373/pexels-photo-1591373.jpeg', + thumbnail: 'https://images.pexels.com/photos/1591373/pexels-photo-1591373.jpeg?auto=compress&cs=tinysrgb&w=400', + filename: 'sunrise-clouds.jpg', + size: 2123000, + width: 1920, + height: 1080, + format: 'jpg', + uploadedAt: new Date('2024-12-26'), + tags: ['日出', '云'], + isFavorite: false, + storageSource: 'MinIO', + }, + { + id: '22', + url: 'https://images.pexels.com/photos/1477430/pexels-photo-1477430.jpeg', + thumbnail: 'https://images.pexels.com/photos/1477430/pexels-photo-1477430.jpeg?auto=compress&cs=tinysrgb&w=400', + filename: 'tropical-island.jpg', + size: 2678000, + width: 2048, + height: 1365, + format: 'jpg', + uploadedAt: new Date('2024-12-25'), + tags: ['海岛', '热带'], + isFavorite: true, + storageSource: 'MinIO', + }, + { + id: '23', + url: 'https://images.pexels.com/photos/1323550/pexels-photo-1323550.jpeg', + thumbnail: 'https://images.pexels.com/photos/1323550/pexels-photo-1323550.jpeg?auto=compress&cs=tinysrgb&w=400', + filename: 'wheat-field.jpg', + size: 2345000, + width: 1920, + height: 1080, + format: 'jpg', + uploadedAt: new Date('2024-12-24'), + tags: ['麦田', '农田'], + isFavorite: false, + storageSource: 'MinIO', + }, + { + id: '24', + url: 'https://images.pexels.com/photos/1761279/pexels-photo-1761279.jpeg', + thumbnail: 'https://images.pexels.com/photos/1761279/pexels-photo-1761279.jpeg?auto=compress&cs=tinysrgb&w=400', + filename: 'rocky-coast.jpg', + size: 2456000, + width: 1920, + height: 1280, + format: 'jpg', + uploadedAt: new Date('2024-12-23'), + tags: ['海岸', '岩石'], + isFavorite: false, + storageSource: 'MinIO', + }, + { + id: '25', + url: 'https://images.pexels.com/photos/1655166/pexels-photo-1655166.jpeg', + thumbnail: 'https://images.pexels.com/photos/1655166/pexels-photo-1655166.jpeg?auto=compress&cs=tinysrgb&w=400', + filename: 'bamboo-forest.jpg', + size: 2234000, + width: 1920, + height: 1080, + format: 'jpg', + uploadedAt: new Date('2024-12-22'), + tags: ['竹林', '森林'], + isFavorite: true, + storageSource: 'MinIO', + }, + { + id: '26', + url: 'https://images.pexels.com/photos/1659438/pexels-photo-1659438.jpeg', + thumbnail: 'https://images.pexels.com/photos/1659438/pexels-photo-1659438.jpeg?auto=compress&cs=tinysrgb&w=400', + filename: 'tulip-garden.jpg', + size: 2567000, + width: 2048, + height: 1365, + format: 'jpg', + uploadedAt: new Date('2024-12-21'), + tags: ['郁金香', '花园'], + isFavorite: false, + storageSource: 'MinIO', + }, + { + id: '27', + url: 'https://images.pexels.com/photos/1366919/pexels-photo-1366919.jpeg', + thumbnail: 'https://images.pexels.com/photos/1366919/pexels-photo-1366919.jpeg?auto=compress&cs=tinysrgb&w=400', + filename: 'glacier-lake.jpg', + size: 2890000, + width: 1920, + height: 1280, + format: 'jpg', + uploadedAt: new Date('2024-12-20'), + tags: ['冰川', '湖泊'], + isFavorite: true, + storageSource: 'MinIO', + }, + { + id: '28', + url: 'https://images.pexels.com/photos/1529360/pexels-photo-1529360.jpeg', + thumbnail: 'https://images.pexels.com/photos/1529360/pexels-photo-1529360.jpeg?auto=compress&cs=tinysrgb&w=400', + filename: 'sunset-pier.jpg', + size: 2123000, + width: 1920, + height: 1080, + format: 'jpg', + uploadedAt: new Date('2024-12-19'), + tags: ['码头', '日落'], + isFavorite: false, + storageSource: 'MinIO', + }, + { + id: '29', + url: 'https://images.pexels.com/photos/1624496/pexels-photo-1624496.jpeg', + thumbnail: 'https://images.pexels.com/photos/1624496/pexels-photo-1624496.jpeg?auto=compress&cs=tinysrgb&w=400', + filename: 'rice-terrace.jpg', + size: 2456000, + width: 2048, + height: 1365, + format: 'jpg', + uploadedAt: new Date('2024-12-18'), + tags: ['梯田', '农田'], + isFavorite: false, + storageSource: 'MinIO', + }, + { + id: '30', + url: 'https://images.pexels.com/photos/1430676/pexels-photo-1430676.jpeg', + thumbnail: 'https://images.pexels.com/photos/1430676/pexels-photo-1430676.jpeg?auto=compress&cs=tinysrgb&w=400', + filename: 'alpine-meadow.jpg', + size: 2345000, + width: 1920, + height: 1080, + format: 'jpg', + uploadedAt: new Date('2024-12-17'), + tags: ['高山', '草甸'], + isFavorite: true, + storageSource: 'MinIO', + }, + { + id: '31', + url: 'https://images.pexels.com/photos/1557652/pexels-photo-1557652.jpeg', + thumbnail: 'https://images.pexels.com/photos/1557652/pexels-photo-1557652.jpeg?auto=compress&cs=tinysrgb&w=400', + filename: 'palm-beach.jpg', + size: 2234000, + width: 1920, + height: 1280, + format: 'jpg', + uploadedAt: new Date('2024-12-16'), + tags: ['棕榈树', '海滩'], + isFavorite: false, + storageSource: 'MinIO', + }, + { + id: '32', + url: 'https://images.pexels.com/photos/1271619/pexels-photo-1271619.jpeg', + thumbnail: 'https://images.pexels.com/photos/1271619/pexels-photo-1271619.jpeg?auto=compress&cs=tinysrgb&w=400', + filename: 'volcano-peak.jpg', + size: 2678000, + width: 1920, + height: 1080, + format: 'jpg', + uploadedAt: new Date('2024-12-15'), + tags: ['火山', '山峰'], + isFavorite: true, + storageSource: 'MinIO', + }, + { + id: '33', + url: 'https://images.pexels.com/photos/1576937/pexels-photo-1576937.jpeg', + thumbnail: 'https://images.pexels.com/photos/1576937/pexels-photo-1576937.jpeg?auto=compress&cs=tinysrgb&w=400', + filename: 'summer-field.jpg', + size: 2456000, + width: 2048, + height: 1365, + format: 'jpg', + uploadedAt: new Date('2024-12-14'), + tags: ['夏天', '田野'], + isFavorite: false, + storageSource: 'MinIO', + }, + { + id: '34', + url: 'https://images.pexels.com/photos/1179229/pexels-photo-1179229.jpeg', + thumbnail: 'https://images.pexels.com/photos/1179229/pexels-photo-1179229.jpeg?auto=compress&cs=tinysrgb&w=400', + filename: 'pine-forest.jpg', + size: 2345000, + width: 1920, + height: 1280, + format: 'jpg', + uploadedAt: new Date('2024-12-13'), + tags: ['松林', '自然'], + isFavorite: false, + storageSource: 'MinIO', + }, + { + id: '35', + url: 'https://images.pexels.com/photos/1525041/pexels-photo-1525041.jpeg', + thumbnail: 'https://images.pexels.com/photos/1525041/pexels-photo-1525041.jpeg?auto=compress&cs=tinysrgb&w=400', + filename: 'rainbow-sky.jpg', + size: 2567000, + width: 1920, + height: 1080, + format: 'jpg', + uploadedAt: new Date('2024-12-12'), + tags: ['彩虹', '天空'], + isFavorite: true, + storageSource: 'MinIO', + }, + { + id: '36', + url: 'https://images.pexels.com/photos/1761283/pexels-photo-1761283.jpeg', + thumbnail: 'https://images.pexels.com/photos/1761283/pexels-photo-1761283.jpeg?auto=compress&cs=tinysrgb&w=400', + filename: 'coral-reef.jpg', + size: 2890000, + width: 2048, + height: 1365, + format: 'jpg', + uploadedAt: new Date('2024-12-11'), + tags: ['珊瑚礁', '海洋'], + isFavorite: true, + storageSource: 'MinIO', + }, +]; + +export const Gallery: React.FC = () => { + const { images, setImages, selectedImages, toggleImageSelection, toggleFavorite } = + useGalleryStore(); + + // 初始化模拟数据 + useEffect(() => { + if (images.length === 0) { + setImages(mockImages); + } + }, [images.length, setImages]); + + const formatFileSize = (bytes: number) => { + if (bytes === 0) return '0 B'; + const k = 1024; + const sizes = ['B', 'KB', 'MB', 'GB']; + const i = Math.floor(Math.log(bytes) / Math.log(k)); + return Math.round(bytes / Math.pow(k, i) * 100) / 100 + ' ' + sizes[i]; + }; + + // 瀑布流断点配置 + const breakpointColumnsObj = { + default: 4, + 1400: 3, + 1000: 2, + 700: 1, + }; + + // 渲染瀑布流视图 + const renderGridView = () => ( + + {images.map((image) => ( + + {image.filename} { + e.stopPropagation(); + }} + /> +
+ + +
+ toggleImageSelection(image.id)} + style={{ + position: 'absolute', + top: 8, + left: 8, + zIndex: 1, + }} + onClick={(e) => e.stopPropagation()} + /> +