diff --git a/config/routes.ts b/config/routes.ts index b7e65ad..50c6d7a 100644 --- a/config/routes.ts +++ b/config/routes.ts @@ -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' }, diff --git a/src/access.ts b/src/access.ts index ed09537..bd25557 100644 --- a/src/access.ts +++ b/src/access.ts @@ -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', }; }