2026-05-08 11:00:11 +08:00
|
|
|
|
import React, { useState } from 'react';
|
|
|
|
|
|
import {
|
2026-08-10 14:51:11 +08:00
|
|
|
|
Input, Button, Table, message, Space, Tabs, Card,
|
|
|
|
|
|
Typography
|
2026-05-08 11:00:11 +08:00
|
|
|
|
} from 'antd';
|
|
|
|
|
|
import { SearchOutlined, ReloadOutlined } from '@ant-design/icons';
|
2026-08-12 11:29:44 +08:00
|
|
|
|
import { useTranslation } from 'react-i18next';
|
2026-05-08 11:00:11 +08:00
|
|
|
|
|
|
|
|
|
|
const { Search } = Input;
|
|
|
|
|
|
const { TabPane } = Tabs;
|
|
|
|
|
|
|
|
|
|
|
|
const OnlineUserPage = () => {
|
2026-08-12 11:29:44 +08:00
|
|
|
|
const { t } = useTranslation();
|
2026-08-14 09:02:52 +08:00
|
|
|
|
// 模拟在线用户数据
|
|
|
|
|
|
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'
|
|
|
|
|
|
}
|
|
|
|
|
|
];
|
2026-05-08 11:00:11 +08:00
|
|
|
|
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);
|
2026-08-14 09:02:52 +08:00
|
|
|
|
message.success(t('systemSetting.fixed2SearchFixed2CompleteFixed2'));
|
2026-05-08 11:00:11 +08:00
|
|
|
|
}, 500);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 重置
|
|
|
|
|
|
const handleReset = () => {
|
|
|
|
|
|
setSearchParams({ loginAddress: '', userName: '' });
|
|
|
|
|
|
setDataSource(mockOnlineUsers);
|
2026-08-14 09:02:52 +08:00
|
|
|
|
message.info(t('systemSetting.resetFixed2Search'));
|
2026-05-08 11:00:11 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 强退用户
|
|
|
|
|
|
const handleForceLogout = (record) => {
|
2026-08-14 09:02:52 +08:00
|
|
|
|
message.info(t('systemSetting.forceLogoutSent', { sessionId: record.sessionId }));
|
2026-05-08 11:00:11 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 表格列配置
|
|
|
|
|
|
const columns = [
|
2026-08-14 09:02:52 +08:00
|
|
|
|
{ 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' },
|
2026-05-08 11:00:11 +08:00
|
|
|
|
{
|
2026-08-12 11:29:44 +08:00
|
|
|
|
title: t('roles.actions'), width: 100,
|
2026-05-08 11:00:11 +08:00
|
|
|
|
render: (_, record) => (
|
2026-08-14 09:02:52 +08:00
|
|
|
|
<Button type="link" onClick={() => handleForceLogout(record)} style={{ color: '#1890ff' }}>{t('systemSetting.s02')}</Button>
|
2026-05-08 11:00:11 +08:00
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
2026-05-15 15:39:28 +08:00
|
|
|
|
<div style={{ padding: "8px 0px", background: '#f5f7fa', minHeight: '100vh' }}>
|
2026-08-10 14:51:11 +08:00
|
|
|
|
<div style={{ padding: '0px 0px 8px' }}>
|
2026-08-14 09:02:52 +08:00
|
|
|
|
<Typography.Title level={4} style={{ margin: 0, fontSize: 'clamp(14px, 1.2vw, 18px)' }}>{t('systemSetting.s110')}</Typography.Title>
|
2026-08-10 14:51:11 +08:00
|
|
|
|
</div>
|
2026-05-08 11:00:11 +08:00
|
|
|
|
{/* ====================== 顶部 Tabs ====================== */}
|
|
|
|
|
|
<Tabs
|
|
|
|
|
|
activeKey={activeTab}
|
|
|
|
|
|
onChange={setActiveTab}
|
2026-05-15 15:39:28 +08:00
|
|
|
|
style={{ marginBottom: 0 }}
|
2026-05-08 11:00:11 +08:00
|
|
|
|
>
|
2026-08-12 11:29:44 +08:00
|
|
|
|
<TabPane tab={t('systemSetting.onlineUsers')} key="onlineUser" />
|
2026-08-14 09:02:52 +08:00
|
|
|
|
<TabPane tab={t('systemSetting.fixed2Others')} key="other" />
|
2026-05-08 11:00:11 +08:00
|
|
|
|
</Tabs>
|
|
|
|
|
|
|
|
|
|
|
|
{/* ====================== Tab 1:在线用户 ====================== */}
|
|
|
|
|
|
{activeTab === 'onlineUser' && (
|
|
|
|
|
|
<Card bordered={false} style={{ borderRadius: 8 }}>
|
|
|
|
|
|
{/* 搜索栏 */}
|
|
|
|
|
|
<div style={{ display: 'flex', alignItems: 'center', gap: 16, marginBottom: 20 }}>
|
|
|
|
|
|
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
2026-08-14 09:02:52 +08:00
|
|
|
|
<span>{t('systemSetting.fixed2LoginFixed2Fixed2')}</span>
|
2026-05-08 11:00:11 +08:00
|
|
|
|
<Input
|
2026-08-14 09:02:52 +08:00
|
|
|
|
placeholder={t('systemSetting.fixed2PleaseEnterFixed2Login')}
|
2026-05-08 11:00:11 +08:00
|
|
|
|
value={searchParams.loginAddress}
|
|
|
|
|
|
onChange={(e) => setSearchParams({ ...searchParams, loginAddress: e.target.value })}
|
|
|
|
|
|
style={{ width: 200 }}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
2026-08-12 11:29:44 +08:00
|
|
|
|
<span>profile.username</span>
|
2026-05-08 11:00:11 +08:00
|
|
|
|
<Input
|
2026-08-14 09:02:52 +08:00
|
|
|
|
placeholder={t('systemSetting.fixed2PleaseEnterFixed2UsernameFixed2')}
|
2026-05-08 11:00:11 +08:00
|
|
|
|
value={searchParams.userName}
|
|
|
|
|
|
onChange={(e) => setSearchParams({ ...searchParams, userName: e.target.value })}
|
|
|
|
|
|
style={{ width: 200 }}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
2026-08-14 09:02:52 +08:00
|
|
|
|
<Button type="primary" icon={<SearchOutlined />} onClick={handleSearch} loading={loading}>{t('common.search')}</Button>
|
|
|
|
|
|
<Button icon={<ReloadOutlined />} onClick={handleReset}>{t('common.reset')}</Button>
|
2026-05-08 11:00:11 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
{/* 在线用户表格 */}
|
|
|
|
|
|
<Table
|
|
|
|
|
|
rowKey="id"
|
|
|
|
|
|
columns={columns}
|
|
|
|
|
|
dataSource={dataSource}
|
|
|
|
|
|
loading={loading}
|
|
|
|
|
|
pagination={{
|
|
|
|
|
|
total: 2,
|
|
|
|
|
|
pageSize: 10,
|
|
|
|
|
|
showSizeChanger: true,
|
2026-08-14 09:02:52 +08:00
|
|
|
|
showTotal: (total) => `${t('common.total')} ${total} ${t('common.items')}`,
|
2026-05-08 11:00:11 +08:00
|
|
|
|
showQuickJumper: true
|
|
|
|
|
|
}}
|
|
|
|
|
|
bordered={false}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</Card>
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
|
|
{/* ====================== Tab 2:其他页面(你可以随便改内容) ====================== */}
|
|
|
|
|
|
{activeTab === 'other' && (
|
|
|
|
|
|
<Card bordered={false} style={{ borderRadius: 8, padding: '40px 0', textAlign: 'center' }}>
|
2026-08-14 09:02:52 +08:00
|
|
|
|
<h2>{t('systemSetting.fixed2OthersContentFixed2')}</h2>
|
|
|
|
|
|
<p>{t('systemSetting.statusCpuContentFixed2')}</p>
|
2026-05-08 11:00:11 +08:00
|
|
|
|
</Card>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export default OnlineUserPage;
|