chore: format

This commit is contained in:
ryan
2026-08-16 21:39:25 +08:00
parent e5d2e4b6d5
commit 55c1fcd5f9
93 changed files with 544 additions and 439 deletions
@@ -89,7 +89,9 @@ export function formatIPGroupBanRemaining(
(expireDate.getTime() - reference.getTime()) / (60 * 1000),
);
if (diffMins < 60) {
return t ? t('ban.minutesLater', { count: diffMins }) : `${diffMins} 分钟后`;
return t
? t('ban.minutesLater', { count: diffMins })
: `${diffMins} 分钟后`;
}
const hours = Math.round(diffMins / 60);
return t ? t('ban.hoursLater', { count: hours }) : `${hours} 小时后`;
@@ -105,7 +107,12 @@ export function getIPGroupViewEntries(
return group.ext_ips.map((item) => ({
ip: item.ip,
capturedAt: item.captured_at,
banRemaining: formatIPGroupBanRemaining(item.captured_at, ttl, undefined, t),
banRemaining: formatIPGroupBanRemaining(
item.captured_at,
ttl,
undefined,
t,
),
}));
}
return (group.ip_list ?? []).map((ip) => ({ ip }));
@@ -205,7 +205,11 @@ export function IPGroupDialog({
const tWaf = useTranslations('waf');
const tCommon = useTranslations('common');
const ipGroupSchema = useMemo(
() => createIPGroupSchema((key) => t(key), (key) => tWaf(key)),
() =>
createIPGroupSchema(
(key) => t(key),
(key) => tWaf(key),
),
[t, tWaf],
);
const form = useForm<IPGroupFormValues>({
@@ -226,8 +230,7 @@ export function IPGroupDialog({
onOpenChange(false);
} catch (error) {
form.setError('root', {
message:
error instanceof Error ? error.message : tWaf('saveFailed'),
message: error instanceof Error ? error.message : tWaf('saveFailed'),
});
}
});