diff --git a/UPDATELOG.md b/UPDATELOG.md index 11518d6f..0faa9b6a 100644 --- a/UPDATELOG.md +++ b/UPDATELOG.md @@ -35,6 +35,7 @@ - 增加 IP 信息请求重试机制,减少 Network Error 发生的情况 - 切换到规则页面时自动刷新规则数据 - 重构更新失败回退机制,使用后端完成更新失败后回退到使用 Clash 代理再次尝试更新 + - 编辑非激活订阅的时候不在触发当前订阅配置重载 ## v2.2.3 diff --git a/src/components/profile/profile-viewer.tsx b/src/components/profile/profile-viewer.tsx index 7f934fc9..a86a5a12 100644 --- a/src/components/profile/profile-viewer.tsx +++ b/src/components/profile/profile-viewer.tsx @@ -22,9 +22,10 @@ import { createProfile, patchProfile } from "@/services/cmds"; import { BaseDialog, Notice, Switch } from "@/components/base"; import { version } from "@root/package.json"; import { FileInput } from "./file-input"; +import { useProfiles } from "@/hooks/use-profiles"; interface Props { - onChange: () => void; + onChange: (isActivating?: boolean) => void; } export interface ProfileViewerRef { @@ -40,6 +41,7 @@ export const ProfileViewer = forwardRef( const [open, setOpen] = useState(false); const [openType, setOpenType] = useState<"new" | "edit">("new"); const [loading, setLoading] = useState(false); + const { profiles } = useProfiles(); // file input const fileDataRef = useRef(null); @@ -107,6 +109,10 @@ export const ProfileViewer = forwardRef( const name = form.name || `${form.type} file`; const item = { ...form, name }; const isRemote = form.type === "remote"; + const isUpdate = openType === "edit"; + + // 判断是否是当前激活的配置 + const isActivating = isUpdate && form.uid === (profiles?.current ?? ""); // 保存原始代理设置以便回退成功后恢复 const originalOptions = { @@ -165,7 +171,9 @@ export const ProfileViewer = forwardRef( setOpen(false); setTimeout(() => formIns.reset(), 500); fileDataRef.current = null; - props.onChange(); + + // 只传递当前配置激活状态,让父组件决定是否需要触发配置重载 + props.onChange(isActivating); } catch (err: any) { Notice.error(err.message || err.toString()); } finally { diff --git a/src/pages/profiles.tsx b/src/pages/profiles.tsx index 96303476..bd1c9cd9 100644 --- a/src/pages/profiles.tsx +++ b/src/pages/profiles.tsx @@ -469,9 +469,12 @@ const ProfilePage = () => { { + onChange={async (isActivating) => { mutateProfiles(); - await onEnhance(false); + // 只有更改当前激活的配置时才触发全局重新加载 + if (isActivating) { + await onEnhance(false); + } }} />