update code level
This commit is contained in:
@@ -1025,7 +1025,7 @@ function showPreviewModal(index) {
|
||||
</div>
|
||||
<div class="preview-content">
|
||||
<div class="preview-image-container">
|
||||
<img src="${API_BASE}/original/${favorite.image.id}"
|
||||
<img src="${API_BASE}/image/${favorite.image.id}"
|
||||
alt="${favorite.image.title || '预览图片'}"
|
||||
class="preview-image"
|
||||
id="preview-image"
|
||||
|
||||
@@ -7,10 +7,9 @@ port = 8080
|
||||
|
||||
[storage]
|
||||
images_dir = "./albums"
|
||||
thumbnails_dir = "./thumbnails"
|
||||
|
||||
[queue]
|
||||
max_concurrent_tasks = 2
|
||||
queue_size_limit = 500
|
||||
max_concurrent_tasks = 5
|
||||
queue_size_limit = 5000
|
||||
high_request_rate_threshold = 200.0
|
||||
idle_request_rate_threshold = 10.0
|
||||
@@ -25,7 +25,6 @@ pub struct ServerConfig {
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct StorageConfig {
|
||||
pub images_dir: PathBuf,
|
||||
pub thumbnails_dir: PathBuf,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
|
||||
@@ -39,7 +39,6 @@ impl ImageProcessor {
|
||||
pub fn new(config: StorageConfig) -> Self {
|
||||
// 确保目录存在
|
||||
fs::create_dir_all(&config.images_dir).unwrap_or(());
|
||||
fs::create_dir_all(&config.thumbnails_dir).unwrap_or(());
|
||||
|
||||
Self { config }
|
||||
}
|
||||
@@ -66,13 +65,7 @@ impl ImageProcessor {
|
||||
let (width, height) = img.dimensions();
|
||||
let file_size = image_data.len() as i64;
|
||||
|
||||
// 生成缩略图
|
||||
let thumbnail_path = self
|
||||
.config
|
||||
.thumbnails_dir
|
||||
.join(format!("thumb_{}", new_filename));
|
||||
self.generate_thumbnail(&img, &thumbnail_path, 0, 0)?;
|
||||
|
||||
// 不再生成缩略图,直接返回原图信息
|
||||
Ok(ImageInfo {
|
||||
id: image_id,
|
||||
filename: new_filename,
|
||||
@@ -84,23 +77,15 @@ impl ImageProcessor {
|
||||
}
|
||||
|
||||
/// 生成缩略图并保存到指定路径(使用统一尺寸)
|
||||
/// 此功能已被移除,直接返回成功
|
||||
pub fn generate_thumbnail(
|
||||
&self,
|
||||
img: &image::DynamicImage,
|
||||
output_path: &Path,
|
||||
_img: &image::DynamicImage,
|
||||
_output_path: &Path,
|
||||
_max_width: u32,
|
||||
_max_height: u32,
|
||||
) -> Result<(), ImageProcessorError> {
|
||||
// 使用统一的缩略图尺寸(400x300,保持宽高比)
|
||||
let thumbnail = img.thumbnail(400, 300);
|
||||
|
||||
// 确保输出目录存在
|
||||
if let Some(parent) = output_path.parent() {
|
||||
fs::create_dir_all(parent)?;
|
||||
}
|
||||
|
||||
thumbnail.save_with_format(output_path, ImageFormat::Jpeg)?;
|
||||
|
||||
// 缩略图功能已移除,此函数不再执行任何操作
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -186,4 +171,4 @@ pub struct ImageInfo {
|
||||
pub height: i32,
|
||||
pub file_size: i64,
|
||||
pub mime_type: String,
|
||||
}
|
||||
}
|
||||
@@ -139,8 +139,6 @@ async fn main() -> std::io::Result<()> {
|
||||
|
||||
// 创建数据目录
|
||||
fs::create_dir_all(&config.storage.images_dir).unwrap_or(());
|
||||
// 不再创建缩略图目录,因为已移除缩略图功能
|
||||
fs::create_dir_all(&config.database.url[7..]).unwrap_or(());
|
||||
|
||||
// 在闭包外提取需要的路径
|
||||
let server_address = config.server_address();
|
||||
|
||||
Reference in New Issue
Block a user