This commit is contained in:
lychang
2026-03-20 02:31:07 +08:00
commit 5893cd5e31
19 changed files with 5653 additions and 0 deletions

43
assets/album.html Normal file
View File

@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>相册详情 - 图片展示服务</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
<link rel="stylesheet" href="/assets/css/style.css">
<link rel="stylesheet" href="/assets/css/album.css">
</head>
<body>
<div class="container">
<div class="header">
<a href="/" class="back-link">
<i class="fas fa-arrow-left"></i> 返回首页
</a>
<h1 class="album-title" id="album-title">加载中...</h1>
<div class="album-info" id="album-info">
<i class="fas fa-images"></i> 正在加载...
</div>
</div>
<div class="images-grid" id="images-container">
<div class="loading">
<i class="fas fa-spinner fa-spin"></i><br>加载图片中...
</div>
</div>
</div>
<!-- 图片查看器 -->
<div class="lightbox" id="lightbox">
<span class="lightbox-close" onclick="closeLightbox()">&times;</span>
<div class="lightbox-nav">
<button onclick="prevImage()"><i class="fas fa-chevron-left"></i></button>
<button onclick="nextImage()"><i class="fas fa-chevron-right"></i></button>
</div>
<img id="lightbox-img" src="" alt="">
<div class="lightbox-info" id="lightbox-info"></div>
</div>
<script src="/assets/js/album.js"></script>
</body>
</html>

212
assets/css/album.css Normal file
View File

@@ -0,0 +1,212 @@
/* 相册详情页面特定样式 - 蓝白配色体系 */
:root {
--primary-blue: #1e40af;
--secondary-blue: #3b82f6;
--light-blue: #dbeafe;
--accent-blue: #60a5fa;
--white: #ffffff;
--light-gray: #f8fafc;
--medium-gray: #e2e8f0;
--dark-gray: #475569;
--text-dark: #1e293b;
--text-light: #64748b;
--shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
--shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
--shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
--shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.1);
--border-radius: 12px;
--border-radius-lg: 20px;
}
body {
font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
background: linear-gradient(135deg, var(--light-blue) 0%, var(--white) 100%);
min-height: 100vh;
color: var(--text-dark);
line-height: 1.6;
}
.container {
max-width: 1400px;
margin: 0 auto;
padding: 30px 20px;
}
.header { margin-bottom: 40px; }
.back-link {
display: inline-flex;
align-items: center;
gap: 10px;
padding: 12px 24px;
background: var(--white);
color: var(--primary-blue);
text-decoration: none;
border-radius: var(--border-radius);
box-shadow: var(--shadow-sm);
margin-bottom: 25px;
transition: all 0.3s ease;
border: 1px solid var(--medium-gray);
font-weight: 500;
}
.back-link:hover {
background: var(--light-blue);
transform: translateX(-5px);
box-shadow: var(--shadow-md);
color: var(--primary-blue);
}
.album-title {
color: var(--text-dark);
font-size: 2.5rem;
text-align: center;
margin-bottom: 15px;
font-weight: 700;
background: linear-gradient(135deg, var(--primary-blue) 0%, var(--secondary-blue) 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.album-info {
text-align: center;
color: var(--text-light);
font-size: 1.2rem;
margin-bottom: 40px;
background: var(--white);
padding: 20px;
border-radius: var(--border-radius);
box-shadow: var(--shadow-sm);
border: 1px solid var(--medium-gray);
max-width: 800px;
margin-left: auto;
margin-right: auto;
}
.images-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
gap: 25px;
margin-bottom: 50px;
}
.image-item {
position: relative;
overflow: hidden;
border-radius: var(--border-radius);
box-shadow: var(--shadow-lg);
background: var(--white);
transition: all 0.3s ease;
cursor: pointer;
border: 1px solid var(--medium-gray);
}
.image-item:hover {
transform: translateY(-8px);
box-shadow: var(--shadow-xl);
border-color: var(--accent-blue);
}
.image-item img {
width: 100%;
height: 220px;
object-fit: cover;
display: block;
transition: transform 0.5s ease;
}
.image-item:hover img {
transform: scale(1.05);
}
.image-caption {
padding: 12px;
text-align: center;
color: var(--text-dark);
font-size: 0.9rem;
font-weight: 500;
line-height: 1.4;
}
/* 图片查看器样式 */
.lightbox {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(30, 41, 59, 0.95);
z-index: 1000;
justify-content: center;
align-items: center;
flex-direction: column;
backdrop-filter: blur(10px);
}
.lightbox img {
max-width: 85%;
max-height: 75%;
object-fit: contain;
border-radius: 12px;
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}
.lightbox-close {
position: absolute;
top: 30px;
right: 40px;
color: var(--white);
font-size: 36px;
cursor: pointer;
z-index: 1001;
background: rgba(255, 255, 255, 0.1);
width: 50px;
height: 50px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.3s ease;
backdrop-filter: blur(10px);
}
.lightbox-close:hover {
background: rgba(255, 255, 255, 0.2);
transform: scale(1.1);
}
.lightbox-nav {
position: absolute;
top: 50%;
width: 100%;
display: flex;
justify-content: space-between;
padding: 0 20px;
transform: translateY(-50%);
z-index: 1001;
}
.lightbox-nav button {
background: rgba(255,255,255,0.2);
border: none;
color: var(--white);
font-size: 30px;
padding: 12px 24px;
cursor: pointer;
border-radius: var(--border-radius);
backdrop-filter: blur(10px);
transition: all 0.3s ease;
border: 1px solid rgba(255, 255, 255, 0.1);
}
.lightbox-nav button:hover {
background: rgba(255,255,255,0.3);
transform: scale(1.1);
border-color: rgba(255, 255, 255, 0.3);
}
.lightbox-info {
color: var(--white);
text-align: center;
margin-top: 25px;
font-size: 1.2rem;
background: rgba(255, 255, 255, 0.1);
padding: 15px 25px;
border-radius: var(--border-radius);
backdrop-filter: blur(10px);
}
@media (max-width: 768px) {
.images-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.album-title { font-size: 1.8rem; }
.lightbox img { max-width: 95%; max-height: 60%; }
.lightbox-nav button { font-size: 24px; padding: 10px 18px; }
.container { padding: 20px 15px; }
.album-info { font-size: 1.1rem; padding: 15px; }
}

228
assets/css/style.css Normal file
View File

@@ -0,0 +1,228 @@
/* 现代化蓝白配色体系 */
:root {
--primary-blue: #1e40af;
--secondary-blue: #3b82f6;
--light-blue: #dbeafe;
--accent-blue: #60a5fa;
--white: #ffffff;
--light-gray: #f8fafc;
--medium-gray: #e2e8f0;
--dark-gray: #475569;
--text-dark: #1e293b;
--text-light: #64748b;
--shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
--shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
--shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
--shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.1);
--border-radius: 12px;
--border-radius-lg: 20px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
background: linear-gradient(135deg, var(--light-blue) 0%, var(--white) 100%);
min-height: 100vh;
color: var(--text-dark);
line-height: 1.6;
}
.container {
max-width: 1400px;
margin: 0 auto;
padding: 30px 20px;
}
.header {
text-align: center;
margin-bottom: 50px;
color: var(--text-dark);
}
.header h1 {
font-size: 3rem;
margin-bottom: 15px;
font-weight: 700;
background: linear-gradient(135deg, var(--primary-blue) 0%, var(--secondary-blue) 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.header p {
font-size: 1.3rem;
color: var(--text-light);
max-width: 600px;
margin: 0 auto;
}
.search-container {
text-align: center;
margin-bottom: 50px;
}
.search-box {
position: relative;
display: inline-block;
max-width: 500px;
width: 100%;
}
.search-box input {
width: 100%;
padding: 18px 60px 18px 25px;
font-size: 16px;
border: 2px solid var(--medium-gray);
border-radius: 50px;
background: var(--white);
box-shadow: var(--shadow-md);
transition: all 0.3s ease;
color: var(--text-dark);
}
.search-box input:focus {
outline: none;
border-color: var(--secondary-blue);
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
transform: translateY(-2px);
}
.search-box button {
position: absolute;
right: 15px;
top: 50%;
transform: translateY(-50%);
background: var(--secondary-blue);
border: none;
color: var(--white);
font-size: 18px;
cursor: pointer;
width: 40px;
height: 40px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.3s ease;
}
.search-box button:hover {
background: var(--primary-blue);
transform: translateY(-50%) scale(1.05);
}
.stats {
text-align: center;
color: var(--text-dark);
margin-bottom: 40px;
font-size: 1.1rem;
background: var(--white);
padding: 20px;
border-radius: var(--border-radius);
box-shadow: var(--shadow-sm);
border: 1px solid var(--medium-gray);
}
.albums-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
gap: 30px;
margin-bottom: 40px;
}
.album-card {
background: var(--white);
border-radius: var(--border-radius-lg);
box-shadow: var(--shadow-lg);
overflow: hidden;
transition: all 0.3s ease;
position: relative;
border: 1px solid var(--medium-gray);
}
.album-card:hover {
transform: translateY(-8px);
box-shadow: var(--shadow-xl);
border-color: var(--accent-blue);
}
.album-cover {
height: 220px;
overflow: hidden;
position: relative;
background: var(--light-gray);
}
.album-cover img {
width: 100%;
height: 100%;
object-fit: cover;
transition: transform 0.5s ease;
}
.album-card:hover .album-cover img {
transform: scale(1.05);
}
.album-info {
padding: 25px;
}
.album-info h2 {
font-size: 1.4rem;
margin-bottom: 12px;
color: var(--text-dark);
line-height: 1.4;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
font-weight: 600;
}
.album-meta {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
color: var(--text-light);
font-size: 0.9rem;
}
.album-meta span {
display: flex;
align-items: center;
gap: 6px;
}
.view-button {
display: block;
text-align: center;
padding: 14px;
background: linear-gradient(135deg, var(--secondary-blue) 0%, var(--primary-blue) 100%);
color: var(--white);
text-decoration: none;
border-radius: 10px;
font-weight: 600;
transition: all 0.3s ease;
border: none;
cursor: pointer;
font-size: 1rem;
}
.view-button:hover {
transform: translateY(-2px);
box-shadow: 0 8px 20px rgba(59, 130, 246, 0.3);
background: linear-gradient(135deg, var(--primary-blue) 0%, var(--secondary-blue) 100%);
}
.no-results {
text-align: center;
color: var(--text-light);
font-size: 1.2rem;
padding: 60px 40px;
background: var(--white);
border-radius: var(--border-radius-lg);
box-shadow: var(--shadow-md);
border: 1px solid var(--medium-gray);
}
.loading {
text-align: center;
color: var(--text-light);
font-size: 1.2rem;
padding: 60px 40px;
background: var(--white);
border-radius: var(--border-radius-lg);
box-shadow: var(--shadow-md);
border: 1px solid var(--medium-gray);
}
@media (max-width: 768px) {
.albums-grid { grid-template-columns: 1fr; }
.search-box { max-width: 100%; }
.header h1 { font-size: 2.2rem; }
.container { padding: 20px 15px; }
.album-info { padding: 20px; }
}

37
assets/index.html Normal file
View File

@@ -0,0 +1,37 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>流云图库</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
<link rel="stylesheet" href="/assets/css/style.css">
</head>
<body>
<div class="container">
<div class="header">
<h1><i class="fas fa-images"></i> <span>流云图库</span></h1>
<p>发现精彩瞬间,浏览精美图片</p>
</div>
<div class="search-container">
<div class="search-box">
<label for="search-input"></label><input type="text" id="search-input" placeholder="搜索图片标题..." onkeypress="handleKeyPress(event)">
<button onclick="searchAlbums()"><i class="fas fa-search"></i></button>
</div>
</div>
<div class="stats" id="stats">
正在加载相册数据...
</div>
<div class="albums-grid" id="albums-container">
<div class="loading">
<i class="fas fa-spinner fa-spin"></i><br>加载中...
</div>
</div>
</div>
<script src="/assets/js/app.js"></script>
</body>
</html>

182
assets/js/album.js Normal file
View File

@@ -0,0 +1,182 @@
// 全局变量
let currentAlbum = null;
let currentImageIndex = 0;
let images = [];
// 页面加载完成后初始化
document.addEventListener('DOMContentLoaded', function() {
const urlParams = new URLSearchParams(window.location.search);
const albumId = urlParams.get('id');
if (albumId) {
loadAlbum(albumId);
} else {
showError('缺少相册ID参数');
}
});
// 加载相册详情
async function loadAlbum(albumId) {
try {
const response = await fetch(`/api/album/${albumId}`);
if (!response.ok) {
if (response.status === 404) {
throw new Error('相册不存在');
}
throw new Error(`HTTP error! status: ${response.status}`);
}
const albumData = await response.json();
currentAlbum = albumData.album;
images = albumData.images;
updateAlbumInfo();
displayImages();
} catch (error) {
console.error('加载相册失败:', error);
showError('加载相册失败: ' + error.message);
}
}
// 更新相册信息
function updateAlbumInfo() {
document.getElementById('album-title').textContent = currentAlbum.title;
document.getElementById('album-info').innerHTML =
`<i class="fas fa-images"></i> 共 ${images.length} 张图片`;
document.title = `${currentAlbum.title} - 图片展示服务`;
}
// 显示图片列表
function displayImages() {
const container = document.getElementById('images-container');
if (images.length === 0) {
container.innerHTML = '<div class="no-results"><i class="fas fa-images"></i><br>此相册暂无图片</div>';
return;
}
container.innerHTML = images.map((image, index) => {
// 优先使用缩略图API,如果没有则使用原始URL
let imageUrl = '/assets/placeholder.svg';
if (image.id) {
imageUrl = `/api/thumbnail/${image.id}`;
} else if (image.original_url) {
imageUrl = image.original_url;
}
const title = image.title || `图片 ${index + 1}`;
return `
<div class="image-item" onclick="openLightbox(${index})">
<img src="${imageUrl}" alt="${title}" onerror="this.src='/assets/placeholder.svg'">
<div class="image-caption">
${image.width ? `<small>${image.width}×${image.height}</small>` : ''}
${image.file_size ? `<small>${(image.file_size / 1024 ).toFixed(2)} KB</small>` : ''}
</div>
</div>
`;
}).join('');
}
// 打开图片查看器
function openLightbox(index) {
currentImageIndex = index;
const lightbox = document.getElementById('lightbox');
const lightboxImg = document.getElementById('lightbox-img');
const lightboxInfo = document.getElementById('lightbox-info');
const image = images[index];
// 在lightbox中优先使用原始图片以获得更好的显示效果
let imageUrl = '/assets/placeholder.svg';
if (image.id) {
imageUrl = `/api/original/${image.id}`;
} else if (image.original_url) {
imageUrl = image.original_url;
}
lightboxImg.src = imageUrl;
const title = image.title || `图片 ${index + 1}`;
let infoText = `${title} (${index + 1}/${images.length})`;
if (image.width && image.height) {
infoText += ` | ${image.width}×${image.height}`;
}
if (image.file_size) {
infoText += ` | ${(image.file_size / 1024 ).toFixed(2)} KB`;
}
lightboxInfo.textContent = infoText;
lightbox.style.display = 'flex';
document.body.style.overflow = 'hidden';
}
// 关闭图片查看器
function closeLightbox() {
const lightbox = document.getElementById('lightbox');
lightbox.style.display = 'none';
document.body.style.overflow = 'auto';
}
// 下一张图片
function nextImage() {
currentImageIndex = (currentImageIndex + 1) % images.length;
updateLightboxImage();
}
// 上一张图片
function prevImage() {
currentImageIndex = (currentImageIndex - 1 + images.length) % images.length;
updateLightboxImage();
}
// 更新图片查看器显示
function updateLightboxImage() {
const lightboxImg = document.getElementById('lightbox-img');
const lightboxInfo = document.getElementById('lightbox-info');
const image = images[currentImageIndex];
// 在lightbox中优先使用原始图片以获得更好的显示效果
let imageUrl = '/assets/placeholder.svg';
if (image.id) {
imageUrl = `/api/original/${image.id}`;
} else if (image.original_url) {
imageUrl = image.original_url;
}
lightboxImg.src = imageUrl;
const title = image.title || `图片 ${currentImageIndex + 1}`;
let infoText = `${title} (${currentImageIndex + 1}/${images.length})`;
if (image.width && image.height) {
infoText += ` | ${image.width}×${image.height}`;
}
if (image.file_size) {
infoText += ` | ${(image.file_size / 1024 ).toFixed(2)} KB`;
}
lightboxInfo.textContent = infoText;
}
// 键盘导航
document.addEventListener('keydown', function(event) {
const lightbox = document.getElementById('lightbox');
if (lightbox.style.display === 'flex') {
if (event.key === 'Escape') closeLightbox();
if (event.key === 'ArrowRight') nextImage();
if (event.key === 'ArrowLeft') prevImage();
}
});
// 点击背景关闭
document.getElementById('lightbox').addEventListener('click', function(event) {
if (event.target === this) closeLightbox();
});
// 显示错误信息
function showError(message) {
const container = document.getElementById('images-container');
container.innerHTML = `<div class="no-results"><i class="fas fa-exclamation-triangle"></i><br>${message}</div>`;
document.getElementById('album-title').textContent = '加载失败';
document.getElementById('album-info').innerHTML = '';
}

115
assets/js/app.js Normal file
View File

@@ -0,0 +1,115 @@
// 全局变量
let allAlbums = [];
// API基础URL
const API_BASE = '/api';
// 页面加载完成后初始化
document.addEventListener('DOMContentLoaded', function() {
loadAlbums();
});
// 加载所有相册
async function loadAlbums() {
try {
const response = await fetch(`${API_BASE}/albums`);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
allAlbums = await response.json();
displayAlbums(allAlbums);
updateStats(allAlbums);
} catch (error) {
console.error('加载相册失败:', error);
showError('加载相册数据失败,请刷新页面重试');
}
}
// 搜索相册
async function searchAlbums() {
const searchTerm = document.getElementById('search-input').value.toLowerCase().trim();
if (searchTerm === '') {
// 显示所有相册
displayAlbums(allAlbums);
updateStats(allAlbums);
return;
}
try {
const response = await fetch(`${API_BASE}/search?q=${encodeURIComponent(searchTerm)}`);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const filteredAlbums = await response.json();
displayAlbums(filteredAlbums);
if (filteredAlbums.length === 0) {
document.getElementById('stats').innerHTML = `没有找到包含 "${searchTerm}" 的相册`;
} else {
document.getElementById('stats').innerHTML = `找到 ${filteredAlbums.length} 个包含 "${searchTerm}" 的相册`;
}
} catch (error) {
console.error('搜索失败:', error);
showError('搜索失败,请重试');
}
}
// 显示相册列表
function displayAlbums(albums) {
const container = document.getElementById('albums-container');
if (albums.length === 0) {
container.innerHTML = '<div class="no-results"><i class="fas fa-search"></i><br>没有找到匹配的相册</div>';
return;
}
container.innerHTML = albums.map(album => {
// 处理封面图片URL
let coverImageUrl = '/assets/placeholder.svg';
if (album.cover_image_id) {
coverImageUrl = `/api/thumbnail/${album.cover_image_id}`;
}
// 格式化日期
const createdDate = new Date(album.created_at).toLocaleDateString('zh-CN');
return `
<div class="album-card">
<div class="album-cover">
<img src="${coverImageUrl}" alt="${album.title}" onerror="this.src='/assets/placeholder.svg'">
</div>
<div class="album-info">
<h3>${album.title}</h3>
<div class="album-meta">
<span><i class="fas fa-images"></i> ${album.image_count} 张图片</span>
<span><i class="fas fa-calendar"></i> ${createdDate}</span>
</div>
<a href="/album?id=${album.id}" class="view-button">
<i class="fas fa-eye"></i> 查看相册
</a>
</div>
</div>
`;
}).join('');
}
// 更新统计信息
function updateStats(albums) {
const totalImages = albums.reduce((sum, album) => sum + album.image_count, 0);
document.getElementById('stats').innerHTML = `共发现 ${albums.length} 个相册,包含 ${totalImages} 张图片`;
}
// 显示错误信息
function showError(message) {
const container = document.getElementById('albums-container');
container.innerHTML = `<div class="no-results"><i class="fas fa-exclamation-triangle"></i><br>${message}</div>`;
document.getElementById('stats').innerHTML = '';
}
// 键盘事件处理
function handleKeyPress(event) {
if (event.key === 'Enter') {
searchAlbums();
}
}

7
assets/placeholder.svg Normal file
View File

@@ -0,0 +1,7 @@
<svg width="400" height="300" xmlns="http://www.w3.org/2000/svg">
<rect width="100%" height="100%" fill="#f0f0f0"/>
<rect x="150" y="100" width="100" height="100" fill="#ddd" stroke="#999" stroke-width="2"/>
<line x1="150" y1="100" x2="250" y2="200" stroke="#999" stroke-width="2"/>
<line x1="250" y1="100" x2="150" y2="200" stroke="#999" stroke-width="2"/>
<text x="200" y="240" text-anchor="middle" font-family="Arial" font-size="16" fill="#666">图片加载中</text>
</svg>

After

Width:  |  Height:  |  Size: 487 B