import { ElMessage } from "element-plus";

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