feat: séparer vaults et dirs dans la config — type VAULT vs DIR
CI / lint (push) Successful in 24s
CI / security (push) Successful in 15s
CI / test (push) Successful in 36s
CI / build (push) Successful in 7s
CI / e2e (push) Failing after 20s
Desktop Build / build-windows (push) Has been cancelled
Desktop Build / build-linux (push) Has been cancelled
CI / lint (push) Successful in 24s
CI / security (push) Successful in 15s
CI / test (push) Successful in 36s
CI / build (push) Successful in 7s
CI / e2e (push) Failing after 20s
Desktop Build / build-windows (push) Has been cancelled
Desktop Build / build-linux (push) Has been cancelled
- AppConfig: ajout dirs: Vec<DirConfig> distinct de vaults: Vec<VaultConfig> - spawn_backend: passe VAULT_N_* et DIR_N_* séparément (backend les supporte déjà) - Config par défaut: 'Bruno' → %USERPROFILE% (type DIR), 'Obsidian' → voute_obsidian (type VAULT) - Commandes: add_dir, remove_dir, list_dirs
This commit is contained in:
+46
-4
@@ -22,10 +22,17 @@ struct VaultConfig {
|
||||
path: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
struct DirConfig {
|
||||
name: String,
|
||||
path: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
struct AppConfig {
|
||||
vault_path: Option<String>,
|
||||
vaults: Vec<VaultConfig>,
|
||||
dirs: Vec<DirConfig>,
|
||||
window_x: Option<f64>,
|
||||
window_y: Option<f64>,
|
||||
window_width: Option<f64>,
|
||||
@@ -37,6 +44,7 @@ impl Default for AppConfig {
|
||||
Self {
|
||||
vault_path: None,
|
||||
vaults: Vec::new(),
|
||||
dirs: Vec::new(),
|
||||
window_x: None,
|
||||
window_y: None,
|
||||
window_width: Some(1200.0),
|
||||
@@ -135,13 +143,18 @@ fn spawn_backend(exe_dir: &PathBuf) -> Result<Child, String> {
|
||||
cmd.current_dir(&data_dir)
|
||||
.env("PYTHONPATH", exe_dir);
|
||||
|
||||
// Pass vault config as env vars (VAULT_1_NAME, VAULT_1_PATH, etc.)
|
||||
// Pass vault config as env vars (VAULT_N_NAME, VAULT_N_PATH, DIR_N_NAME, DIR_N_PATH)
|
||||
let config = load_config();
|
||||
for (i, vault) in config.vaults.iter().enumerate() {
|
||||
let n = i + 1;
|
||||
cmd.env(format!("VAULT_{}_NAME", n), &vault.name);
|
||||
cmd.env(format!("VAULT_{}_PATH", n), &vault.path);
|
||||
}
|
||||
for (i, dir) in config.dirs.iter().enumerate() {
|
||||
let n = i + 1;
|
||||
cmd.env(format!("DIR_{}_NAME", n), &dir.name);
|
||||
cmd.env(format!("DIR_{}_PATH", n), &dir.path);
|
||||
}
|
||||
|
||||
let child = cmd
|
||||
.args([
|
||||
@@ -278,6 +291,30 @@ fn list_vaults() -> Vec<VaultConfig> {
|
||||
load_config().vaults
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn add_dir(name: String, path: String) -> Result<(), String> {
|
||||
let mut config = load_config();
|
||||
config.dirs.retain(|d| d.name != name);
|
||||
config.dirs.push(DirConfig { name: name.clone(), path });
|
||||
save_config(&config);
|
||||
info!("Dir added: {} — restart backend to apply", name);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn remove_dir(name: String) -> Result<(), String> {
|
||||
let mut config = load_config();
|
||||
config.dirs.retain(|d| d.name != name);
|
||||
save_config(&config);
|
||||
info!("Dir removed: {} — restart backend to apply", name);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn list_dirs() -> Vec<DirConfig> {
|
||||
load_config().dirs
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn restart_backend(state: tauri::State<BackendProcess>) -> Result<String, String> {
|
||||
let mut restarting = state.restarting.lock().map_err(|e| e.to_string())?;
|
||||
@@ -405,11 +442,13 @@ fn main() {
|
||||
}
|
||||
}
|
||||
|
||||
config.vaults = vec![
|
||||
VaultConfig {
|
||||
name: "Dossier".to_string(),
|
||||
config.dirs = vec![
|
||||
DirConfig {
|
||||
name: "Bruno".to_string(),
|
||||
path: userprofile.clone(),
|
||||
},
|
||||
];
|
||||
config.vaults = vec![
|
||||
VaultConfig {
|
||||
name: "Obsidian".to_string(),
|
||||
path: vault_dir.to_string_lossy().to_string(),
|
||||
@@ -469,6 +508,9 @@ fn main() {
|
||||
add_vault,
|
||||
remove_vault,
|
||||
list_vaults,
|
||||
add_dir,
|
||||
remove_dir,
|
||||
list_dirs,
|
||||
])
|
||||
.setup(move |app| {
|
||||
// Restore window position/size
|
||||
|
||||
Reference in New Issue
Block a user