From c857fcf0359e2e98daf6a34ae98ddd43f6e00a9f Mon Sep 17 00:00:00 2001 From: MystiPanda Date: Wed, 3 Jul 2024 08:15:02 +0800 Subject: [PATCH] fix: compatibility --- src-tauri/src/config/profiles.rs | 3 +- src/components/profile/profile-item.tsx | 52 ++++++++++++------------- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/src-tauri/src/config/profiles.rs b/src-tauri/src/config/profiles.rs index 08ef1f9e..260eba76 100644 --- a/src-tauri/src/config/profiles.rs +++ b/src-tauri/src/config/profiles.rs @@ -1,4 +1,4 @@ -use super::prfitem::PrfItem; +use super::{prfitem::PrfItem, PrfOption}; use crate::utils::{dirs, help}; use anyhow::{bail, Context, Result}; use serde::{Deserialize, Serialize}; @@ -205,6 +205,7 @@ impl IProfiles { each.extra = item.extra; each.updated = item.updated; each.home = item.home; + each.option = PrfOption::merge(each.option.clone(), item.option); // save the file data // move the field value after save if let Some(file_data) = item.file_data.take() { diff --git a/src/components/profile/profile-item.tsx b/src/components/profile/profile-item.tsx index 42ff0f48..308f76e1 100644 --- a/src/components/profile/profile-item.tsx +++ b/src/components/profile/profile-item.tsx @@ -211,27 +211,27 @@ export const ProfileItem = (props: Props) => { { label: "Edit Rules", handler: onEditRules, - disabled: option?.rules === null, + disabled: !option?.rules, + }, + { + label: "Edit Proxies", + handler: onEditProxies, + disabled: !option?.proxies, + }, + { + label: "Edit Groups", + handler: onEditGroups, + disabled: !option?.groups, }, - // { - // label: "Edit Proxies", - // handler: onEditProxies, - // disabled: option?.proxies === null, - // }, - // { - // label: "Edit Groups", - // handler: onEditGroups, - // disabled: option?.groups === null, - // }, { label: "Extend Config", handler: onEditMerge, - disabled: option?.merge === null, + disabled: !option?.merge, }, { label: "Extend Script", handler: onEditScript, - disabled: option?.script === null, + disabled: !option?.script, }, { label: "Open File", handler: onOpenFile, disabled: false }, { label: "Update", handler: () => onUpdate(0), disabled: false }, @@ -252,27 +252,27 @@ export const ProfileItem = (props: Props) => { { label: "Edit Rules", handler: onEditRules, - disabled: option?.rules === null, + disabled: !option?.rules, + }, + { + label: "Edit Proxies", + handler: onEditProxies, + disabled: !option?.proxies, + }, + { + label: "Edit Groups", + handler: onEditGroups, + disabled: !option?.groups, }, - // { - // label: "Edit Proxies", - // handler: onEditProxies, - // disabled: option?.proxies === null, - // }, - // { - // label: "Edit Groups", - // handler: onEditGroups, - // disabled: option?.groups === null, - // }, { label: "Extend Config", handler: onEditMerge, - disabled: option?.merge === null, + disabled: !option?.merge, }, { label: "Extend Script", handler: onEditScript, - disabled: option?.script === null, + disabled: !option?.script, }, { label: "Open File", handler: onOpenFile, disabled: false }, {