add type of browser
This commit is contained in:
@@ -34,7 +34,7 @@ pub fn resolve_browser_configs(app: &AppHandle) -> Result<Vec<BrowserConfigEntry
|
||||
.map(|config| BrowserConfigEntry {
|
||||
id: config.id,
|
||||
source: BrowserConfigSource::Custom,
|
||||
browser_family_id: None,
|
||||
browser_family_id: config.browser_family_id.or(config.icon_key.clone()),
|
||||
icon_key: config.icon_key,
|
||||
name: config.name,
|
||||
executable_path: config.executable_path,
|
||||
@@ -61,6 +61,7 @@ pub fn create_custom_browser_config(
|
||||
});
|
||||
let executable_path = input.executable_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() {
|
||||
return Err("Name is required.".to_string());
|
||||
@@ -77,6 +78,7 @@ pub fn create_custom_browser_config(
|
||||
id: generate_custom_config_id(),
|
||||
name: name.to_string(),
|
||||
icon_key,
|
||||
browser_family_id,
|
||||
executable_path: executable_path.to_string(),
|
||||
user_data_path: user_data_path.to_string(),
|
||||
});
|
||||
@@ -197,3 +199,12 @@ fn generate_custom_config_id() -> String {
|
||||
.unwrap_or(0);
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user