diff --git a/app/success/page.jsx b/app/success/page.jsx index 8151b25..ceef2bb 100644 --- a/app/success/page.jsx +++ b/app/success/page.jsx @@ -1,11 +1,27 @@ "use client"; -import { useEffect, useState } from "react"; +import { useEffect, useState, Suspense } from "react"; import { FiArrowLeft, FiCheckCircle } from "react-icons/fi"; import toast from "react-hot-toast"; +import { useSearchParams } from "next/navigation"; -export default function SuccessPage() { +// 创建一个客户端组件来处理搜索参数 +function SuccessContent() { const [closeAttempted, setCloseAttempted] = useState(false); + const searchParams = useSearchParams(); + const redirectUrl = searchParams.get("redirect_url"); + + // 处理重定向 + useEffect(() => { + if (redirectUrl) { + // 添加一个小延迟,让成功动画有时间显示 + const redirectTimer = setTimeout(() => { + window.location.href = redirectUrl; + }, 1500); + + return () => clearTimeout(redirectTimer); + } + }, [redirectUrl]); // 页面加载时的动画效果 useEffect(() => { @@ -22,6 +38,12 @@ export default function SuccessPage() { // 尝试关闭页面 const handleClose = () => { + // 如果有重定向URL,直接跳转 + if (redirectUrl) { + window.location.href = redirectUrl; + return; + } + try { window.close(); @@ -49,36 +71,47 @@ export default function SuccessPage() { } }; + return ( +
+ {redirectUrl ? "即将返回应用..." : "请关闭当前页面返回应用"} +
+ + +- 请关闭当前页面返回应用 -
- - -