diff --git a/src-tauri/icons/128x128.png b/src-tauri/icons/128x128.png index 6be5e50..33f6922 100644 Binary files a/src-tauri/icons/128x128.png and b/src-tauri/icons/128x128.png differ diff --git a/src-tauri/icons/128x128@2x.png b/src-tauri/icons/128x128@2x.png index e81bece..0a94cfd 100644 Binary files a/src-tauri/icons/128x128@2x.png and b/src-tauri/icons/128x128@2x.png differ diff --git a/src-tauri/icons/32x32.png b/src-tauri/icons/32x32.png index a437dd5..f095645 100644 Binary files a/src-tauri/icons/32x32.png and b/src-tauri/icons/32x32.png differ diff --git a/src-tauri/icons/Square107x107Logo.png b/src-tauri/icons/Square107x107Logo.png index 0ca4f27..c5a2482 100644 Binary files a/src-tauri/icons/Square107x107Logo.png and b/src-tauri/icons/Square107x107Logo.png differ diff --git a/src-tauri/icons/Square142x142Logo.png b/src-tauri/icons/Square142x142Logo.png index b81f820..b26d90a 100644 Binary files a/src-tauri/icons/Square142x142Logo.png and b/src-tauri/icons/Square142x142Logo.png differ diff --git a/src-tauri/icons/Square150x150Logo.png b/src-tauri/icons/Square150x150Logo.png index 624c7bf..73832b5 100644 Binary files a/src-tauri/icons/Square150x150Logo.png and b/src-tauri/icons/Square150x150Logo.png differ diff --git a/src-tauri/icons/Square284x284Logo.png b/src-tauri/icons/Square284x284Logo.png index c021d2b..9a6e9ba 100644 Binary files a/src-tauri/icons/Square284x284Logo.png and b/src-tauri/icons/Square284x284Logo.png differ diff --git a/src-tauri/icons/Square30x30Logo.png b/src-tauri/icons/Square30x30Logo.png index 6219700..a691568 100644 Binary files a/src-tauri/icons/Square30x30Logo.png and b/src-tauri/icons/Square30x30Logo.png differ diff --git a/src-tauri/icons/Square310x310Logo.png b/src-tauri/icons/Square310x310Logo.png index f9bc048..83f3fc5 100644 Binary files a/src-tauri/icons/Square310x310Logo.png and b/src-tauri/icons/Square310x310Logo.png differ diff --git a/src-tauri/icons/Square44x44Logo.png b/src-tauri/icons/Square44x44Logo.png index d5fbfb2..68dd569 100644 Binary files a/src-tauri/icons/Square44x44Logo.png and b/src-tauri/icons/Square44x44Logo.png differ diff --git a/src-tauri/icons/Square71x71Logo.png b/src-tauri/icons/Square71x71Logo.png index 63440d7..b6c98bd 100644 Binary files a/src-tauri/icons/Square71x71Logo.png and b/src-tauri/icons/Square71x71Logo.png differ diff --git a/src-tauri/icons/Square89x89Logo.png b/src-tauri/icons/Square89x89Logo.png index f3f705a..fb9beca 100644 Binary files a/src-tauri/icons/Square89x89Logo.png and b/src-tauri/icons/Square89x89Logo.png differ diff --git a/src-tauri/icons/StoreLogo.png b/src-tauri/icons/StoreLogo.png index 4556388..d969bb8 100644 Binary files a/src-tauri/icons/StoreLogo.png and b/src-tauri/icons/StoreLogo.png differ diff --git a/src-tauri/icons/icon.icns b/src-tauri/icons/icon.icns index 12a5bce..b4e8f35 100644 Binary files a/src-tauri/icons/icon.icns and b/src-tauri/icons/icon.icns differ diff --git a/src-tauri/icons/icon.ico b/src-tauri/icons/icon.ico index b3636e4..6001274 100644 Binary files a/src-tauri/icons/icon.ico and b/src-tauri/icons/icon.ico differ diff --git a/src-tauri/icons/icon.png b/src-tauri/icons/icon.png index e1cd261..e6ea30c 100644 Binary files a/src-tauri/icons/icon.png and b/src-tauri/icons/icon.png differ diff --git a/src-tauri/src/commands.rs b/src-tauri/src/commands.rs index 122295b..82ab27b 100644 --- a/src-tauri/src/commands.rs +++ b/src-tauri/src/commands.rs @@ -102,21 +102,26 @@ pub fn get_manga_dir_data( // 用于存储不同尺寸的图片的数量 let mut size_count: HashMap<(u32, u32), u32> = HashMap::new(); // 遍历漫画目录下的所有文件,统计不同尺寸的图片的数量 - for entry in WalkDir::new(PathBuf::from_slash(manga_dir)) + WalkDir::new(PathBuf::from_slash(manga_dir)) .max_depth(2) // 一般第一层目录是章节目录,第二层目录是图片文件 .into_iter() .filter_map(Result::ok) - { - let path = entry.into_path(); - if path.is_file() && path.extension().map_or(false, |e| e == "jpg") { - let Ok(size) = imagesize::size(&path) else { - continue; - }; + .filter_map(|entry| { + let path = entry.into_path(); + if !path.is_file() { + return None; + } + let ext = path.extension()?; + if ext != "jpg" && ext != "jpeg" { + return None; + } + imagesize::size(&path).ok() + }) + .for_each(|size| { let key = (size.width as u32, size.height as u32); let count = size_count.entry(key).or_insert(0); *count += 1; - } - } + }); // 将统计结果转换为Vec let mut manga_dir_data: Vec = size_count .into_iter() @@ -165,23 +170,29 @@ pub fn get_jpg_image_infos(manga_dir: &str) -> CommandResponse // 用于存储jpg图片的信息 let mut jpg_image_infos = vec![]; // 遍历漫画目录下的所有文件,获取jpg图片的信息 - for entry in WalkDir::new(PathBuf::from_slash(manga_dir)) + WalkDir::new(PathBuf::from_slash(manga_dir)) .max_depth(2) // 一般第一层目录是章节目录,第二层目录是图片文件 .into_iter() .filter_map(Result::ok) - { - let path = entry.into_path(); - if path.is_file() && path.extension().map_or(false, |e| e == "jpg") { - let Ok(size) = imagesize::size(&path) else { - continue; - }; + .filter_map(|entry| { + let path = entry.into_path(); + if !path.is_file() { + return None; + } + let ext = path.extension()?; + if ext != "jpg" && ext != "jpeg" { + return None; + } + let size = imagesize::size(&path).ok()?; + Some((path, size)) + }) + .for_each(|(path, size)| { jpg_image_infos.push(JpgImageInfo { width: size.width as u32, height: size.height as u32, path, }); - } - } + }); CommandResponse { code: 0, msg: String::new(), diff --git a/src-tauri/src/watermark.rs b/src-tauri/src/watermark.rs index f29189b..f961075 100644 --- a/src-tauri/src/watermark.rs +++ b/src-tauri/src/watermark.rs @@ -14,7 +14,7 @@ use std::{ }; use tauri::AppHandle; use tauri_specta::Event; -use walkdir::{DirEntry, WalkDir}; +use walkdir::WalkDir; /// 生成黑色背景和白色背景的水印图片 pub fn generate_background( @@ -101,7 +101,11 @@ fn create_image_paths(manga_dir: &str, width: u32, height: u32) -> Vec .filter_map(Result::ok) .filter_map(|entry| { let path = entry.into_path(); - if !path.is_file() || path.extension()? != "jpg" { + if !path.is_file() { + return None; + } + let ext = path.extension()?; + if ext != "jpg" && ext != "jpeg" { return None; } let size = imagesize::size(&path).ok()?; @@ -233,16 +237,22 @@ fn create_dir_progress<'a>( fn create_dir_map(manga_dir: &PathBuf) -> HashMap> { let mut dir_map: HashMap> = HashMap::new(); // 遍历manga_dir目录下的所有文件和子目录 - for entry in WalkDir::new(manga_dir).into_iter().filter_map(Result::ok) { - let entry: DirEntry = entry; - let path = entry.into_path(); - // 如果是文件且是jpg文件则添加到directory_map中 - if path.is_file() && path.extension().map_or(false, |e| e == "jpg") { - if let Some(parent) = path.parent() { - dir_map.entry(parent.to_path_buf()).or_default().push(path); + WalkDir::new(manga_dir) + .into_iter() + .filter_map(Result::ok) + .filter_map(|entry| { + let path = entry.into_path(); + if !path.is_file() { + return None; } - } - } + let ext = path.extension()?; + if ext != "jpg" && ext != "jpeg" { + return None; + } + let parent = path.parent()?.to_path_buf(); + Some((path, parent)) + }) + .for_each(|(path, parent)| dir_map.entry(parent).or_default().push(path)); dir_map }