Skip to content

Commit

Permalink
bak
Browse files Browse the repository at this point in the history
  • Loading branch information
TC999 committed Dec 7, 2024
1 parent 88dae7f commit a15ceed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/move_module.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use eframe::egui;
use native_dialog::FileDialog;
use rfd::FileDialog;
use sha2::{Digest, Sha256};
use std::fs;
use std::io::Read;
Expand All @@ -12,9 +12,9 @@ pub fn move_folder(
appdata_folder: &str,
) -> Result<(), String> {
// 弹出文件夹选择对话框
let target_folder = match FileDialog::new()
.set_location("C:/")
.show_open_single_dir()
let target_folder = match FileDialog::new().pick_folder()
.set_directory("C:/") // 设置初始路径
.pick_folder()
{
Ok(Some(folder)) => folder,
Ok(None) => return Err("取消选择目标文件夹".to_string()),
Expand Down
9 changes: 8 additions & 1 deletion src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use eframe::egui::{self, Grid, ScrollArea};
use std::sync::mpsc::{Sender, Receiver};
use std::collections::HashSet;
use std::path::PathBuf; // 确保引入 PathBuf
use rfd::FileDialog;

pub struct AppDataCleaner { // 定义数据类型
is_scanning: bool,
Expand Down Expand Up @@ -78,6 +79,8 @@ impl AppDataCleaner {
});
logger::log_info(&format!("准备移动文件夹: {}", folder));
}
// 移动操作中调用 move_folder 并传入 ctx
move_module::move_folder(ctx, &source_folder, &self.selected_appdata_folder)?;
}
}

Expand Down Expand Up @@ -147,7 +150,7 @@ impl eframe::App for AppDataCleaner {
match move_state {
MoveState::Initiate { source, folder } => {
// 弹出文件夹选择对话框
if let Some(target_folder) = FileDialog::new()
if let Some(target_folder) = FileDialog::new().pick_folder()
.set_location("C:/")
.show_open_single_dir()
.ok()
Expand Down Expand Up @@ -200,6 +203,10 @@ impl eframe::App for AppDataCleaner {
});
}
MoveState::Moving { source, target, folder, progress } => {
// 使用文件选择器
if let Some(target_folder) = FileDialog::new().pick_folder() {
println!("Selected folder: {:?}", target_folder);
}
// 执行移动操作(应在后台线程中执行)
ui.ctx().request_repaint(); // 请求重绘以显示进度

Expand Down

0 comments on commit a15ceed

Please sign in to comment.