import router from "../router";
import Vue from "vue";

export function logoutHandle() {
  const returnUrl = Vue.ls.get("returnUrl");
  if (returnUrl) {
    window.location.href = returnUrl;
    return;
  }

  Vue.ls.clear();
  const paramDomainCode = window.sessionStorage.getItem("paramDomainCode");
  const routeDomainCode = window.sessionStorage.getItem("routeDomainCode");
  if (paramDomainCode) {
    router.push({ name: "Login", query: { code: paramDomainCode } });
  } else if (routeDomainCode) {
    router.push({ name: "Login", params: { code: routeDomainCode } });
  } else {
    router.push({ name: "Login" });
  }
}
