From eb86b471fee1ab20f209b4e5e068ba0c509541b6 Mon Sep 17 00:00:00 2001 From: GyDi Date: Sat, 12 Feb 2022 21:12:39 +0800 Subject: [PATCH] fix: something --- src/components/setting/setting-clash.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/components/setting/setting-clash.tsx b/src/components/setting/setting-clash.tsx index 3825e87..90675a0 100644 --- a/src/components/setting/setting-clash.tsx +++ b/src/components/setting/setting-clash.tsx @@ -50,7 +50,7 @@ const SettingClash = ({ onError }: Props) => { // restart clash when port is changed const { run: onUpdatePort } = useDebounceFn( async (port: number) => { - (async () => { + try { if (port < 1000) { throw new Error("The port should not < 1000"); } @@ -61,10 +61,10 @@ const SettingClash = ({ onError }: Props) => { onChangeData({ "mixed-port": port }); setPort(port); Notice.success("Change Clash port successfully!"); - })().catch((err: any) => { + } catch (err: any) { setMixedPort(thePort); // back to old port value Notice.error(err.message ?? err.toString()); - }); + } }, { wait: 1000 } ); @@ -72,8 +72,7 @@ const SettingClash = ({ onError }: Props) => { // get clash core version const [clashVer, setClashVer] = useState(""); useEffect(() => { - getVersion().then((res) => { - const { premium, version } = res; + getVersion().then(({ premium, version }) => { setClashVer(premium ? `${version} Premium` : version); }); }, []);