Ant Design Pro项目打开页设为登录或者其他页面

Ant Design Pro项目打开页设为登录或者其他页面

一、打开页设为登录页

首先找到utils包中的authority文件,在该文件中找到如下代码:

export function getAuthority(str) {
  // return localStorage.getItem('antd-pro-authority') || ['admin', 'user'];
  const authorityString =
    typeof str === 'undefined' ? localStorage.getItem('antd-pro-authority') : str;
  // authorityString could be admin, "admin", ["admin"]
  let authority;
  try {
    authority = JSON.parse(authorityString);
  } catch (e) {
    authority = authorityString;
  }
  if (typeof authority === 'string') {
    return [authority];
  }
  return authority || ['admin'];
}

将第二行的注释取消,那么打开页就是登录页了,这是权限问题。

二、打开页设为其他页

在我们进行网页设计的时候,可能没有后端的提供,这时要想使用ant design pro项目。我们需要跳过登录步骤,直接进到其他页面进行静态的设计,这时可以直接在最后一行改为:

这里的意思是直接返回类型为admin的用户,这样就可以跳过登录了。

原文地址:https://www.cnblogs.com/tian874540961/p/10253983.html