增加了管理员登录记录

This commit is contained in:
Monster
2025-07-16 19:24:07 +08:00
parent 44e35c42e6
commit 63e4c7f1f6
3 changed files with 24 additions and 19 deletions

View File

@@ -189,8 +189,11 @@ const AdminTable = () => {
{
title: '最近活跃时间',
dataIndex: 'last_active_at',
render: (text) => {
return text === 0 ? '从未使用' : dayjs.unix(text).fromNow();
render: (text, record) => {
return <Stack direction='column'>
<Box sx={{ color: 'text.secondary' }}>{record.created_at ? dayjs.unix(record.created_at).fromNow() + '加入' : '加入时间未知'}</Box>
<Box sx={{ color: 'text.secondary' }}>{record.last_active_at ? dayjs.unix(record.last_active_at).fromNow() + '活跃' : '活跃时间未知'}</Box>
</Stack>
},
},
{
@@ -212,14 +215,14 @@ const AdminTable = () => {
},
];
return (
<Card>
<Card sx={{ height: '100%' }}>
<Stack
direction='row'
justifyContent='space-between'
alignItems='center'
sx={{ mb: 2 }}
>
<Box sx={{ fontWeight: 700 }}></Box>
<Box sx={{ fontWeight: 700, lineHeight: '36px' }}></Box>
<Button
variant='contained'
color='primary'

View File

@@ -1,14 +1,18 @@
import React from 'react';
import LoginHistory from './loginHistory';
import AdminTable from './adminTable';
import { Stack } from '@mui/material';
import { Grid2 as Grid, Stack } from '@mui/material';
const Admin = () => {
return (
<Stack gap={2} sx={{ height: '100%' }}>
<AdminTable />
<LoginHistory />
</Stack>
<Grid container spacing={2} sx={{ height: '100%' }}>
<Grid size={6}>
<AdminTable />
</Grid>
<Grid size={6}>
<LoginHistory />
</Grid>
</Grid>
);
};

View File

@@ -23,17 +23,15 @@ const LoginHistory = () => {
},
},
{
title: 'IP 地址',
title: 'IP 地址',
dataIndex: 'ip',
render: (ip, record) => {
let address = '';
if (record?.ip_info) {
address = `${record?.ip_info?.country}-${record?.ip_info?.city}`;
}
return (
<Stack direction='row'>
<Box>{ip}</Box>
<Box sx={{ color: 'text.secondary' }}>{address}</Box>
<Stack direction='column'>
<Box>{record?.ip_info?.ip}</Box>
<Box sx={{ color: 'text.secondary' }}>
{record?.ip_info?.country === '中国' ? ('' + record?.ip_info?.province + '-' + record?.ip_info?.city) : (record?.ip_info?.country || '未知')}
</Box>
</Stack>
);
},
@@ -47,14 +45,14 @@ const LoginHistory = () => {
},
];
return (
<Card>
<Card sx={{ height: '100%' }}>
<Stack
direction='row'
justifyContent='space-between'
alignItems='center'
sx={{ mb: 2 }}
>
<Box sx={{ fontWeight: 700 }}></Box>
<Box sx={{ fontWeight: 700, lineHeight: '36px' }}></Box>
</Stack>
<Table
columns={columns}