/* Copyright (C) 2025 QuantumNous This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . For commercial licensing, please contact support@quantumnous.com */ // 进入 WeyAi 的过渡画面。授权页在三个瞬态里没有任何可操作内容:拉授权信息、 // 静默签发、授权完成等浏览器跳走。原来这三态套在登录卡片里只放一个 Spin, // 而登录页背景主题是按需懒加载的 chunk,这个页面通常在 chunk 到达前就跳走了, // 用户看到的是"空白底 + 小转圈"。这里改为:同步渲染的 token 派生背景 // (PageBackground,随主题预设与亮暗自动变化)+ 品牌环形加载动画 + 三步 // 真实进度(按 phase 推进,不是假进度条)。 // // 跳转卡住的兜底:授权完成后浏览器应当立刻跳走,若数秒后还停在这里(弹窗 // 拦截、location.replace 被扩展拦下),显示手动入口,用户不至于干等。手动 // 入口是**重新走一遍授权**(整页刷新),不是再打一次回跳地址:回跳地址里的 // code 只能核销一次,若第一次跳转其实已经到达网关只是慢,再打一次会让网关 // 拿着已核销的 code 报错,反而把本来会成功的登录弄坏。刷新会重新拉上下文、 // 静默签发新 code,无论第一次是没发出去还是发出去了都能收敛。 import React, { useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { Check } from 'lucide-react'; import PageBackground from '../../components/common/PageBackground'; import './WeyAiHandoff.css'; // 授权完成后等多久还没跳走就露出手动入口。网关换 token 正常在 1 秒内, // 8 秒仍未离开这一页基本可以断定跳转没发出去 const MANUAL_RETRY_DELAY_MS = 8000; export const HANDOFF_STAGE_LOADING = 0; export const HANDOFF_STAGE_ISSUING = 1; export const HANDOFF_STAGE_REDIRECT = 2; export default function WeyAiHandoff({ logo, stage, title, subtitle, clientName = 'WeyAi', }) { const { t } = useTranslation(); const [showManual, setShowManual] = useState(false); useEffect(() => { if (stage !== HANDOFF_STAGE_REDIRECT) { setShowManual(false); return undefined; } const timer = setTimeout(() => setShowManual(true), MANUAL_RETRY_DELAY_MS); return () => clearTimeout(timer); }, [stage]); const steps = [ t('验证账号'), t('建立安全会话'), t('打开 {{name}}', { name: clientName }), ]; return (
{/* 居中光晕:把视线聚到徽标上,颜色随品牌色 */} ); }