mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 17:15:38 +08:00
fix: delete profile item command
This commit is contained in:
@@ -107,13 +107,23 @@ pub fn select_profile(
|
||||
}
|
||||
}
|
||||
|
||||
/// todo: need to check
|
||||
/// delete profile item
|
||||
#[tauri::command]
|
||||
pub fn delete_profile(index: usize, profiles: State<'_, ProfilesState>) -> Result<(), String> {
|
||||
match profiles.0.lock() {
|
||||
Ok(mut profiles) => profiles.delete_item(index),
|
||||
Err(_) => Err("can not get profiles lock".into()),
|
||||
pub fn delete_profile(
|
||||
index: usize,
|
||||
clash_state: State<'_, ClashState>,
|
||||
profiles_state: State<'_, ProfilesState>,
|
||||
) -> Result<(), String> {
|
||||
let mut profiles = profiles_state.0.lock().unwrap();
|
||||
match profiles.delete_item(index) {
|
||||
Ok(change) => match change {
|
||||
true => {
|
||||
let clash = clash_state.0.lock().unwrap();
|
||||
profiles.activate(clash.info.clone())
|
||||
}
|
||||
false => Ok(()),
|
||||
},
|
||||
Err(err) => Err(err),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user