<template></template>

<script setup>
import { ref, onMounted } from "vue";
import { useStore } from "vuex";
import { useRouter } from "vue-router";
import {
  setItem
} from "@/utils/storage";
const loginDialog = ref(false);
const deptList = ref([]);
const store = useStore();
function redirectAuth() {

  let token = location.hash.slice(20) || null;
  if (token != null) {
    debugger
    token = token.replace(/\ +/g, "");
    setItem("SSOTOKEN", token)
    handleLogin({ token: token});
  } else {
    window.location.href = `http://155.240.22.188:9020`;
  }
}

const handleLogin = (e) => {
  store.dispatch("user/oatuhLogin", e).then((res) => {
    // 登录后操作
    if (res.deptList.length === 1) {
      window.location.hash = "/";
    } else {
      deptList.value = [...res.deptList];
      loginDialog.value = true;
      authorization.value = res.jwtToken;
    }
  });
};
onMounted(() => {
  redirectAuth();
});
</script>

<<<<<<< HEAD
<style></style>
=======
<style></style>
>>>>>>> d55c698309e1775da715e035dd9e1b7d06e52a30
