Skip to content

Commit b7697f7

Browse files
authored
Merge pull request #1538 from jlcodes99/merge/pr-1503
merge: PR #1503 auto-import local accounts
2 parents fa4f7f8 + 240eca1 commit b7697f7

8 files changed

Lines changed: 787 additions & 2 deletions

File tree

src-tauri/src/commands/system.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ pub struct GeneralConfig {
133133
pub app_auto_launch_enabled: bool,
134134
/// 是否启用后台账号授权保活
135135
pub token_keeper_enabled: bool,
136+
/// 是否启用本机账号变更后自动导入
137+
pub auto_import_from_local_enabled: bool,
136138
/// 是否在应用启动后触发 Antigravity IDE 唤醒
137139
pub antigravity_startup_wakeup_enabled: bool,
138140
/// Antigravity IDE 启动后唤醒延时(秒)
@@ -1042,6 +1044,7 @@ fn is_general_config_patch_field(key: &str) -> bool {
10421044
| "floating_card_always_on_top"
10431045
| "app_auto_launch_enabled"
10441046
| "token_keeper_enabled"
1047+
| "auto_import_from_local_enabled"
10451048
| "antigravity_startup_wakeup_enabled"
10461049
| "antigravity_startup_wakeup_delay_seconds"
10471050
| "codex_startup_wakeup_enabled"
@@ -2476,6 +2479,7 @@ pub fn get_general_config(app: tauri::AppHandle) -> Result<GeneralConfig, String
24762479
floating_card_always_on_top: user_config.floating_card_always_on_top,
24772480
app_auto_launch_enabled,
24782481
token_keeper_enabled: user_config.token_keeper_enabled,
2482+
auto_import_from_local_enabled: user_config.auto_import_from_local_enabled,
24792483
antigravity_startup_wakeup_enabled: user_config.antigravity_startup_wakeup_enabled,
24802484
antigravity_startup_wakeup_delay_seconds: sanitize_startup_wakeup_delay_seconds(
24812485
user_config.antigravity_startup_wakeup_delay_seconds,
@@ -2638,6 +2642,7 @@ pub fn patch_general_config(
26382642

26392643
let mut language_changed = false;
26402644
let mut token_keeper_enabled_changed = false;
2645+
let mut auto_import_from_local_enabled_changed = false;
26412646
let mut floating_always_on_top_changed = false;
26422647
#[cfg(target_os = "macos")]
26432648
let mut hide_dock_icon_changed = false;
@@ -2647,6 +2652,7 @@ pub fn patch_general_config(
26472652
let patch_result = config::patch_user_config(|current| {
26482653
let previous_language = current.language.clone();
26492654
let previous_token_keeper_enabled = current.token_keeper_enabled;
2655+
let previous_auto_import_from_local_enabled = current.auto_import_from_local_enabled;
26502656
let previous_floating_always_on_top = current.floating_card_always_on_top;
26512657
#[cfg(target_os = "macos")]
26522658
let previous_hide_dock_icon = current.hide_dock_icon;
@@ -2658,6 +2664,8 @@ pub fn patch_general_config(
26582664
language_changed = previous_language != current.language;
26592665
token_keeper_enabled_changed =
26602666
previous_token_keeper_enabled != current.token_keeper_enabled;
2667+
auto_import_from_local_enabled_changed = previous_auto_import_from_local_enabled
2668+
!= current.auto_import_from_local_enabled;
26612669
floating_always_on_top_changed =
26622670
previous_floating_always_on_top != current.floating_card_always_on_top;
26632671
#[cfg(target_os = "macos")]
@@ -2692,6 +2700,12 @@ pub fn patch_general_config(
26922700
);
26932701
}
26942702

2703+
if auto_import_from_local_enabled_changed {
2704+
modules::auto_local_import::notify_config_changed(
2705+
new_config.auto_import_from_local_enabled,
2706+
);
2707+
}
2708+
26952709
if floating_always_on_top_changed {
26962710
if let Err(err) = modules::floating_card_window::apply_floating_card_always_on_top(&app) {
26972711
modules::logger::log_warn(&format!(
@@ -2763,6 +2777,7 @@ pub fn save_general_config(
27632777
floating_card_always_on_top: Option<bool>,
27642778
app_auto_launch_enabled: Option<bool>,
27652779
token_keeper_enabled: Option<bool>,
2780+
auto_import_from_local_enabled: Option<bool>,
27662781
antigravity_startup_wakeup_enabled: Option<bool>,
27672782
antigravity_startup_wakeup_delay_seconds: Option<i32>,
27682783
codex_startup_wakeup_enabled: Option<bool>,
@@ -2904,6 +2919,7 @@ pub fn save_general_config(
29042919

29052920
let mut language_changed = false;
29062921
let mut token_keeper_enabled_changed = false;
2922+
let mut auto_import_from_local_enabled_changed = false;
29072923
let mut current_app_auto_launch_enabled = false;
29082924
#[cfg(target_os = "macos")]
29092925
let mut hide_dock_icon_changed = false;
@@ -2915,6 +2931,9 @@ pub fn save_general_config(
29152931
token_keeper_enabled_changed = token_keeper_enabled
29162932
.map(|enabled| current.token_keeper_enabled != enabled)
29172933
.unwrap_or(false);
2934+
auto_import_from_local_enabled_changed = auto_import_from_local_enabled
2935+
.map(|enabled| current.auto_import_from_local_enabled != enabled)
2936+
.unwrap_or(false);
29182937
current_app_auto_launch_enabled = current.app_auto_launch_enabled;
29192938
#[cfg(target_os = "macos")]
29202939
{
@@ -3021,6 +3040,9 @@ pub fn save_general_config(
30213040
if let Some(value) = token_keeper_enabled {
30223041
current.token_keeper_enabled = value;
30233042
}
3043+
if let Some(value) = auto_import_from_local_enabled {
3044+
current.auto_import_from_local_enabled = value;
3045+
}
30243046
if let Some(value) = antigravity_startup_wakeup_enabled {
30253047
current.antigravity_startup_wakeup_enabled = value;
30263048
}
@@ -3314,6 +3336,12 @@ pub fn save_general_config(
33143336
);
33153337
}
33163338

3339+
if auto_import_from_local_enabled_changed {
3340+
modules::auto_local_import::notify_config_changed(
3341+
new_config.auto_import_from_local_enabled,
3342+
);
3343+
}
3344+
33173345
if current_app_auto_launch_enabled != new_config.app_auto_launch_enabled {
33183346
apply_app_auto_launch_enabled(&app, new_config.app_auto_launch_enabled)?;
33193347
}

src-tauri/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ pub fn run() {
349349
}
350350

351351
modules::provider_token_keeper::ensure_started(app.handle().clone());
352+
modules::auto_local_import::ensure_started(app.handle().clone());
352353
modules::wakeup_scheduler::restore_state_from_disk();
353354
modules::wakeup_scheduler::ensure_started(app.handle().clone());
354355
modules::codex_wakeup_scheduler::ensure_started(app.handle().clone());

0 commit comments

Comments
 (0)