add type of browser

This commit is contained in:
Julian Freeman
2026-04-16 19:24:00 -04:00
parent aac78b4b9c
commit e041523dbd
2 changed files with 14 additions and 1 deletions

View File

@@ -34,7 +34,7 @@ pub fn resolve_browser_configs(app: &AppHandle) -> Result<Vec<BrowserConfigEntry
.map(|config| BrowserConfigEntry { .map(|config| BrowserConfigEntry {
id: config.id, id: config.id,
source: BrowserConfigSource::Custom, source: BrowserConfigSource::Custom,
browser_family_id: None, browser_family_id: config.browser_family_id.or(config.icon_key.clone()),
icon_key: config.icon_key, icon_key: config.icon_key,
name: config.name, name: config.name,
executable_path: config.executable_path, executable_path: config.executable_path,
@@ -61,6 +61,7 @@ pub fn create_custom_browser_config(
}); });
let executable_path = input.executable_path.trim(); let executable_path = input.executable_path.trim();
let user_data_path = input.user_data_path.trim(); let user_data_path = input.user_data_path.trim();
let browser_family_id = infer_browser_family_id(icon_key.as_deref());
if name.is_empty() { if name.is_empty() {
return Err("Name is required.".to_string()); return Err("Name is required.".to_string());
@@ -77,6 +78,7 @@ pub fn create_custom_browser_config(
id: generate_custom_config_id(), id: generate_custom_config_id(),
name: name.to_string(), name: name.to_string(),
icon_key, icon_key,
browser_family_id,
executable_path: executable_path.to_string(), executable_path: executable_path.to_string(),
user_data_path: user_data_path.to_string(), user_data_path: user_data_path.to_string(),
}); });
@@ -197,3 +199,12 @@ fn generate_custom_config_id() -> String {
.unwrap_or(0); .unwrap_or(0);
format!("custom-{timestamp}") format!("custom-{timestamp}")
} }
fn infer_browser_family_id(icon_key: Option<&str>) -> Option<String> {
match icon_key {
Some("chrome") => Some("chrome".to_string()),
Some("edge") => Some("edge".to_string()),
Some("brave") => Some("brave".to_string()),
_ => None,
}
}

View File

@@ -137,6 +137,8 @@ pub struct CustomBrowserConfigRecord {
pub name: String, pub name: String,
#[serde(default)] #[serde(default)]
pub icon_key: Option<String>, pub icon_key: Option<String>,
#[serde(default)]
pub browser_family_id: Option<String>,
pub executable_path: String, pub executable_path: String,
pub user_data_path: String, pub user_data_path: String,
} }