Files
monkey-ai-web/src/components/auth/OrgCredentialResult.jsx
T
qiubaishen a57aae3043 sync: 同步 monkey-ai@weiyuan(ddc5b9443) 的 web/ 到 ui-optimization
- 合入 weiyuan 新功能前端:分佣 V2 / 伙伴工作台、智能路由、企业资金与分析、官网设置与预约演示等,
  semi-ui 已全部迁移到 antd 6 / @/components/ui,不重新引入 Semi
- 分佣二级菜单与页头去重、伙伴入口探测(企业伙伴走企业中心「企业分佣」)、超管侧栏入口恢复
- 适配层 DatePicker / TimePicker 统一 onChange(Date|Date[]|null, 文本) 契约;生产构建剔除调试日志
- 图片链接刷新:同任务请求复用、后台刷新不弹全局错误、离页停止批量请求
- 恢复 bun.lock(与 package-lock.json 共存);docs 规范与 CHANGELOG 更新
- 停止跟踪 .env.playwright.local(本地登录凭据,已加入 .gitignore)
2026-11-18 10:22:02 +08:00

126 lines
4.2 KiB
React
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
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 { Copy as ActionCopy } from '@/components/common/icons/ActionIcons';
import React from 'react';
import { useTranslation } from 'react-i18next';
import { Button, Toast, Banner } from '@/components/ui';
import { copy as copyText } from '../../helpers/utils';
/**
* 企业建号一次性凭证展示面板(注册自助建号 / 管理员建号复用)。
* props:
* creds: { status?, org_code, org_name, owner_login_name, initial_password }
* onLogin?: () => void 存在时展示「立即登录」按钮
*/
const OrgCredentialResult = ({ creds, onLogin }) => {
const { t } = useTranslation();
if (!creds) return null;
const isPending = creds.status === 'pending';
// 走公共 copy:HTTP 部署下 navigator.clipboard 为 undefined,直接调用会同步抛错、点了无反应
const copy = async (val) => {
if (await copyText(val)) {
Toast.success(t('已复制到剪贴板'));
} else {
Toast.error(t('复制失败,请手动复制'));
}
};
// 四项凭证拼成带标签的文本块一次复制,避免逐项复制的遗漏(如只记了密码没记企业代码)
const copyAll = () => {
copy(
[
`${t('企业代码')}: ${creds.org_code}`,
`${t('企业名称')}: ${creds.org_name}`,
`${t('登录名')}: ${creds.owner_login_name}`,
`${t('初始密码')}: ${creds.initial_password}`,
].join('\n'),
);
};
const Row = ({ label, value, mono }) => (
<div className='flex items-center justify-between gap-2 py-2 border-b border-gray-100 dark:border-white/[0.06] last:border-0'>
<span className='text-xs text-gray-500 dark:text-gray-400 shrink-0'>
{label}
</span>
<div className='flex items-center gap-1.5 min-w-0'>
<span
className={`truncate text-sm text-gray-800 dark:text-gray-100 ${mono ? 'font-mono' : ''}`}
>
{value}
</span>
<Button
size='small'
theme='borderless'
icon={<ActionCopy size={14} />}
onClick={() => copy(value)}
aria-label={t('复制')}
/>
</div>
</div>
);
return (
<div className='flex flex-col gap-3'>
<Banner
type={isPending ? 'info' : 'warning'}
closeIcon={null}
description={
isPending
? t(
'企业已提交,待平台审核通过后即可用以下凭证登录。请立即保存初始密码,此信息仅显示一次。',
)
: t(
'请立即保存以下凭证并交付管理员。初始密码仅显示一次,关闭后无法再次查看。',
)
}
/>
<div className='rounded-xl border border-gray-200/80 dark:border-white/[0.1] bg-white/60 dark:bg-white/[0.04] px-4'>
<Row label={t('企业代码')} value={creds.org_code} mono />
<Row label={t('企业名称')} value={creds.org_name} />
<Row label={t('登录名')} value={creds.owner_login_name} mono />
<Row label={t('初始密码')} value={creds.initial_password} mono />
</div>
<Button
size='large'
block
icon={<ActionCopy size={14} />}
onClick={copyAll}
>
{t('复制全部凭证')}
</Button>
{onLogin && (
<Button
theme='solid'
size='large'
block
onClick={onLogin}
disabled={isPending}
>
{isPending ? t('待审核通过后可登录') : t('立即登录')}
</Button>
)}
</div>
);
};
export default OrgCredentialResult;