diff --git a/src/components/auth/authorizing.tsx b/src/components/auth/authorizing.tsx index 4312ee9..071f3af 100644 --- a/src/components/auth/authorizing.tsx +++ b/src/components/auth/authorizing.tsx @@ -1,6 +1,6 @@ "use client"; -import { useCallback, useEffect, useState } from "react"; +import { useEffect, useState } from "react"; import { useRouter } from "next/navigation"; import { getDiscourseSSOUrl } from "@/actions/discourse-sso-url"; @@ -13,36 +13,26 @@ interface AuthorizingProps { export function Authorizing({ searchParams }: AuthorizingProps) { const router = useRouter(); const [error, setError] = useState(null); - const [progress, setProgress] = useState(0); - - const signInCallback = useCallback(async () => { - try { - const url = await getDiscourseSSOUrl( - new URLSearchParams(searchParams).toString(), - ); - router.push(url); - } catch (error) { - setError(error); - } - }, [searchParams, router]); useEffect(() => { - // 启动进度条动画 - const progressTimer = setInterval(() => { - setProgress((prev) => Math.min(prev + 10, 90)); - }, 500); - // 立即开始授权 - signInCallback(); - - return () => { - clearInterval(progressTimer); + const doAuth = async () => { + try { + const url = await getDiscourseSSOUrl( + new URLSearchParams(searchParams).toString(), + ); + router.push(url); + } catch (error) { + setError(error); + } }; - }, [signInCallback]); - return ( -
- {error ? ( + doAuth(); + }, [searchParams, router]); + + if (error) { + return ( +
- ) : ( -
-
-
-
-

正在授权

-

获取授权信息中,请稍等...

-
-
-
-

系统正在处理您的请求

+
+ ); + } + + return ( +
+
+
+
- )} +

正在授权

+

请稍候...

+
); }