update
This commit is contained in:
@@ -99,10 +99,21 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
document.body.classList.add('touch-device');
|
||||
}
|
||||
|
||||
loadAlbums();
|
||||
initSearch();
|
||||
initInfiniteScroll();
|
||||
initLazyLoading(); // 初始化图片懒加载
|
||||
|
||||
// 检查URL中是否有search参数
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const searchQuery = urlParams.get('search');
|
||||
if (searchQuery) {
|
||||
const searchInput = document.getElementById('search-input');
|
||||
searchInput.value = searchQuery;
|
||||
// 直接搜索,不先加载全部相册
|
||||
searchAlbums();
|
||||
} else {
|
||||
loadAlbums();
|
||||
}
|
||||
});
|
||||
|
||||
// 初始化搜索功能
|
||||
@@ -355,7 +366,7 @@ function appendAlbums(albums) {
|
||||
const createdDate = new Date(album.created_at).toLocaleDateString('zh-CN');
|
||||
|
||||
return `
|
||||
<div class="album-card" data-album-id="${album.id}">
|
||||
<div class="album-card" data-album-id="${album.id}" onclick="openAlbum('${album.id}')">
|
||||
<div class="album-cover">
|
||||
<img
|
||||
src="${coverImageUrl}"
|
||||
@@ -371,9 +382,6 @@ function appendAlbums(albums) {
|
||||
<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>
|
||||
`;
|
||||
@@ -555,7 +563,7 @@ function displayAlbums(albums) {
|
||||
const createdDate = new Date(album.created_at).toLocaleDateString('zh-CN');
|
||||
|
||||
return `
|
||||
<div class="album-card" data-album-id="${album.id}">
|
||||
<div class="album-card" data-album-id="${album.id}" onclick="openAlbum('${album.id}')">
|
||||
<div class="album-cover">
|
||||
<img
|
||||
src="${coverImageUrl}"
|
||||
@@ -571,9 +579,6 @@ function displayAlbums(albums) {
|
||||
<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>
|
||||
`;
|
||||
@@ -759,6 +764,11 @@ preloadCriticalResources();
|
||||
// 优化滚动性能
|
||||
optimizeScrollPerformance();
|
||||
|
||||
// 打开相册详情
|
||||
function openAlbum(albumId) {
|
||||
window.location.href = `/album?id=${albumId}`;
|
||||
}
|
||||
|
||||
// 随机打开相册
|
||||
function openRandomAlbum() {
|
||||
// 添加随机动画效果
|
||||
@@ -818,12 +828,7 @@ function showFavorites() {
|
||||
return response.json();
|
||||
})
|
||||
.then(favoriteImages => {
|
||||
if (favoriteImages.length === 0) {
|
||||
alert('收藏夹为空,快去收藏一些喜欢的图片吧!');
|
||||
return;
|
||||
}
|
||||
|
||||
// 创建收藏夹页面或跳转到收藏夹视图
|
||||
// 始终显示收藏夹视图(包括空状态)
|
||||
displayFavorites(favoriteImages);
|
||||
})
|
||||
.catch(error => {
|
||||
@@ -1197,4 +1202,11 @@ function openFavoriteImage(favoriteId) {
|
||||
// 导出函数供全局使用
|
||||
window.searchAlbums = searchAlbums;
|
||||
window.openRandomAlbum = openRandomAlbum;
|
||||
window.showFavorites = showFavorites;
|
||||
window.showFavorites = showFavorites;
|
||||
window.openAlbum = openAlbum;
|
||||
window.backToHome = backToHome;
|
||||
window.loadAlbums = loadAlbums;
|
||||
window.removeFavorite = removeFavorite;
|
||||
window.previewFavorite = previewFavorite;
|
||||
window.openFavoriteImage = openFavoriteImage;
|
||||
window.removeFavoriteFromPreview = removeFavoriteFromPreview;
|
||||
Reference in New Issue
Block a user