fix: correct address display error caused by async system proxy retrieval

This commit is contained in:
wonfen
2025-06-22 23:19:11 +08:00
parent bdfc383a18
commit fee08f3826
3 changed files with 113 additions and 31 deletions

View File

@@ -17,7 +17,7 @@ const formatUptime = (uptimeMs: number) => {
export const ClashInfoCard = () => {
const { t } = useTranslation();
const { version: clashVersion } = useClash();
const { clashConfig, sysproxy, rules, uptime } = useAppData();
const { clashConfig, rules, uptime, systemProxyAddress } = useAppData();
// 使用useMemo缓存格式化后的uptime避免频繁计算
const formattedUptime = useMemo(() => formatUptime(uptime), [uptime]);
@@ -42,7 +42,7 @@ export const ClashInfoCard = () => {
{t("System Proxy Address")}
</Typography>
<Typography variant="body2" fontWeight="medium">
{sysproxy?.server || "-"}
{systemProxyAddress}
</Typography>
</Stack>
<Divider />
@@ -74,7 +74,14 @@ export const ClashInfoCard = () => {
</Stack>
</Stack>
);
}, [clashConfig, clashVersion, t, formattedUptime, rules.length, sysproxy]);
}, [
clashConfig,
clashVersion,
t,
formattedUptime,
rules.length,
systemProxyAddress,
]);
return (
<EnhancedCard