mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-02-12 11:43:36 +08:00
增加了管理员登录记录
This commit is contained in:
@@ -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'
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user