From f6e821ba6b2b8dae508744d4571b0d2c7dd45cf4 Mon Sep 17 00:00:00 2001 From: GyDi Date: Thu, 24 Feb 2022 23:04:18 +0800 Subject: [PATCH] feat: adjust clash version display --- src/components/setting/setting-clash.tsx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/components/setting/setting-clash.tsx b/src/components/setting/setting-clash.tsx index 610a23f..e0fa9f7 100644 --- a/src/components/setting/setting-clash.tsx +++ b/src/components/setting/setting-clash.tsx @@ -25,6 +25,7 @@ interface Props { const SettingClash = ({ onError }: Props) => { const { mutate } = useSWRConfig(); const { data: clashConfig } = useSWR("getClashConfig", getClashConfig); + const { data: versionData } = useSWR("getVersion", getVersion); const { ipv6 = false, @@ -70,12 +71,9 @@ const SettingClash = ({ onError }: Props) => { ); // get clash core version - const [clashVer, setClashVer] = useState(""); - useEffect(() => { - getVersion().then(({ premium, version }) => { - setClashVer(premium ? `${version} Premium` : version); - }); - }, []); + const clashVer = versionData?.premium + ? `${versionData.version} Premium` + : versionData?.version || "-"; return (