/** * @see https://umijs.org/zh-CN/plugins/plugin-access * */ export default function access(initialState: { currentUser?: API.CurrentUser | undefined }) { const { currentUser, roles = [] } = initialState || {} return { authRouteFilter: route => { if (currentUser?.isAdmin) { return true } return roles.includes(route.name) } } }