<template>
  <div />
</template>

<script setup lang="ts">
import { onBeforeMount } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { verityCidWebTokenApi } from '@/api/project/dataManager';

// 跳转白名单
const whitePageList = ['/yian/data/overview', '/yian/data/analysis'];
const route = useRoute();
const router = useRouter();

onBeforeMount(() => {
  goPageFun();
});

const goPageFun = () => {
  const { token = '' as any, redirectUrl = '' as any } = route.query;
  if (redirectUrl && whitePageList.includes(redirectUrl)) {
    const tokenData = token || localStorage.getItem('TOKEN');
    localStorage.setItem('TOKEN', tokenData);
    localStorage.setItem('USER_ID', '1999363561237610497');
    localStorage.setItem('TENANT_ID', '1999362907622948866');
    const path: any = redirectUrl;
    const params = {
      token: tokenData,
      userId: '1999363561237610497',
      tenantId: '1999362907622948866',
    };
    verityCidWebTokenApi(params).then((res: any) => {
      if (res.code === 200) {
        router.push({
          path,
        });
      }
    });
  }
};
</script>
