authority.js 618 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
  let authority = localStorage.getItem('antd-pro-authority');
  if (authority) {
    if (authority.includes('[')) {
      authority = JSON.parse(authority);
    } else {
9
      authority = [JSON.parse(authority)];
10 11 12 13 14
    }
  } 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
}