中英文切换

This commit is contained in:
mmc
2026-08-14 09:02:52 +08:00
parent a8af55a856
commit 62b03bba03
94 changed files with 19723 additions and 2766 deletions

View File

@@ -9,34 +9,33 @@ import { useTranslation } from 'react-i18next';
const { Search } = Input;
const { TabPane } = Tabs;
// 模拟在线用户数据
const mockOnlineUsers = [
{
id: 1,
sessionId: 'c85c6fe7-2e70-47...',
loginName: 'admin',
dept: '研发部门',
host: '127.0.0.1',
location: '内网IP',
os: 'Linux',
browser: 'Firefox 136.0',
loginTime: '2026-05-08 09:46:08'
},
{
id: 2,
sessionId: '9f6c7d73-f684-4e...',
loginName: 'admin',
dept: '研发部门',
host: '127.0.0.1',
location: '内网IP',
os: 'Windows >=10',
browser: 'Edge 147',
loginTime: '2026-05-08 10:11:27'
}
];
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);
@@ -51,7 +50,7 @@ const OnlineUserPage = () => {
// 模拟接口请求
setTimeout(() => {
setLoading(false);
message.success('搜索完成');
message.success(t('systemSetting.fixed2SearchFixed2CompleteFixed2'));
}, 500);
};
@@ -59,31 +58,29 @@ const OnlineUserPage = () => {
const handleReset = () => {
setSearchParams({ loginAddress: '', userName: '' });
setDataSource(mockOnlineUsers);
message.info('已重置搜索条件');
message.info(t('systemSetting.resetFixed2Search'));
};
// 强退用户
const handleForceLogout = (record) => {
message.info(`已向会话 ${record.sessionId} 发送强退指令`);
message.info(t('systemSetting.forceLogoutSent', { sessionId: record.sessionId }));
};
// 表格列配置
const columns = [
{ title: '序号', dataIndex: 'id', width: 60 },
{ title: '会话编号', dataIndex: 'sessionId', ellipsis: true },
{ title: '登录名称', dataIndex: 'loginName' },
{ title: '所属部门', dataIndex: 'dept' },
{ title: '主机', dataIndex: 'host' },
{ title: '登录地点', dataIndex: 'location' },
{ title: '操作系统', dataIndex: 'os' },
{ title: '浏览器', dataIndex: 'browser' },
{ title: '登录时间', dataIndex: 'loginTime' },
{ 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) => (
<Button type="link" onClick={() => handleForceLogout(record)} style={{ color: '#1890ff' }}>
强退
</Button>
<Button type="link" onClick={() => handleForceLogout(record)} style={{ color: '#1890ff' }}>{t('systemSetting.s02')}</Button>
)
}
];
@@ -91,7 +88,7 @@ const OnlineUserPage = () => {
return (
<div style={{ padding: "8px 0px", background: '#f5f7fa', minHeight: '100vh' }}>
<div style={{ padding: '0px 0px 8px' }}>
<Typography.Title level={4} style={{ margin: 0, fontSize: 'clamp(14px, 1.2vw, 18px)' }}>系统监控</Typography.Title>
<Typography.Title level={4} style={{ margin: 0, fontSize: 'clamp(14px, 1.2vw, 18px)' }}>{t('systemSetting.s110')}</Typography.Title>
</div>
{/* ====================== 顶部 Tabs ====================== */}
<Tabs
@@ -100,7 +97,7 @@ const OnlineUserPage = () => {
style={{ marginBottom: 0 }}
>
<TabPane tab={t('systemSetting.onlineUsers')} key="onlineUser" />
<TabPane tab="其他监控" key="other" />
<TabPane tab={t('systemSetting.fixed2Others')} key="other" />
</Tabs>
{/* ====================== Tab 1:在线用户 ====================== */}
@@ -109,9 +106,9 @@ const OnlineUserPage = () => {
{/* 搜索栏 */}
<div style={{ display: 'flex', alignItems: 'center', gap: 16, marginBottom: 20 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<span>登录地址</span>
<span>{t('systemSetting.fixed2LoginFixed2Fixed2')}</span>
<Input
placeholder="请输入登录地址"
placeholder={t('systemSetting.fixed2PleaseEnterFixed2Login')}
value={searchParams.loginAddress}
onChange={(e) => setSearchParams({ ...searchParams, loginAddress: e.target.value })}
style={{ width: 200 }}
@@ -120,18 +117,14 @@ const OnlineUserPage = () => {
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<span>profile.username</span>
<Input
placeholder="请输入用户名称"
placeholder={t('systemSetting.fixed2PleaseEnterFixed2UsernameFixed2')}
value={searchParams.userName}
onChange={(e) => setSearchParams({ ...searchParams, userName: e.target.value })}
style={{ width: 200 }}
/>
</div>
<Button type="primary" icon={<SearchOutlined />} onClick={handleSearch} loading={loading}>
搜索
</Button>
<Button icon={<ReloadOutlined />} onClick={handleReset}>
重置
</Button>
<Button type="primary" icon={<SearchOutlined />} onClick={handleSearch} loading={loading}>{t('common.search')}</Button>
<Button icon={<ReloadOutlined />} onClick={handleReset}>{t('common.reset')}</Button>
</div>
{/* 在线用户表格 */}
@@ -144,7 +137,7 @@ const OnlineUserPage = () => {
total: 2,
pageSize: 10,
showSizeChanger: true,
showTotal: (total) => `共 ${total} 条`,
showTotal: (total) => `${t('common.total')} ${total} ${t('common.items')}`,
showQuickJumper: true
}}
bordered={false}
@@ -155,8 +148,8 @@ const OnlineUserPage = () => {
{/* ====================== Tab 2:其他页面(你可以随便改内容) ====================== */}
{activeTab === 'other' && (
<Card bordered={false} style={{ borderRadius: 8, padding: '40px 0', textAlign: 'center' }}>
<h2>其他监控内容</h2>
<p>这里可以放服务状态、CPU监控、内存监控、接口监控等内容</p>
<h2>{t('systemSetting.fixed2OthersContentFixed2')}</h2>
<p>{t('systemSetting.statusCpuContentFixed2')}</p>
</Card>
)}
</div>