import { ElMessage } from "element-plus";

export function responseHandle({
  code,
  message,
  logout,
  hasError,
  handler,
  error
}: {
  code: number;
  message: string;
  logout: any;
  hasError?: Boolean;
  handler: () => void;
  error?: () => void;
}) {
  const c = Number(code);
  if (c === 0) {
    handler();
  } else if (c > 100 && c < 140) {
    logout();
  } else if (hasError) {
    error();
  } else {
    ElMessage.error(message);
  }
}
