mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-13 02:26:36 +08:00
chore: format
This commit is contained in:
@@ -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'),
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -96,7 +96,9 @@ export default function WafPage() {
|
||||
<div className='flex items-center justify-between gap-3'>
|
||||
<div className='flex items-center gap-2'>
|
||||
<Shield className='size-5 text-primary' />
|
||||
<h1 className='text-2xl font-semibold tracking-tight'>{t('title')}</h1>
|
||||
<h1 className='text-2xl font-semibold tracking-tight'>
|
||||
{t('title')}
|
||||
</h1>
|
||||
</div>
|
||||
<div className='flex items-center gap-2'>
|
||||
<Button
|
||||
@@ -137,10 +139,7 @@ export default function WafPage() {
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{loading ? (
|
||||
<LoadingStateWithBorder
|
||||
icon={Shield}
|
||||
description={t('loading')}
|
||||
/>
|
||||
<LoadingStateWithBorder icon={Shield} description={t('loading')} />
|
||||
) : error ? (
|
||||
<div className='p-8 border border-dashed rounded-lg'>
|
||||
<ErrorInline
|
||||
@@ -150,10 +149,7 @@ export default function WafPage() {
|
||||
/>
|
||||
</div>
|
||||
) : groups.length === 0 ? (
|
||||
<EmptyStateWithBorder
|
||||
icon={Shield}
|
||||
description={t('empty')}
|
||||
/>
|
||||
<EmptyStateWithBorder icon={Shield} description={t('empty')} />
|
||||
) : (
|
||||
<RuleGroupsTable
|
||||
groups={groups}
|
||||
|
||||
@@ -305,9 +305,7 @@ function EditorContent() {
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>{t('leaveTitle')}</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{t('leaveDesc')}
|
||||
</AlertDialogDescription>
|
||||
<AlertDialogDescription>{t('leaveDesc')}</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>{tCommon('cancel')}</AlertDialogCancel>
|
||||
|
||||
Reference in New Issue
Block a user