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:
Jason
2026-01-26 11:24:28 +08:00
parent 5e92111771
commit 29a0643d74
5 changed files with 22 additions and 45 deletions
+5 -12
View File
@@ -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) {