Skip to content

Commit

Permalink
修改路径
Browse files Browse the repository at this point in the history
  • Loading branch information
TC999 committed Dec 12, 2024
1 parent 7877e32 commit 06b5357
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@ Cargo.lock

# 日志文件
*.log
adcignore.txt
adcignore.txt

# 规则文件
/rules
16 changes: 11 additions & 5 deletions src/subscription.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use dirs_next as dirs;
use eframe::egui;
use std::collections::HashMap;
use std::fs;
Expand All @@ -16,10 +15,7 @@ pub struct SubscriptionManager {

impl Default for SubscriptionManager {
fn default() -> Self {
let rules_directory = dirs::data_dir()
.unwrap_or_else(|| PathBuf::from("."))
.join("AppDataCleaner")
.join("rules");
let rules_directory = PathBuf::from("./rules");

// 确保目录存在
if let Err(e) = fs::create_dir_all(&rules_directory) {
Expand All @@ -39,6 +35,16 @@ impl Default for SubscriptionManager {
}

impl SubscriptionManager {
pub fn set_rules_directory(&mut self, directory: &str) {
let new_directory = PathBuf::from(directory);

if let Err(e) = fs::create_dir_all(&new_directory) {
eprintln!("无法创建规则目录: {}", e);
} else {
self.rules_directory = new_directory;
}
}

pub fn show_window(&mut self, ctx: &egui::Context) {
let mut is_open = self.is_open;
if is_open {
Expand Down

0 comments on commit 06b5357

Please sign in to comment.