feat: 参考原型图 ui优化提交 个人端-用户中心 相关的页面

This commit is contained in:
zhanjunhao
2026-11-04 19:59:06 +08:00
parent 1fd4e084b6
commit 15192c433b
576 changed files with 18075 additions and 18912 deletions
+130 -82
View File
@@ -19,6 +19,7 @@ For commercial licensing, please contact support@quantumnous.com
import React, { useContext, useEffect, useRef, useState } from 'react';
import { useNavigate, useParams, useSearchParams } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { Form as AntForm } from 'antd';
import {
Button,
Form,
@@ -30,7 +31,7 @@ import {
Spin,
Checkbox,
Modal,
} from '@douyinfe/semi-ui';
} from '@/components/ui';
import { API } from '../../helpers/api';
import { showError, getLogo, getSystemName } from '../../helpers';
import {
@@ -67,7 +68,10 @@ const OrgLogin = () => {
const directLoginEnabled = !!statusState?.status?.org_direct_login;
// 免企业标识直登(方案 §12):'direct'=账号直登(默认),'identifier'=企业标识登录(原流程/回退)
const [loginMode, setLoginMode] = useState('direct');
const [directForm, setDirectForm] = useState({ login_name: '', password: '' });
const [directForm, setDirectForm] = useState({
login_name: '',
password: '',
});
const [multiMatch, setMultiMatch] = useState(null); // { orgs:[{index,org_id,name,logo}], ticket, password }
// 带入 Step2 初值的登录名,避免重复输入:来自 ?login= 预填(注册成功直达)或直登回退时已输的登录名
const [pendingLoginName, setPendingLoginName] = useState(loginParam);
@@ -290,7 +294,10 @@ const OrgLogin = () => {
if (loading) return;
setLoading(true);
try {
const res = await API.post('/api/org/login/direct', { login_name, password });
const res = await API.post('/api/org/login/direct', {
login_name,
password,
});
if (res.data.success) {
const data = res.data.data;
if (data.need_org_hint) {
@@ -300,7 +307,11 @@ const OrgLogin = () => {
return;
}
if (data.multi) {
setMultiMatch({ orgs: data.orgs || [], ticket: data.ticket, password });
setMultiMatch({
orgs: data.orgs || [],
ticket: data.ticket,
password,
});
return;
}
await applyLoginSuccess(data, login_name, password);
@@ -416,7 +427,7 @@ const OrgLogin = () => {
return (
<div
className='relative overflow-hidden flex items-center justify-center py-12 px-4 sm:px-6 lg:px-8'
className='auth-login-page relative overflow-hidden flex items-center justify-center py-12 px-4 sm:px-6 lg:px-8'
// 抵扣 PageLayout 跑马灯占位高度,保证占位+容器恰为一屏,避免幽灵滚动
style={{ minHeight: 'calc(100vh - var(--content-top-offset, 0px))' }}
>
@@ -438,7 +449,7 @@ const OrgLogin = () => {
)}
<GlassCard>
<AuthCardHeader
wrapperClassName='mb-6'
wrapperClassName='mb-3'
logo={logo}
logoNode={
orgInfo?.logo ? (
@@ -471,33 +482,53 @@ const OrgLogin = () => {
</span>
</div>
) : (
<div key={step} className='org-step-enter auth-glass-form'>
<div key={step} className='org-step-enter auth-login-form'>
{step === 1 && (
<div className='flex flex-col gap-4'>
<AntForm
layout='vertical'
component='div'
className='auth-login-fields'
>
{effectiveMode === 'direct' ? (
<>
{/* 账号直登:输登录名 + 密码,系统自动定位企业(方案 §12) */}
<Input
value={directForm.login_name}
onChange={(v) =>
setDirectForm({ ...directForm, login_name: v })
}
placeholder={t('登录名')}
size='large'
autoFocus
/>
<Input
value={directForm.password}
onChange={(v) =>
setDirectForm({ ...directForm, password: v })
}
mode='password'
placeholder={t('密码')}
size='large'
onKeyDown={handleCapsLock}
onKeyUp={handleCapsLock}
onEnterPress={doDirectLogin}
/>
<AntForm.Item
label={t('登录名')}
htmlFor='org-direct-login-name'
required
>
<Input
id='org-direct-login-name'
aria-required='true'
value={directForm.login_name}
onChange={(v) =>
setDirectForm({ ...directForm, login_name: v })
}
placeholder={t('请输入登录名')}
size='default'
autoFocus
/>
</AntForm.Item>
<AntForm.Item
label={t('密码')}
htmlFor='org-direct-password'
required
>
<Input
id='org-direct-password'
aria-required='true'
value={directForm.password}
onChange={(v) =>
setDirectForm({ ...directForm, password: v })
}
mode='password'
placeholder={t('请输入密码')}
size='default'
onKeyDown={handleCapsLock}
onKeyUp={handleCapsLock}
onEnterPress={doDirectLogin}
/>
</AntForm.Item>
{capsOn && (
<div className='text-xs text-amber-500 -mt-1'>
{t('大写锁定已开启')}
@@ -505,7 +536,7 @@ const OrgLogin = () => {
)}
<Button
theme='solid'
size='large'
size='default'
block
loading={loading}
disabled={
@@ -517,7 +548,7 @@ const OrgLogin = () => {
</Button>
<Button
theme='borderless'
size='large'
size='default'
block
className='!text-gray-500'
onClick={() => setLoginMode('identifier')}
@@ -527,43 +558,51 @@ const OrgLogin = () => {
</>
) : (
<>
<AutoComplete
value={identifier}
data={suggestOptions}
onChange={(v) =>
setIdentifier(typeof v === 'string' ? v : '')
}
onSearch={handleSuggestSearch}
onSelect={(code) => {
setIdentifier(code);
lookupOrg(code); // 选中候选:用 code 精确直达 Step2
}}
onEnterPress={lookupOrg} // 未选候选时按当前输入精确解析
placeholder={t('输入企业名称、企业代码或登录短链')}
emptyContent={null}
renderItem={(item) => (
<div className='flex items-center gap-2 py-0.5'>
{item.logo ? (
<Avatar
src={item.logo}
shape='square'
className='h-6 w-6 rounded'
/>
) : (
<div className='h-6 w-6 rounded bg-gray-100 dark:bg-white/10' />
)}
<span className='truncate'>
{highlightMatch(item.name, identifier)}
</span>
</div>
)}
style={{ width: '100%' }}
size='large'
autoFocus
/>
<AntForm.Item
label={t('企业名称/代码')}
htmlFor='org-login-identifier'
required
>
<AutoComplete
id='org-login-identifier'
aria-required='true'
value={identifier}
data={suggestOptions}
onChange={(v) =>
setIdentifier(typeof v === 'string' ? v : '')
}
onSearch={handleSuggestSearch}
onSelect={(code) => {
setIdentifier(code);
lookupOrg(code); // 选中候选:用 code 精确直达 Step2
}}
onEnterPress={lookupOrg} // 未选候选时按当前输入精确解析
placeholder={t('输入企业名称、企业代码或登录短链')}
emptyContent={null}
renderItem={(item) => (
<div className='flex items-center gap-2 py-0.5'>
{item.logo ? (
<Avatar
src={item.logo}
shape='square'
className='h-6 w-6 rounded'
/>
) : (
<div className='h-6 w-6 rounded bg-gray-100 dark:bg-white/10' />
)}
<span className='truncate'>
{highlightMatch(item.name, identifier)}
</span>
</div>
)}
style={{ width: '100%' }}
size='default'
autoFocus
/>
</AntForm.Item>
<Button
theme='solid'
size='large'
size='default'
block
loading={loading}
disabled={!identifier.trim()}
@@ -574,7 +613,7 @@ const OrgLogin = () => {
{directLoginEnabled && (
<Button
theme='borderless'
size='large'
size='default'
block
className='!text-gray-500'
onClick={() => setLoginMode('direct')}
@@ -594,7 +633,7 @@ const OrgLogin = () => {
</div>
<Button
theme='borderless'
size='large'
size='default'
block
className='!text-brand'
onClick={() => navigate('/org/register')}
@@ -603,7 +642,7 @@ const OrgLogin = () => {
</Button>
</>
)}
</div>
</AntForm>
)}
{step === 2 && (
@@ -613,17 +652,21 @@ const OrgLogin = () => {
>
<Form.Input
field='login_name'
className='auth-login-required-field'
label={t('企业内登录名')}
size='large'
placeholder={t('请输入登录名')}
size='default'
autoFocus={!prefilledLoginName}
autoComplete='username'
rules={[{ required: true, message: t('请输入登录名') }]}
/>
<Form.Input
field='password'
className='auth-login-required-field'
label={t('密码')}
placeholder={t('请输入密码')}
mode='password'
size='large'
size='default'
autoFocus={Boolean(prefilledLoginName)}
autoComplete='current-password'
onKeyDown={handleCapsLock}
@@ -637,20 +680,19 @@ const OrgLogin = () => {
)}
<div className='flex items-center justify-between'>
<Checkbox
className='auth-login-remember'
checked={rememberLoginName}
onChange={(e) => setRememberLoginName(e.target.checked)}
>
<span className='text-xs text-gray-500 dark:text-gray-400'>
{t('记住登录名')}
</span>
<span className='text-xs'>{t('记住登录名')}</span>
</Checkbox>
<span className='text-xs text-gray-400 dark:text-gray-500'>
<span className='auth-login-admin-help text-xs'>
{t('忘记密码?请联系企业管理员重置')}
</span>
</div>
<Button
theme='solid'
size='large'
size='default'
block
htmlType='submit'
loading={loading}
@@ -659,8 +701,8 @@ const OrgLogin = () => {
{t('登录')}
</Button>
<Button
theme='borderless'
size='large'
theme='solid'
size='default'
block
disabled={loading}
style={{ marginTop: 8 }}
@@ -687,8 +729,9 @@ const OrgLogin = () => {
<Form.Input
field='new_password'
label={t('新密码(8-20 位)')}
placeholder={t('请输入新密码')}
mode='password'
size='large'
size='default'
autoFocus
autoComplete='new-password'
onKeyDown={handleCapsLock}
@@ -703,8 +746,9 @@ const OrgLogin = () => {
<Form.Input
field='confirm_password'
label={t('确认新密码')}
placeholder={t('请再次输入新密码')}
mode='password'
size='large'
size='default'
autoComplete='new-password'
onKeyDown={handleCapsLock}
onKeyUp={handleCapsLock}
@@ -722,7 +766,7 @@ const OrgLogin = () => {
)}
<Button
theme='solid'
size='large'
size='default'
block
htmlType='submit'
loading={loading}
@@ -758,7 +802,11 @@ const OrgLogin = () => {
className='flex items-center gap-3 w-full p-3 rounded-xl border border-gray-200/80 dark:border-white/10 hover:bg-gray-50 dark:hover:bg-white/[0.06] transition-all text-left disabled:opacity-50'
>
{o.logo ? (
<Avatar src={o.logo} shape='square' className='h-8 w-8 rounded-lg' />
<Avatar
src={o.logo}
shape='square'
className='h-8 w-8 rounded-lg'
/>
) : (
<div className='h-8 w-8 rounded-lg bg-gray-100 dark:bg-white/10' />
)}