mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-01 22:46:38 +08:00
5a8722ff07
接入无 URL 前缀的 zh-CN/en,顶栏与外观设置可切换语言;选择写入 cookie 后刷新生效。
61 lines
1.6 KiB
TypeScript
61 lines
1.6 KiB
TypeScript
'use client';
|
|
|
|
import { useTranslations } from 'next-intl';
|
|
import { useState } from 'react';
|
|
|
|
import {
|
|
Dialog,
|
|
DialogContent,
|
|
DialogDescription,
|
|
DialogHeader,
|
|
DialogTitle,
|
|
} from '@/components/ui/dialog';
|
|
|
|
import { IpAnalysisPanel } from './ip-analysis-panel';
|
|
|
|
export function IpDetailDialog({
|
|
open,
|
|
remoteAddr,
|
|
region,
|
|
initialHours,
|
|
onOpenChange,
|
|
}: {
|
|
open: boolean;
|
|
remoteAddr: string | null;
|
|
region?: string;
|
|
initialHours?: number;
|
|
onOpenChange: (open: boolean) => void;
|
|
}) {
|
|
const [displayAddr, setDisplayAddr] = useState<string | null>(remoteAddr);
|
|
const [displayRegion, setDisplayRegion] = useState(region);
|
|
if (remoteAddr && remoteAddr !== displayAddr) {
|
|
setDisplayAddr(remoteAddr);
|
|
setDisplayRegion(region);
|
|
}
|
|
const t = useTranslations('accessLogs.ip');
|
|
const ip = remoteAddr ?? displayAddr ?? '';
|
|
|
|
return (
|
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
<DialogContent className='max-h-[90vh] sm:max-w-6xl md:max-w-6xl overflow-y-auto hide-scrollbar'>
|
|
<DialogHeader>
|
|
<DialogTitle>{t('dialogTitle')}</DialogTitle>
|
|
<DialogDescription>
|
|
<span className='font-mono text-foreground'>{ip || '—'}</span>
|
|
{displayRegion ? (
|
|
<span className='text-muted-foreground'> · {displayRegion}</span>
|
|
) : null}
|
|
{t('dialogDesc')}
|
|
</DialogDescription>
|
|
</DialogHeader>
|
|
<IpAnalysisPanel
|
|
key={ip}
|
|
ip={ip}
|
|
enabled={open && ip !== ''}
|
|
initialHours={initialHours}
|
|
/>
|
|
</DialogContent>
|
|
</Dialog>
|
|
);
|
|
}
|