feat: 完成券商和用户管理
This commit is contained in:
155
apps/web/src/layouts/menuConfig.tsx
Normal file
155
apps/web/src/layouts/menuConfig.tsx
Normal file
@@ -0,0 +1,155 @@
|
||||
import {
|
||||
BarChartOutlined,
|
||||
FileTextOutlined,
|
||||
EditOutlined,
|
||||
SettingOutlined,
|
||||
DashboardOutlined,
|
||||
BankOutlined,
|
||||
UserOutlined,
|
||||
} from '@ant-design/icons';
|
||||
import type { ReactNode } from 'react';
|
||||
|
||||
/**
|
||||
* 路由菜单配置项
|
||||
*/
|
||||
export interface RouteMenuConfig {
|
||||
/** 路由路径 */
|
||||
path: string;
|
||||
/** 菜单键值(通常与 path 相同) */
|
||||
key: string;
|
||||
/** 菜单图标 */
|
||||
icon: ReactNode;
|
||||
/** 菜单标签 */
|
||||
label: string;
|
||||
/** 页面标题 */
|
||||
title: string;
|
||||
/** 页面副标题 */
|
||||
subtitle: string;
|
||||
/** 菜单分组:'main' 主要功能,'admin' 管理员功能 */
|
||||
group: 'main' | 'admin';
|
||||
/** 是否需要管理员权限 */
|
||||
requireAdmin?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 路由菜单配置列表
|
||||
*/
|
||||
export const routeMenuConfig: RouteMenuConfig[] = [
|
||||
{
|
||||
path: '/assets',
|
||||
key: '/assets',
|
||||
icon: <BarChartOutlined />,
|
||||
label: '资产账户',
|
||||
title: '资产账户',
|
||||
subtitle: '买股票就是买公司',
|
||||
group: 'main',
|
||||
},
|
||||
{
|
||||
path: '/plans',
|
||||
key: '/plans',
|
||||
icon: <FileTextOutlined />,
|
||||
label: '交易计划',
|
||||
title: '交易计划',
|
||||
subtitle: '计划你的交易,交易你的计划',
|
||||
group: 'main',
|
||||
},
|
||||
{
|
||||
path: '/review',
|
||||
key: '/review',
|
||||
icon: <EditOutlined />,
|
||||
label: '投资复盘',
|
||||
title: '投资复盘',
|
||||
subtitle: '回顾过去是为了更好应对将来',
|
||||
group: 'main',
|
||||
},
|
||||
{
|
||||
path: '/user',
|
||||
key: '/user',
|
||||
icon: <UserOutlined />,
|
||||
label: '用户管理',
|
||||
title: '用户管理',
|
||||
subtitle: '管理用户信息',
|
||||
group: 'admin',
|
||||
requireAdmin: true,
|
||||
},
|
||||
{
|
||||
path: '/broker',
|
||||
key: '/broker',
|
||||
icon: <BankOutlined />,
|
||||
label: '券商管理',
|
||||
title: '券商管理',
|
||||
subtitle: '管理券商信息',
|
||||
group: 'admin',
|
||||
requireAdmin: true,
|
||||
},
|
||||
{
|
||||
path: '/seo',
|
||||
key: '/seo',
|
||||
icon: <SettingOutlined />,
|
||||
label: 'SEO配置',
|
||||
title: 'SEO配置',
|
||||
subtitle: '优化搜索引擎可见性',
|
||||
group: 'admin',
|
||||
requireAdmin: true,
|
||||
},
|
||||
{
|
||||
path: '/analytics',
|
||||
key: '/analytics',
|
||||
icon: <DashboardOutlined />,
|
||||
label: '数据统计',
|
||||
title: '数据统计',
|
||||
subtitle: '了解用户行为与系统数据',
|
||||
group: 'admin',
|
||||
requireAdmin: true,
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* 根据路径获取页面标题信息
|
||||
*/
|
||||
export const getPageInfo = (path: string): { title: string; subtitle: string } => {
|
||||
// 处理根路径
|
||||
if (path === '/' || path === '') {
|
||||
const defaultRoute = routeMenuConfig.find((item) => item.path === '/assets');
|
||||
return defaultRoute
|
||||
? { title: defaultRoute.title, subtitle: defaultRoute.subtitle }
|
||||
: { title: '资产账户', subtitle: '买股票就是买公司' };
|
||||
}
|
||||
|
||||
const config = routeMenuConfig.find((item) => item.path === path);
|
||||
return config
|
||||
? { title: config.title, subtitle: config.subtitle }
|
||||
: { title: '资产账户', subtitle: '买股票就是买公司' };
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取主要功能菜单项
|
||||
*/
|
||||
export const getMainMenuItems = () => {
|
||||
return routeMenuConfig.filter((item) => item.group === 'main');
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取管理员功能菜单项
|
||||
*/
|
||||
export const getAdminMenuItems = () => {
|
||||
return routeMenuConfig.filter((item) => item.group === 'admin' && item.requireAdmin);
|
||||
};
|
||||
|
||||
/**
|
||||
* 页面标题映射(用于向后兼容)
|
||||
*/
|
||||
export const pageTitles: Record<string, { title: string; subtitle: string }> = (() => {
|
||||
const titles: Record<string, { title: string; subtitle: string }> = {
|
||||
'/': getPageInfo('/assets'),
|
||||
};
|
||||
|
||||
routeMenuConfig.forEach((config) => {
|
||||
titles[config.path] = {
|
||||
title: config.title,
|
||||
subtitle: config.subtitle,
|
||||
};
|
||||
});
|
||||
|
||||
return titles;
|
||||
})();
|
||||
Reference in New Issue
Block a user