wip: multi accounts

This commit is contained in:
2024-02-19 09:58:27 +07:00
parent 0f06522c28
commit bfe35ad885
13 changed files with 537 additions and 465 deletions

View File

@@ -1,4 +1,5 @@
use std::process::Command;
use tauri::Manager;
#[tauri::command]
pub async fn show_in_folder(path: String) {
@@ -46,3 +47,26 @@ pub async fn show_in_folder(path: String) {
Command::new("open").args(["-R", &path]).spawn().unwrap();
}
}
#[tauri::command]
pub fn get_all_nsecs(app_handle: tauri::AppHandle) -> Result<Vec<String>, ()> {
let dir = app_handle.path().app_config_dir().unwrap();
if let Ok(paths) = std::fs::read_dir(dir) {
let files = paths
.filter_map(|res| res.ok())
.map(|dir_entry| dir_entry.path())
.filter_map(|path| {
if path.extension().map_or(false, |ext| ext == "nsec") {
Some(path.file_name().unwrap().to_str().unwrap().to_string())
} else {
None
}
})
.collect::<Vec<_>>();
Ok(files)
} else {
Err(())
}
}