import { ElMessage } from "element-plus";

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