fix: 修改路由筛选

This commit is contained in:
Shu Guang 2025-05-17 02:59:55 +08:00
parent 55c472b840
commit adcad7769e
2 changed files with 4 additions and 3 deletions

View File

@ -5,7 +5,7 @@ export default [
]},
{path:"/", redirect: "/home"},
{ path: '/home', name :"首页", icon: "PieChartOutlined", component: './HomePage' },
{ path: '/home', name :"首页", icon: "PieChartOutlined", component: './HomePage',access: 'canAdmin', },
{ path: '/add_chart', name :"智能分析", icon: "barChart", component: './AddChart' },
{ path: '/add_async', name: "异步分析", icon: "DotChartOutlined", component: './AddChartAsync' },
{ path: '/my_chart', name: "我的图表", icon: "PictureOutlined", component: './MyChart' },
@ -29,7 +29,7 @@ export default [
path: '/admin',
name: '后台管理',
icon: 'crown',
// access: 'canAdmin',
access: 'canAdmin',
routes: [
{ path: '/admin', redirect: '/admin/sub-page' },
{ path: '/admin/sub-page', name: '论坛管理', component: './Admin' },

View File

@ -5,7 +5,8 @@
* */
export default function access(initialState: { currentUser?: API.CurrentUser } | undefined) {
const { currentUser } = initialState ?? {};
console.log('currentUser',currentUser)
return {
canAdmin: currentUser && currentUser.access === 'admin',
canAdmin: currentUser && currentUser.userRole === 'admin',
};
}