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