access.ts 669 B

12345678910111213141516171819
  1. /**
  2. * @see https://umijs.org/docs/max/access#access
  3. * */
  4. export default function access(initialState: { menuType: "distributor" | "miniApp",selectApp:{id:number} }) {
  5. return {
  6. isShow: (route: { name: string; }) => {
  7. if(initialState?.menuType){
  8. const { menuType } = initialState;
  9. let regex = new RegExp(`^${menuType}\\.`);
  10. // //与2取余为0时设为小说
  11. // if(initialState.selectApp.id % 2 === 0 && route.name.match(/(\.long$)|(\.short$)/)){
  12. // return route.name.match(/\.long$/)
  13. // }
  14. return route.name.match(regex)
  15. }
  16. return false
  17. },//路由名称包含menuType才显示
  18. };
  19. }