mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-24 21:30:17 +08:00
refactor(config): consolidate get_home_dir into single public function
Follow-up to #644: Extract duplicate get_home_dir() implementations into a single pub fn in config.rs, reducing code duplication across codex_config.rs, gemini_config.rs, and settings.rs. Also adds documentation comments to build.rs explaining the Windows manifest workaround for test binaries.
This commit is contained in:
@@ -163,18 +163,11 @@ impl Default for AppSettings {
|
||||
impl AppSettings {
|
||||
fn settings_path() -> Option<PathBuf> {
|
||||
// settings.json 保留用于旧版本迁移和无数据库场景
|
||||
#[cfg(windows)]
|
||||
if let Ok(home) = std::env::var("HOME") {
|
||||
let trimmed = home.trim();
|
||||
if !trimmed.is_empty() {
|
||||
return Some(
|
||||
PathBuf::from(trimmed)
|
||||
.join(".cc-switch")
|
||||
.join("settings.json"),
|
||||
);
|
||||
}
|
||||
}
|
||||
dirs::home_dir().map(|h| h.join(".cc-switch").join("settings.json"))
|
||||
Some(
|
||||
crate::config::get_home_dir()
|
||||
.join(".cc-switch")
|
||||
.join("settings.json"),
|
||||
)
|
||||
}
|
||||
|
||||
fn normalize_paths(&mut self) {
|
||||
|
||||
Reference in New Issue
Block a user