Fixed an issue with adding a profile when making changes in advanced settings.
This commit is contained in:
@@ -164,7 +164,16 @@ pub async fn import_profile(url: String, option: Option<PrfOption>) -> CmdResult
|
||||
url
|
||||
);
|
||||
let item = wrap_err!(PrfItem::from_url(&url, None, None, option).await)?;
|
||||
wrap_err!(Config::profiles().data().append_item(item))
|
||||
let new_uid = item.uid.clone().unwrap_or_default();
|
||||
wrap_err!(Config::profiles().data().append_item(item))?;
|
||||
if !new_uid.is_empty() {
|
||||
let _ = patch_profiles_config(IProfiles {
|
||||
current: Some(new_uid),
|
||||
items: None,
|
||||
})
|
||||
.await?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,7 +187,17 @@ pub async fn reorder_profile(active_id: String, over_id: String) -> CmdResult {
|
||||
#[tauri::command]
|
||||
pub async fn create_profile(item: PrfItem, file_data: Option<String>) -> CmdResult {
|
||||
let item = wrap_err!(PrfItem::from(item, file_data).await)?;
|
||||
wrap_err!(Config::profiles().data().append_item(item))
|
||||
let new_uid = item.uid.clone().unwrap_or_default();
|
||||
wrap_err!(Config::profiles().data().append_item(item))?;
|
||||
|
||||
if !new_uid.is_empty() {
|
||||
let _ = patch_profiles_config(IProfiles {
|
||||
current: Some(new_uid),
|
||||
items: None,
|
||||
})
|
||||
.await?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// 更新配置文件
|
||||
|
||||
@@ -504,13 +504,23 @@ impl PrfItem {
|
||||
selected: None,
|
||||
extra,
|
||||
option: Some(PrfOption {
|
||||
user_agent: user_agent.clone(),
|
||||
with_proxy: if with_proxy { Some(true) } else { None },
|
||||
self_proxy: if self_proxy { Some(true) } else { None },
|
||||
update_interval,
|
||||
update_always,
|
||||
timeout_seconds: Some(timeout),
|
||||
danger_accept_invalid_certs: if accept_invalid_certs {
|
||||
Some(true)
|
||||
} else {
|
||||
None
|
||||
},
|
||||
merge,
|
||||
script,
|
||||
rules,
|
||||
proxies,
|
||||
groups,
|
||||
use_hwid: Some(use_hwid),
|
||||
..PrfOption::default()
|
||||
}),
|
||||
home,
|
||||
|
||||
@@ -136,10 +136,9 @@ impl IProfiles {
|
||||
.with_context(|| format!("failed to write to file \"{file}\""))?;
|
||||
}
|
||||
|
||||
if self.current.is_none()
|
||||
&& (item.itype == Some("remote".to_string()) || item.itype == Some("local".to_string()))
|
||||
{
|
||||
self.current = uid;
|
||||
if item.itype == Some("remote".to_string()) || item.itype == Some("local".to_string()) {
|
||||
// Always switch current to the newly created remote/local profile
|
||||
self.current = uid.clone();
|
||||
}
|
||||
|
||||
if self.items.is_none() {
|
||||
|
||||
Reference in New Issue
Block a user