This commit is contained in:
2026-07-03 00:56:13 +08:00
parent 82a64787c3
commit bc96296670
13 changed files with 611 additions and 378 deletions

View File

@@ -22,10 +22,23 @@ fn pick_folder(app: tauri::AppHandle) -> Option<String> {
#[tauri::command]
fn read_dir(path: String) -> Result<Vec<DirEntry>, String> {
let entries = fs::read_dir(&path).map_err(|e| format!("无法读取目录: {}", e))?;
let allowed_extensions = ["md", "txt", "png", "jpg", "jpeg", "gif", "svg", "webp", "bmp"];
let mut result = Vec::new();
for entry in entries {
let entry = entry.map_err(|e| format!("读取条目失败: {}", e))?;
let path = entry.path();
let is_dir = path.is_dir();
// Always include directories; filter files by extension
if !is_dir {
let ext = path
.extension()
.and_then(|e| e.to_str())
.unwrap_or("")
.to_lowercase();
if !allowed_extensions.contains(&ext.as_str()) {
continue;
}
}
let name = entry
.file_name()
.to_string_lossy()
@@ -33,7 +46,7 @@ fn read_dir(path: String) -> Result<Vec<DirEntry>, String> {
result.push(DirEntry {
name,
path: path.to_string_lossy().to_string(),
is_dir: path.is_dir(),
is_dir,
});
}
// Sort: directories first, then alphabetical

View File

@@ -13,8 +13,10 @@
"windows": [
{
"title": "yurou",
"width": 800,
"width": 900,
"height": 600,
"minWidth": 900,
"minHeight": 600,
"decorations": true
}
],