// 登录的用户名
export const loginUserKey = 'login-user';
// 登录的密码
export const loginPasswordKey = 'login-password';
// 记住密码
export const rememberPasswordKey = 'login-remember-password';

export const getLocalStorageItem = (key: string, isObject: boolean = false) => {
  const jsonStr = localStorage.getItem(key);
  if (!isObject) {
    return jsonStr;
  }
  if (jsonStr) {
    try {
      return JSON.parse(jsonStr);
    } catch (error) {
      return undefined;
    }
  }
  return undefined;
};

export const setLocalStorageItem = (key: string, state?: any, isObject: boolean = false) => {
  if (state) {
    localStorage.setItem(key, isObject ? JSON.stringify(state) : state);
  }
};

export const removeLocalStorageItem = (key: string) => {
  localStorage.removeItem(key);
};
