Skip to content

Commit

Permalink
bak
Browse files Browse the repository at this point in the history
  • Loading branch information
TC999 committed Jan 7, 2025
1 parent 281169a commit e4b1624
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/confirmation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::logger;
use crate::delete;
use crate::utils;

pub fn show_confirmation(ctx: &egui::Context, message: &str, status: &Option<String>) -> Option<bool> {
pub fn show_confirmation(ctx: &egui::Context, message: &str, status: &Option<String>, confirm_delete: &mut Option<(String, bool)>) -> Option<bool> {
let mut result = None;

egui::Window::new("确认操作")
Expand All @@ -18,12 +18,19 @@ pub fn show_confirmation(ctx: &egui::Context, message: &str, status: &Option<Str
}

ui.horizontal(|ui| {
if ui.button("确认").clicked() {
result = Some(true);
}
if ui.button("取消").clicked() {
result = Some(false);
println!("用户取消操作");
if status.is_some() {
if ui.button("关闭").clicked() {
*confirm_delete = None;
println!("用户关闭窗口");
}
} else {
if ui.button("确认").clicked() {
result = Some(true);
}
if ui.button("取消").clicked() {
result = Some(false);
println!("用户取消操作");
}
}
});
});
Expand All @@ -40,7 +47,7 @@ pub fn handle_delete_confirmation(
if let Some((folder_name, _)) = confirm_delete {
let message = format!("确定要彻底删除文件夹 {} 吗?", folder_name);
logger::log_info(&message);
if let Some(confirm) = show_confirmation(ctx, &message, status) {
if let Some(confirm) = show_confirmation(ctx, &message, status, confirm_delete) {
if confirm {
if let Some(base_path) = utils::get_appdata_dir(selected_appdata_folder) {
let full_path = base_path.join(&folder_name);
Expand All @@ -59,8 +66,6 @@ pub fn handle_delete_confirmation(
*status = Some(format!("删除文件夹 {} 时发生错误: {}", folder_name, err));
}
}
// 成功删除文件夹后关闭弹窗
*confirm_delete = None;
} else {
eprintln!("无法获取 {} 文件夹路径", selected_appdata_folder);
logger::log_error(&format!(
Expand Down

0 comments on commit e4b1624

Please sign in to comment.