import Cookies from 'js-cookie'

const TokenKey = 'exhibition_token'
const UserInfoKey = 'exhibition_userInfo'
const MenuKey = 'exhibition_menu'
const MenuAllKey = 'exhibition_menu_all'

export function getToken() {
  // return Cookies.get(TokenKey)
  return localStorage.getItem(TokenKey)
}

export function setToken(token) {
  return localStorage.setItem(TokenKey, token)
  // return Cookies.set(TokenKey, token)
}

export function removeToken() {
  // return Cookies.remove(TokenKey)
  localStorage.removeItem(TokenKey)
}

export function setUserInfo(userInfo) {
  return localStorage.setItem(UserInfoKey, JSON.stringify(userInfo))
}

export function getUserInfo() {
  return JSON.parse(localStorage.getItem(UserInfoKey))
}

export function removeUserInfo() {
  localStorage.removeItem(UserInfoKey)
}
// 不含有按钮权限的菜单
export function setLocalMenu(menu) {
  return localStorage.setItem(MenuKey, JSON.stringify(menu))
}


export function getLocalMenu() {
  return JSON.parse(localStorage.getItem(MenuKey))
}

export function removeLocalMenu() {
  localStorage.removeItem(MenuKey)
}

// 含有按钮权限的菜单
export function setLocalMenuAll(allMenus) {
  return localStorage.setItem(MenuAllKey, JSON.stringify(allMenus))
}


export function getLocalMenuAll() {
  return JSON.parse(localStorage.getItem(MenuAllKey))
}

export function removeLocalMenuAll() {
  localStorage.removeItem(MenuAllKey)
}
