Initial import of weiyuan frontend
This commit is contained in:
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
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 { useTranslation } from 'react-i18next';
|
||||
import { Button, Toast, Banner } from '@douyinfe/semi-ui';
|
||||
import { Copy } from 'lucide-react';
|
||||
|
||||
/**
|
||||
* 企业建号一次性凭证展示面板(注册自助建号 / 管理员建号复用)。
|
||||
* 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';
|
||||
|
||||
const copy = (val) => {
|
||||
navigator.clipboard
|
||||
.writeText(val)
|
||||
.then(() => Toast.success(t('已复制到剪贴板')))
|
||||
.catch(() => 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={<Copy 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={<Copy 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;
|
||||
Reference in New Issue
Block a user