Skip to content

Commit

Permalink
测试通过
Browse files Browse the repository at this point in the history
  • Loading branch information
TC999 committed Jan 7, 2025
1 parent e4b1624 commit ccd5e07
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 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>, confirm_delete: &mut Option<(String, bool)>) -> Option<bool> {
pub fn show_confirmation(ctx: &egui::Context, message: &str, status: &Option<String>) -> Option<bool> {
let mut result = None;

egui::Window::new("确认操作")
Expand All @@ -20,8 +20,7 @@ pub fn show_confirmation(ctx: &egui::Context, message: &str, status: &Option<Str
ui.horizontal(|ui| {
if status.is_some() {
if ui.button("关闭").clicked() {
*confirm_delete = None;
println!("用户关闭窗口");
result = Some(false);
}
} else {
if ui.button("确认").clicked() {
Expand All @@ -44,10 +43,10 @@ pub fn handle_delete_confirmation(
selected_appdata_folder: &str,
status: &mut Option<String>,
) {
if let Some((folder_name, _)) = confirm_delete {
if let Some((folder_name, _)) = confirm_delete.clone() {
let message = format!("确定要彻底删除文件夹 {} 吗?", folder_name);
logger::log_info(&message);
if let Some(confirm) = show_confirmation(ctx, &message, status, confirm_delete) {
if let Some(confirm) = show_confirmation(ctx, &message, status) {
if confirm {
if let Some(base_path) = utils::get_appdata_dir(selected_appdata_folder) {
let full_path = base_path.join(&folder_name);
Expand All @@ -74,6 +73,8 @@ pub fn handle_delete_confirmation(
));
*status = Some(format!("无法获取 {} 文件夹路径", selected_appdata_folder));
}
} else {
*confirm_delete = None; // 用户选择关闭或取消
}
}
}
Expand Down

0 comments on commit ccd5e07

Please sign in to comment.