fix: #3244, remove test directory, simplify resource initialization

This commit is contained in:
wonfen 2025-04-04 13:18:17 +08:00
parent 98be9621a6
commit b5952f320b
2 changed files with 4 additions and 12 deletions

View File

@ -247,15 +247,15 @@ impl CoreManager {
logging!(info, Type::Config, true, "使用内核: {}", clash_core); logging!(info, Type::Config, true, "使用内核: {}", clash_core);
let app_handle = handle::Handle::global().app_handle().unwrap(); let app_handle = handle::Handle::global().app_handle().unwrap();
let test_dir = dirs::app_home_dir()?.join("test"); let app_dir = dirs::app_home_dir()?;
let test_dir = dirs::path_to_str(&test_dir)?; let app_dir_str = dirs::path_to_str(&app_dir)?;
logging!(info, Type::Config, true, "测试目录: {}", test_dir); logging!(info, Type::Config, true, "验证目录: {}", app_dir_str);
// 使用子进程运行clash验证配置 // 使用子进程运行clash验证配置
let output = app_handle let output = app_handle
.shell() .shell()
.sidecar(clash_core)? .sidecar(clash_core)?
.args(["-t", "-d", test_dir, "-f", config_path]) .args(["-t", "-d", app_dir_str, "-f", config_path])
.output() .output()
.await?; .await?;

View File

@ -295,15 +295,11 @@ pub fn init_config() -> Result<()> {
/// after tauri setup /// after tauri setup
pub fn init_resources() -> Result<()> { pub fn init_resources() -> Result<()> {
let app_dir = dirs::app_home_dir()?; let app_dir = dirs::app_home_dir()?;
let test_dir = app_dir.join("test");
let res_dir = dirs::app_resources_dir()?; let res_dir = dirs::app_resources_dir()?;
if !app_dir.exists() { if !app_dir.exists() {
let _ = fs::create_dir_all(&app_dir); let _ = fs::create_dir_all(&app_dir);
} }
if !test_dir.exists() {
let _ = fs::create_dir_all(&test_dir);
}
if !res_dir.exists() { if !res_dir.exists() {
let _ = fs::create_dir_all(&res_dir); let _ = fs::create_dir_all(&res_dir);
} }
@ -315,7 +311,6 @@ pub fn init_resources() -> Result<()> {
for file in file_list.iter() { for file in file_list.iter() {
let src_path = res_dir.join(file); let src_path = res_dir.join(file);
let dest_path = app_dir.join(file); let dest_path = app_dir.join(file);
let test_dest_path = test_dir.join(file);
log::debug!(target: "app", "src_path: {src_path:?}, dest_path: {dest_path:?}"); log::debug!(target: "app", "src_path: {src_path:?}, dest_path: {dest_path:?}");
let handle_copy = |dest: &PathBuf| { let handle_copy = |dest: &PathBuf| {
@ -327,9 +322,6 @@ pub fn init_resources() -> Result<()> {
}; };
}; };
if src_path.exists() && !test_dest_path.exists() {
handle_copy(&test_dest_path);
}
if src_path.exists() && !dest_path.exists() { if src_path.exists() && !dest_path.exists() {
handle_copy(&dest_path); handle_copy(&dest_path);
continue; continue;