mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-08-01 21:06:13 +08:00
fix(opencode): fix add/remove provider flow and toast messages
- Create separate removeFromLiveConfig API for additive mode apps (remove only removes from live config, not database) - Fix useSwitchProviderMutation to invalidate opencodeLiveProviderIds cache so button state updates correctly after add operation - Show appropriate toast messages: - Add: "已添加到配置" / "Added to config" - Remove: "已从配置移除" / "Removed from config" - Add i18n texts for addToConfigSuccess and removeFromConfigSuccess
This commit is contained in:
@@ -261,6 +261,27 @@ impl ProviderService {
|
||||
state.db.delete_provider(app_type.as_str(), id)
|
||||
}
|
||||
|
||||
/// Remove provider from live config only (for additive mode apps like OpenCode)
|
||||
///
|
||||
/// Does NOT delete from database - provider remains in the list.
|
||||
/// This is used when user wants to "remove" a provider from active config
|
||||
/// but keep it available for future use.
|
||||
pub fn remove_from_live_config(app_type: AppType, id: &str) -> Result<(), AppError> {
|
||||
match app_type {
|
||||
AppType::OpenCode => {
|
||||
remove_opencode_provider_from_live(id)?;
|
||||
}
|
||||
// Future: add other additive mode apps here
|
||||
_ => {
|
||||
return Err(AppError::Message(format!(
|
||||
"App {} does not support remove from live config",
|
||||
app_type.as_str()
|
||||
)));
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Switch to a provider
|
||||
///
|
||||
/// Switch flow:
|
||||
|
||||
Reference in New Issue
Block a user