Files
monkey-ai-web/src/components/auth/AuthLoginTabs.jsx
T

73 lines
2.7 KiB
React

/*
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 <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import { Button } from 'antd';
import { useNavigate } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
/**
* 认证页「个人 / 企业」分段切换控件(登录与注册两种模式)。
* 跨页跳转:mode='login' 在 /login 与 /org/login 间切换;
* mode='register' 在 /register 与 /org/register 间切换。四页共用,保持对称的信息架构。
* active:当前页归属('personal' | 'enterprise'),高亮且不重复跳转。
*
* 浮于玻璃卡片之外、之上:自带玻璃壳(backdrop-blur + 半透白底 + ring/border),
* 在背景上保持可读并与下方卡片呼应;激活态沿用 Ant Design 主题主色。
*/
const AuthLoginTabs = ({ active = 'personal', mode = 'login' }) => {
const { t } = useTranslation();
const navigate = useNavigate();
// 企业入口置于左侧首位:本产品主推企业用户,企业登录/注册是默认入口
const tabs =
mode === 'register'
? [
{ key: 'enterprise', label: t('企业注册'), to: '/org/register' },
{ key: 'personal', label: t('个人注册'), to: '/register' },
]
: [
{ key: 'enterprise', label: t('企业登录'), to: '/org/login' },
{ key: 'personal', label: t('个人登录'), to: '/login' },
];
return (
<div className='auth-login-tabs relative z-20 flex p-1 gap-1 rounded-xl backdrop-blur-2xl bg-white/45 dark:bg-neutral-900/55 ring-1 ring-white/50 dark:ring-white/[0.06] border border-white/30 dark:border-white/[0.05]'>
{tabs.map((tab) => {
const isActive = tab.key === active;
return (
<Button
key={tab.key}
type={isActive ? 'primary' : 'text'}
aria-pressed={isActive}
onClick={() => {
if (!isActive) navigate(tab.to);
}}
className='flex-1 font-medium'
>
{tab.label}
</Button>
);
})}
</div>
);
};
export default AuthLoginTabs;