Add Codex auth preservation setting

This commit is contained in:
Jason
2026-05-30 14:13:58 +08:00
parent 8f83fa2063
commit 2683af57cb
12 changed files with 171 additions and 3 deletions
+14
View File
@@ -253,6 +253,9 @@ pub struct AppSettings {
/// Whether to show the failover toggle independently on the main page
#[serde(default)]
pub enable_failover_toggle: bool,
/// Keep Codex ChatGPT login material in auth.json when switching to third-party providers
#[serde(default = "default_true")]
pub preserve_codex_official_auth_on_switch: bool,
/// User has confirmed the failover toggle first-run notice
#[serde(default, skip_serializing_if = "Option::is_none")]
pub failover_confirmed: Option<bool>,
@@ -366,6 +369,7 @@ impl Default for AppSettings {
usage_confirmed: None,
stream_check_confirmed: None,
enable_failover_toggle: false,
preserve_codex_official_auth_on_switch: true,
failover_confirmed: None,
first_run_notice_confirmed: None,
common_config_confirmed: None,
@@ -699,6 +703,16 @@ pub fn get_hermes_override_dir() -> Option<PathBuf> {
.map(|p| resolve_override_path(p))
}
pub fn preserve_codex_official_auth_on_switch() -> bool {
settings_store()
.read()
.unwrap_or_else(|e| {
log::warn!("设置锁已毒化,使用恢复值: {e}");
e.into_inner()
})
.preserve_codex_official_auth_on_switch
}
// ===== 当前供应商管理函数 =====
/// 获取指定应用类型的当前供应商 ID(从本地 settings 读取)