diff --git a/assets/js/album.js b/assets/js/album.js index 0ffa665..684d3c2 100644 --- a/assets/js/album.js +++ b/assets/js/album.js @@ -235,7 +235,7 @@ async function loadAlbum(albumId) { // 显示骨架屏 showImageSkeleton(); - const response = await fetch(`/api/album/${albumId}`); + const response = await fetch(`${API_BASE}/album/${albumId}`); if (!response.ok) { if (response.status === 404) { throw new Error('相册不存在'); @@ -431,7 +431,7 @@ function displayImages() { let dataSrc = ''; if (image.id) { - dataSrc = `/api/image/${image.id}`; + dataSrc = `${API_BASE}/image/${image.id}`; imageUrl = '/assets/placeholder.svg'; // 初始使用占位图 } else if (image.original_url) { dataSrc = image.original_url; @@ -545,7 +545,7 @@ function updateLightboxContent(newIndex) { // 在lightbox中优先使用原始图片以获得更好的显示效果 let imageUrl = '/assets/placeholder.svg'; if (image.id) { - imageUrl = `/api/image/${image.id}`; + imageUrl = `${API_BASE}/image/${image.id}`; } else if (image.original_url) { imageUrl = image.original_url; } diff --git a/assets/js/app.js b/assets/js/app.js index 9805727..402d89c 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -369,7 +369,7 @@ function appendAlbums(albums) { let dataSrc = ''; if (album.cover_image_id) { - dataSrc = `/api/image/${album.cover_image_id}`; + dataSrc = `${API_BASE}/image/${album.cover_image_id}`; coverImageUrl = '/assets/placeholder.svg'; // 初始使用占位图 } @@ -585,7 +585,7 @@ function displayAlbums(albums) { let dataSrc = ''; if (album.cover_image_id) { - dataSrc = `/api/image/${album.cover_image_id}`; + dataSrc = `${API_BASE}/image/${album.cover_image_id}`; coverImageUrl = '/assets/placeholder.svg'; // 初始使用占位图 } @@ -1495,12 +1495,21 @@ async function filterByPerson(personName) { } } catch (e) { /* 回退 */ } } - // 回退到全站搜索,也要保存过滤结果 + // 回退到全站搜索 filteredAlbums = await performServerSearchWithResult(personName); } catch (error) { console.error('人物筛选失败:', error); filteredAlbums = await performServerSearchWithResult(personName); } + + // 无论回退搜索是否找到结果,都要渲染页面(移除骨架屏) + if (filteredAlbums !== null) { + currentDisplayPage = 1; + hasMoreAlbums = filteredAlbums.length > albumsPerPage; + displayAlbums(filteredAlbums); + updateStats(filteredAlbums); + initLazyLoading(); + } } // 显示筛选状态 diff --git a/src/routes/person.rs b/src/routes/person.rs index 7dd9d05..7d12a67 100644 --- a/src/routes/person.rs +++ b/src/routes/person.rs @@ -6,17 +6,16 @@ use std::collections::HashMap; use std::sync::Arc; use tokio::sync::RwLock; -/// GET /api/people — 从缓存获取所有人名列表 +/// GET /api/people — 从内存缓存获取所有人名列表 pub async fn get_people(cache: web::Data>>) -> impl Responder { let c = cache.read().await; - // 缓存中已按 total_albums DESC 排序 HttpResponse::Ok().json(PersonListResponse { total: c.persons.len(), persons: c.persons.clone(), }) } -/// GET /api/people/search?q=关键词 — 从缓存搜索人名 +/// GET /api/people/search?q=关键词 — 从内存缓存搜索人名 pub async fn search_people( cache: web::Data>>, query: web::Query>, @@ -36,7 +35,7 @@ pub async fn search_people( }) } -/// GET /api/people/{name} — 从缓存查找人物详情(相册列表从 search.db) +/// GET /api/people/{name} — 从 search.db 查找人物详情(缓存查人物信息,search.db 查相册列表) pub async fn get_person_detail( search_db: web::Data>, cache: web::Data>>, @@ -44,7 +43,7 @@ pub async fn get_person_detail( ) -> impl Responder { let name = path.into_inner(); let c = cache.read().await; - // 在缓存中搜索 + // 在内存缓存中查找人物 let found = c.search(&name); let p = found.into_iter().find(|p| p.name.to_lowercase() == name.to_lowercase()); match p {