pay-admin/src/pages/tabs-demo.tsx
2025-07-25 16:42:54 +08:00

243 lines
7.4 KiB
TypeScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import React from 'react';
import { Button, Card, Space, Divider, Row, Col, Statistic, Alert } from 'antd';
import {
PlusOutlined,
UserOutlined,
SettingOutlined,
HomeOutlined,
FileTextOutlined,
TeamOutlined
} from '@ant-design/icons';
import { MyPageContainer, usePageTabs } from '@/common';
import { history } from '@umijs/max';
/**
* 多标签页功能演示页面
* 展示完整的标签页管理功能
*/
export default function TabsDemo() {
const tabsApi = usePageTabs({
tabKey: 'tabs-demo',
tabLabel: '标签页演示',
closable: false // 演示页面不可关闭
});
// 模拟打开不同的页面标签
const openTab = (key: string, label: string, path: string) => {
tabsApi.addTab({
key,
label,
path,
closable: true
});
// 注意:在实际项目中,这里应该使用 history.push(path)
// 由于这是演示,我们只是添加标签而不实际跳转
console.log(`模拟跳转到: ${path}`);
};
const demoTabs = [
{
key: 'employees',
label: '员工管理',
path: '/employees',
icon: <TeamOutlined />,
description: '管理公司员工信息'
},
{
key: 'companies',
label: '公司管理',
path: '/company/companies',
icon: <HomeOutlined />,
description: '管理公司基本信息'
},
{
key: 'house-bills',
label: '房屋账单',
path: '/house_bills',
icon: <FileTextOutlined />,
description: '查看和管理房屋账单'
},
{
key: 'system-admins',
label: '系统管理员',
path: '/system/admins',
icon: <UserOutlined />,
description: '管理系统管理员账户'
},
{
key: 'system-roles',
label: '角色管理',
path: '/system/sys_roles',
icon: <SettingOutlined />,
description: '管理系统角色权限'
}
];
return (
<MyPageContainer
enableTabs
tabKey="tabs-demo"
tabLabel="标签页演示"
title="多标签页功能演示"
>
<Alert
message="多标签页功能演示"
description="这个页面展示了 MyPageContainer 的多标签页功能。您可以点击下方按钮打开新的标签页,然后右键点击标签体验各种操作。"
type="info"
showIcon
style={{ marginBottom: 24 }}
/>
{/* 统计信息 */}
<Row gutter={16} style={{ marginBottom: 24 }}>
<Col span={6}>
<Card>
<Statistic
title="当前标签数量"
value={tabsApi.getTabs().length}
prefix={<FileTextOutlined />}
/>
</Card>
</Col>
<Col span={6}>
<Card>
<Statistic
title="激活标签"
value={tabsApi.getActiveKey()}
valueStyle={{ fontSize: '16px' }}
/>
</Card>
</Col>
<Col span={6}>
<Card>
<Statistic
title="可用操作"
value={6}
suffix="种"
prefix={<SettingOutlined />}
/>
</Card>
</Col>
<Col span={6}>
<Card>
<Statistic
title="演示页面"
value={demoTabs.length}
suffix="个"
prefix={<PlusOutlined />}
/>
</Card>
</Col>
</Row>
{/* 快速打开标签页 */}
<Card title="🚀 快速打开页面" style={{ marginBottom: 24 }}>
<Row gutter={[16, 16]}>
{demoTabs.map(tab => (
<Col span={8} key={tab.key}>
<Card
size="small"
hoverable
onClick={() => openTab(tab.key, tab.label, tab.path)}
style={{ cursor: 'pointer', textAlign: 'center' }}
>
<div style={{ fontSize: '24px', marginBottom: '8px' }}>
{tab.icon}
</div>
<div style={{ fontWeight: 'bold', marginBottom: '4px' }}>
{tab.label}
</div>
<div style={{ fontSize: '12px', color: '#666' }}>
{tab.description}
</div>
</Card>
</Col>
))}
</Row>
</Card>
{/* 标签页操作 */}
<Card title="🎛️ 标签页操作" style={{ marginBottom: 24 }}>
<Space wrap size="middle">
<Button
type="primary"
onClick={() => tabsApi.closeOtherTabs()}
disabled={tabsApi.getTabs().length <= 1}
>
</Button>
<Button
onClick={() => tabsApi.closeLeftTabs()}
disabled={tabsApi.getTabs().length <= 1}
>
</Button>
<Button
onClick={() => tabsApi.closeRightTabs()}
disabled={tabsApi.getTabs().length <= 1}
>
</Button>
<Button
onClick={() => tabsApi.refreshTab()}
>
</Button>
<Button
danger
onClick={() => {
const tabs = tabsApi.getTabs();
const closableTabs = tabs.filter(tab => tab.closable);
closableTabs.forEach(tab => tabsApi.removeTab(tab.key));
}}
disabled={tabsApi.getTabs().filter(tab => tab.closable).length === 0}
>
</Button>
</Space>
</Card>
{/* 功能说明 */}
<Card title="📖 功能说明">
<Row gutter={24}>
<Col span={12}>
<h4>🎯 </h4>
<ul style={{ lineHeight: '1.8' }}>
<li><strong></strong></li>
<li><strong></strong></li>
<li><strong></strong></li>
<li><strong></strong></li>
<li><strong></strong></li>
</ul>
</Col>
<Col span={12}>
<h4>🖱 </h4>
<ul style={{ lineHeight: '1.8' }}>
<li><strong></strong></li>
<li><strong></strong></li>
<li><strong></strong></li>
<li><strong></strong></li>
<li><strong></strong></li>
</ul>
</Col>
</Row>
<Divider />
<h4>💡 使</h4>
<ul style={{ lineHeight: '1.8' }}>
<li></li>
<li></li>
<li>使</li>
<li></li>
<li></li>
</ul>
</Card>
</MyPageContainer>
);
}