import React, { useEffect, useState, useRef } from 'react';
import { useParams, useSearchParams,useNavigate } from 'react-router-dom';
import ProviderApp from '@/provider/app';

import Link from '@/components/Link';
const Page = () => {
  const navigate= useNavigate();
  const [search] = useSearchParams();
  const providerApp = ProviderApp.useContainer();

  const kssoLogin=async ()=>{
    let code = search.get('code');
    if(code){
      //ksso auth登录
      const req = await providerApp.login(code);
      if(req){
        navigate('/');//回到首页
      }
    }
  }
  useEffect(kssoLogin,[])
  return (
    <div>
      <p>您未登录，当前是登录页</p>
      <Link href={'/'}>点击返回首页</Link>
    </div>
  )
}

export default Page;