<template>
  <h3 />
</template>

<script setup>
import Common from '../common/Common';
import { useRouter } from 'vue-router';
import { ref, onMounted,getCurrentInstance } from 'vue';
import TokenClientResource from '../api/base/TokenClientResource';

const router = useRouter();
const { proxy } = getCurrentInstance();

const redirectUrl = ref('');

onMounted(() => {
  const href = window.location.href;
  const url = href.split('redirectUrl=')[1];
  if (url) {
    redirectUrl.value = decodeURIComponent(url);
  }
  getVerification();
});

const getVerification = () => {
  TokenClientResource.getVerificationMethod().then(
    successData => {
      if (successData.errorCode === 0) {
        if(successData.data === 'graphic') {
          if(redirectUrl.value) {
            router.push('/loginGraphic?redirectUrl=' + redirectUrl.value);
          } else {
            router.push('/loginGraphic');
          }
        } else{
          if(redirectUrl.value) {
            router.push('/loginNode?redirectUrl=' + redirectUrl.value);
          } else {
            router.push('/loginNode');
          }
        }
      } else {
        Notify.error(proxy.$t('lang.Notify.fail'), successData.errorMessage);
      }
    }, error => {
      Common.processException(error);
    });
};

</script>

<style scoped></style>