mirror of
https://github.com/clash-verge-rev/clash-verge-rev
synced 2025-05-05 05:03:45 +08:00
perf: avoid reloading active config when editing inactive subscription
This commit is contained in:
parent
8d62c0d521
commit
bd3231bfa8
@ -35,6 +35,7 @@
|
|||||||
- 增加 IP 信息请求重试机制,减少 Network Error 发生的情况
|
- 增加 IP 信息请求重试机制,减少 Network Error 发生的情况
|
||||||
- 切换到规则页面时自动刷新规则数据
|
- 切换到规则页面时自动刷新规则数据
|
||||||
- 重构更新失败回退机制,使用后端完成更新失败后回退到使用 Clash 代理再次尝试更新
|
- 重构更新失败回退机制,使用后端完成更新失败后回退到使用 Clash 代理再次尝试更新
|
||||||
|
- 编辑非激活订阅的时候不在触发当前订阅配置重载
|
||||||
|
|
||||||
## v2.2.3
|
## v2.2.3
|
||||||
|
|
||||||
|
@ -22,9 +22,10 @@ import { createProfile, patchProfile } from "@/services/cmds";
|
|||||||
import { BaseDialog, Notice, Switch } from "@/components/base";
|
import { BaseDialog, Notice, Switch } from "@/components/base";
|
||||||
import { version } from "@root/package.json";
|
import { version } from "@root/package.json";
|
||||||
import { FileInput } from "./file-input";
|
import { FileInput } from "./file-input";
|
||||||
|
import { useProfiles } from "@/hooks/use-profiles";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
onChange: () => void;
|
onChange: (isActivating?: boolean) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ProfileViewerRef {
|
export interface ProfileViewerRef {
|
||||||
@ -40,6 +41,7 @@ export const ProfileViewer = forwardRef<ProfileViewerRef, Props>(
|
|||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const [openType, setOpenType] = useState<"new" | "edit">("new");
|
const [openType, setOpenType] = useState<"new" | "edit">("new");
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
const { profiles } = useProfiles();
|
||||||
|
|
||||||
// file input
|
// file input
|
||||||
const fileDataRef = useRef<string | null>(null);
|
const fileDataRef = useRef<string | null>(null);
|
||||||
@ -107,6 +109,10 @@ export const ProfileViewer = forwardRef<ProfileViewerRef, Props>(
|
|||||||
const name = form.name || `${form.type} file`;
|
const name = form.name || `${form.type} file`;
|
||||||
const item = { ...form, name };
|
const item = { ...form, name };
|
||||||
const isRemote = form.type === "remote";
|
const isRemote = form.type === "remote";
|
||||||
|
const isUpdate = openType === "edit";
|
||||||
|
|
||||||
|
// 判断是否是当前激活的配置
|
||||||
|
const isActivating = isUpdate && form.uid === (profiles?.current ?? "");
|
||||||
|
|
||||||
// 保存原始代理设置以便回退成功后恢复
|
// 保存原始代理设置以便回退成功后恢复
|
||||||
const originalOptions = {
|
const originalOptions = {
|
||||||
@ -165,7 +171,9 @@ export const ProfileViewer = forwardRef<ProfileViewerRef, Props>(
|
|||||||
setOpen(false);
|
setOpen(false);
|
||||||
setTimeout(() => formIns.reset(), 500);
|
setTimeout(() => formIns.reset(), 500);
|
||||||
fileDataRef.current = null;
|
fileDataRef.current = null;
|
||||||
props.onChange();
|
|
||||||
|
// 只传递当前配置激活状态,让父组件决定是否需要触发配置重载
|
||||||
|
props.onChange(isActivating);
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
Notice.error(err.message || err.toString());
|
Notice.error(err.message || err.toString());
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -469,9 +469,12 @@ const ProfilePage = () => {
|
|||||||
|
|
||||||
<ProfileViewer
|
<ProfileViewer
|
||||||
ref={viewerRef}
|
ref={viewerRef}
|
||||||
onChange={async () => {
|
onChange={async (isActivating) => {
|
||||||
mutateProfiles();
|
mutateProfiles();
|
||||||
await onEnhance(false);
|
// 只有更改当前激活的配置时才触发全局重新加载
|
||||||
|
if (isActivating) {
|
||||||
|
await onEnhance(false);
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<ConfigViewer ref={configRef} />
|
<ConfigViewer ref={configRef} />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user