import React, { useState } from 'react'; import { Input, Button, Table, message, Space, Tabs, Card, Typography } from 'antd'; import { SearchOutlined, ReloadOutlined } from '@ant-design/icons'; import { useTranslation } from 'react-i18next'; const { Search } = Input; const { TabPane } = Tabs; const OnlineUserPage = () => { const { t } = useTranslation(); // 模拟在线用户数据 const mockOnlineUsers = [ { id: 1, sessionId: 'c85c6fe7-2e70-47...', loginName: 'admin', dept: t('systemSetting.deptRnd'), host: '127.0.0.1', location: t('systemSetting.intranetIp'), os: 'Linux', browser: 'Firefox 136.0', loginTime: '2026-05-08 09:46:08' }, { id: 2, sessionId: '9f6c7d73-f684-4e...', loginName: 'admin', dept: t('systemSetting.deptRnd'), host: '127.0.0.1', location: t('systemSetting.intranetIp'), os: 'Windows >=10', browser: 'Edge 147', loginTime: '2026-05-08 10:11:27' } ]; const [activeTab, setActiveTab] = useState('onlineUser'); // 默认选中在线用户 const [loading, setLoading] = useState(false); const [dataSource, setDataSource] = useState(mockOnlineUsers); const [searchParams, setSearchParams] = useState({ loginAddress: '', userName: '' }); // 搜索 const handleSearch = () => { setLoading(true); // 模拟接口请求 setTimeout(() => { setLoading(false); message.success(t('systemSetting.fixed2SearchFixed2CompleteFixed2')); }, 500); }; // 重置 const handleReset = () => { setSearchParams({ loginAddress: '', userName: '' }); setDataSource(mockOnlineUsers); message.info(t('systemSetting.resetFixed2Search')); }; // 强退用户 const handleForceLogout = (record) => { message.info(t('systemSetting.forceLogoutSent', { sessionId: record.sessionId })); }; // 表格列配置 const columns = [ { title: t('systemSetting.s122'), dataIndex: 'id', width: 60 }, { title: t('systemSetting.s132'), dataIndex: 'sessionId', ellipsis: true }, { title: t('systemSetting.fixed2LoginFixed2NameFixed2'), dataIndex: 'loginName' }, { title: t('systemSetting.s152'), dataIndex: 'dept' }, { title: t('systemSetting.s162'), dataIndex: 'host' }, { title: t('systemSetting.fixed2Login'), dataIndex: 'location' }, { title: t('systemSetting.fixed2Actions'), dataIndex: 'os' }, { title: t('systemSetting.s192'), dataIndex: 'browser' }, { title: t('systemSetting.fixed2LoginFixed2TimeFixed2'), dataIndex: 'loginTime' }, { title: t('roles.actions'), width: 100, render: (_, record) => ( ) } ]; return (
{t('systemSetting.s110')}
{/* ====================== 顶部 Tabs ====================== */} {/* ====================== Tab 1:在线用户 ====================== */} {activeTab === 'onlineUser' && ( {/* 搜索栏 */}
{t('systemSetting.fixed2LoginFixed2Fixed2')} setSearchParams({ ...searchParams, loginAddress: e.target.value })} style={{ width: 200 }} />
profile.username setSearchParams({ ...searchParams, userName: e.target.value })} style={{ width: 200 }} />
{/* 在线用户表格 */} `${t('common.total')} ${total} ${t('common.items')}`, showQuickJumper: true }} bordered={false} /> )} {/* ====================== Tab 2:其他页面(你可以随便改内容) ====================== */} {activeTab === 'other' && (

{t('systemSetting.fixed2OthersContentFixed2')}

{t('systemSetting.statusCpuContentFixed2')}

)} ); }; export default OnlineUserPage;