import { defineComponent, onMounted } from 'vue';
import zhCN from 'element-plus/lib/locale/lang/zh-cn';
import { RouterView, useRoute, useRouter } from 'vue-router';


export default defineComponent({
  name: 'App',
  setup() {
    const locale = zhCN;

    const route = useRoute();
    const router = useRouter();

    // console.log(route); // 第二步

    // onMounted(() => {
    //   console.log(route.query);
    //   var islogin = false;
    //   //判断url是否含有ticket
    //   if (route.query.ticket != undefined && route.query.ticket != null) {
    //     //存在ticket 根据ticket获取token 并保存清除ticket
    //     api_gettokenByTicket((route.query.ticket as string) ?? '').then(
    //       (res) => {
    //         window.localStorage.setItem('userdata', JSON.stringify(res.data));
    //         // let newQuery = JSON.parse(JSON.stringify(route.query)); // 深拷贝
    //         // delete newQuery.ticket;
    //         // router.replace({ query: newQuery });
    //       },
    //     );
    //     //ticket 失效直接跳过
    //   } else {
    //     let userinfojson = window.localStorage.getItem('userdata');
    //     if (userinfojson != undefined || userinfojson != null) {
    //       islogin = true;
    //     }
    //     if (!islogin) {
    //       // debugger;
    //       // window.location.href = LOGIN_URL;
    //     }
    //   }
    // });

    return () => (
      // <el-configProvider locale={locale}>
      <div>
        <RouterView />
      </div>

      //  </el-configProvider>
    );
  },
});
