From 8f214b587b17dacc858ccd98fac4c71f6bc9cab9 Mon Sep 17 00:00:00 2001 From: lychang <632945494@qq.com> Date: Wed, 13 May 2026 21:08:04 +0800 Subject: [PATCH] update code level --- assets/js/app.js | 2 +- config.toml | 5 ++--- src/config.rs | 1 - src/image_processor.rs | 27 ++++++--------------------- src/main.rs | 2 -- 5 files changed, 9 insertions(+), 28 deletions(-) diff --git a/assets/js/app.js b/assets/js/app.js index 2d57ed0..f020946 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -1025,7 +1025,7 @@ function showPreviewModal(index) {
- ${favorite.image.title || '预览图片'} 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, -} +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 569a5fb..a01844a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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();