Skip to content

Commit a0ec019

Browse files
authored
Merge pull request #78 from alley-rs/dev
fix: release 时一些编译错误
2 parents a031833 + 1fd341e commit a0ec019

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

src-tauri/src/config/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ use crate::error::{Error, HunterResult};
1414
pub use crate::config::config::Config;
1515
pub use crate::config::log_level::LogLevel;
1616
pub use crate::config::node::ServerNode;
17+
use crate::global::APP_NAME;
1718

18-
const APP_NAME: &str = "hunter";
1919
const CONFIG_FILE_NAME: &str = "hunter.toml";
2020
const TROJAN_CONFIG_FILE_NAME: &str = "config.json";
2121

src-tauri/src/global.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::{fs, path::PathBuf, sync::LazyLock};
22

3-
const APP_NAME: &str = "hunter";
3+
pub const APP_NAME: &str = "hunter";
44

55
pub(super) static EXECUTABLE_DIR: LazyLock<PathBuf> = LazyLock::new(|| {
66
let dir = dirs::cache_dir().unwrap().join(APP_NAME);

src-tauri/src/proxy.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,9 @@ impl Proxy {
435435
}
436436

437437
#[cfg(target_os = "linux")]
438-
pub fn switch_auto_start(&self, current_state: bool) -> HunterResult<()> {
438+
pub async fn switch_auto_start(&self, current_state: bool) -> HunterResult<()> {
439+
let trojan_config_path = get_or_init_config_manager().await.trojan_config_path();
440+
439441
if current_state {
440442
debug!("delete auto start script");
441443
fs::remove_file(&self.auto_start_desktop).map_err(|e| {
@@ -458,7 +460,7 @@ Type=Application
458460
X-KDE-AutostartScript=true
459461
"#,
460462
self.executable_file.to_string_lossy(),
461-
TROJAN_CONFIG_FILE_PATH.to_string_lossy()
463+
trojan_config_path.to_string_lossy()
462464
);
463465

464466
debug!("add auto start script");
@@ -494,7 +496,7 @@ ws.Run "{} -config {}",0"#,
494496
}
495497

496498
#[cfg(target_os = "macos")]
497-
pub fn switch_auto_start(&self, current_state: bool) -> HunterResult<()> {
499+
pub async fn switch_auto_start(&self, current_state: bool) -> HunterResult<()> {
498500
if current_state {
499501
debug!("删除开机启动脚本");
500502
return fs::remove_file(&self.auto_start_plist).map_err(|e| {
@@ -503,6 +505,8 @@ ws.Run "{} -config {}",0"#,
503505
});
504506
}
505507

508+
let trojan_config_path = get_or_init_config_manager().await.trojan_config_path();
509+
506510
let content = format!(
507511
r#"<?xml version="1.0" encoding="UTF-8"?>
508512
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
@@ -522,7 +526,7 @@ ws.Run "{} -config {}",0"#,
522526
</plist>
523527
"#,
524528
self.executable_file.to_string_lossy(),
525-
TROJAN_CONFIG_FILE_PATH.to_str().unwrap()
529+
trojan_config_path.to_str().unwrap()
526530
);
527531

528532
debug!("添加开机启动脚本");

src-tauri/src/setup.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ pub(super) fn setup_logging() {
1313

1414
#[cfg(all(desktop, not(debug_assertions)))]
1515
let writer = {
16-
use crate::global::APP_CONFIG_DIR;
16+
use crate::global::APP_NAME;
1717
use std::{fs::File, sync::Mutex};
18-
let log_file =
19-
File::create(APP_CONFIG_DIR.join("lsar.log")).expect("Failed to create the log file");
18+
let dir = dirs::config_dir().unwrap().join(APP_NAME);
19+
let log_file = File::create(dir.join("lsar.log")).expect("Failed to create the log file");
2020
Mutex::new(log_file)
2121
};
2222

0 commit comments

Comments
 (0)