mirror of
https://github.com/woodchen-ink/Q58Connect.git
synced 2025-07-18 05:51:55 +08:00
refactor: Consolidate OAuth authorization page and enhance parameter handling
This commit is contained in:
parent
32aaf27b2e
commit
a40234e6c8
6
src/app/(auth)/authorize/metadata.ts
Normal file
6
src/app/(auth)/authorize/metadata.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import { Metadata } from "next";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Auth – Q58论坛",
|
||||
description: "Sign in to your account",
|
||||
};
|
@ -1,6 +1,8 @@
|
||||
import { Suspense } from "react";
|
||||
import { Metadata } from "next";
|
||||
"use client";
|
||||
|
||||
import { useEffect } from "react";
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { MessageCircleCode } from "lucide-react";
|
||||
|
||||
import { UserAuthorize } from "@/components/auth/user-authorize";
|
||||
@ -9,12 +11,26 @@ type Props = {
|
||||
searchParams: { [key: string]: string | string[] | undefined };
|
||||
};
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: `Auth – Q58论坛`,
|
||||
description: "Sign in to your account",
|
||||
};
|
||||
|
||||
export default function AuthPage({ searchParams }: Props) {
|
||||
const router = useRouter();
|
||||
|
||||
useEffect(() => {
|
||||
// 检查是否有待处理的 OAuth 请求
|
||||
const pendingOAuth = localStorage.getItem("oauth_pending");
|
||||
if (pendingOAuth) {
|
||||
try {
|
||||
const params = JSON.parse(pendingOAuth);
|
||||
// 清除存储的 OAuth 参数
|
||||
localStorage.removeItem("oauth_pending");
|
||||
// 重定向到 OAuth 授权页面
|
||||
const searchParams = new URLSearchParams(params);
|
||||
router.push(`/oauth/authorize?${searchParams.toString()}`);
|
||||
} catch (error) {
|
||||
console.error("Failed to process OAuth params:", error);
|
||||
}
|
||||
}
|
||||
}, [router]);
|
||||
|
||||
return (
|
||||
<div className="mx-auto flex w-full flex-col justify-center space-y-6 sm:w-[350px]">
|
||||
<div className="flex flex-col space-y-2 text-center">
|
||||
@ -25,9 +41,7 @@ export default function AuthPage({ searchParams }: Props) {
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<Suspense>
|
||||
<UserAuthorize data={searchParams} />
|
||||
</Suspense>
|
||||
<UserAuthorize data={searchParams} />
|
||||
</div>
|
||||
<p className="px-8 text-center text-sm text-muted-foreground">
|
||||
By clicking continue, you agree to our{" "}
|
||||
|
@ -1,38 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
export default function AuthorizePage() {
|
||||
const router = useRouter();
|
||||
|
||||
useEffect(() => {
|
||||
// 检查是否有待处理的 OAuth 请求
|
||||
const pendingOAuth = localStorage.getItem("oauth_pending");
|
||||
if (pendingOAuth) {
|
||||
try {
|
||||
const params = JSON.parse(pendingOAuth);
|
||||
// 清除存储的 OAuth 参数
|
||||
localStorage.removeItem("oauth_pending");
|
||||
// 重定向到 OAuth 授权页面
|
||||
const searchParams = new URLSearchParams(params);
|
||||
router.push(`/oauth/authorize?${searchParams.toString()}`);
|
||||
} catch (error) {
|
||||
console.error("Failed to process OAuth params:", error);
|
||||
router.push("/dashboard");
|
||||
}
|
||||
} else {
|
||||
// 如果没有待处理的 OAuth 请求,直接进入仪表板
|
||||
router.push("/dashboard");
|
||||
}
|
||||
}, [router]);
|
||||
|
||||
return (
|
||||
<div className="flex min-h-screen items-center justify-center">
|
||||
<div className="text-center">
|
||||
<div className="mb-4 h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"></div>
|
||||
<p className="text-sm text-muted-foreground">正在处理...</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user