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 }) => (