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的用戶,這樣就可以跳過登錄了。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM