/**
 * 设置token
 * */
import { isJSON } from '@/webPublic/one_stop_public/copy';

export const setToken = (value, time) => {
  localStorage.setItem('antd-pro-token-onestop', value);
  localStorage.setItem('antd-pro-token', value);
  localStorage.setItem('wisdom-school-token', value);
}

/**
 * 获取token
 * */
export const getToken = () => {
  const x = localStorage.getItem('antd-pro-token-onestop');
  if (x && x.length > 11) {
    return x;
  }
  const y = localStorage.getItem('antd-pro-token');
  if (y && y.length > 11) {
    return y;
  }

  return null;
};

/**
 * 删除token
 * */
export const delToken = () => {
  localStorage.removeItem('antd-pro-token-onestop');
  localStorage.removeItem('antd-pro-token');
  localStorage.removeItem('wisdom-school-token');
}

export const getUserInfo = () => {
  let x = localStorage.getItem('user');
  if(isJSON(x)){
    x = JSON.parse(x);
    return x;
  }else{
    return {
      groupsId: 'pub',
    };
  }
}
