authority.js 606 Bytes
Newer Older
ddcat1115's avatar
ddcat1115 committed
1 2
// use localStorage to store the authority info, which might be sent from server in actual project.
export function getAuthority() {
3
  // return localStorage.getItem('antd-pro-authority') || ['admin', 'user'];
4 5 6 7 8 9 10 11 12 13 14
  let authority = localStorage.getItem('antd-pro-authority');
  if (authority) {
    if (authority.includes('[')) {
      authority = JSON.parse(authority);
    } else {
      authority = [authority];
    }
  } else {
    authority = ['admin'];
  }
  return authority;
ddcat1115's avatar
ddcat1115 committed
15 16 17
}

export function setAuthority(authority) {
rongxingsun's avatar
rongxingsun committed
18
  return localStorage.setItem('antd-pro-authority', JSON.stringify(authority));
ddcat1115's avatar
ddcat1115 committed
19
}