中英文切换

This commit is contained in:
mmc
2026-08-14 09:02:52 +08:00
parent a8af55a856
commit 62b03bba03
94 changed files with 19723 additions and 2766 deletions

View File

@@ -38,6 +38,8 @@ const { TabPane } = Tabs;
const { Title } = Typography;
const Profile: React.FC = () => {
const { t } = useTranslation();
const [loading, setLoading] = useState(false);
const [profileData, setProfileData] = useState<any>(null);
const { userInfo } = useSelector((state: RootState) => state.user);
@@ -80,7 +82,7 @@ const Profile: React.FC = () => {
message.error(res.msg || t('profile.modifyFailed'));
}
} catch (error) {
message.error('请求失败');
message.error(t('profile.requestFailed'));
} finally {
setLoading(false);
}
@@ -101,7 +103,7 @@ const Profile: React.FC = () => {
message.error(res.msg || t('profile.modifyFailed'));
}
} catch (error) {
message.error('请求失败');
message.error(t('profile.requestFailed'));
} finally {
setLoading(false);
}
@@ -136,7 +138,7 @@ const Profile: React.FC = () => {
return (
<div style={{ padding: '20px 40px', background: '#f5f7fa', minHeight: '100vh' }}>
<Title level={4} style={{ marginBottom: 24, fontWeight: 600 }}>
个人中心
{t('profile.title')}
</Title>
{/* 🔥 关键:给 Row 添加 align="stretch" 让两列自动等高 */}
@@ -175,7 +177,7 @@ const Profile: React.FC = () => {
borderColor: '#d9d9d9',
}}
>
更换头像
{t('profile.changeAvatar')}
</Button>
</Upload>
</div>
@@ -187,25 +189,25 @@ const Profile: React.FC = () => {
<Space direction="vertical" size="middle" style={{ width: '100%' }}>
<div style={{ display: 'flex', alignItems: 'center', fontSize: 14 }}>
<UserOutlined style={{ marginRight: 12, color: '#165DFF', fontSize: 16 }} />
<span style={{ color: '#666' }}>用户名称:</span>
<span style={{ color: '#666' }}>{t('profile.username')}:</span>
<strong style={{ marginLeft: 4, color: '#333' }}>{profileData?.userName}</strong>
</div>
<div style={{ display: 'flex', alignItems: 'center', fontSize: 14 }}>
<PhoneOutlined style={{ marginRight: 12, color: '#165DFF', fontSize: 16 }} />
<span style={{ color: '#666' }}>手机号码:</span>
<span style={{ color: '#666' }}>{t('profile.phone')}:</span>
<strong style={{ marginLeft: 4, color: '#333' }}>{profileData?.phonenumber || t('profile.notSet')}</strong>
</div>
<div style={{ display: 'flex', alignItems: 'center', fontSize: 14 }}>
<MailOutlined style={{ marginRight: 12, color: '#165DFF', fontSize: 16 }} />
<span style={{ color: '#666' }}>用户邮箱:</span>
<span style={{ color: '#666' }}>{t('profile.email')}:</span>
<strong style={{ marginLeft: 4, color: '#333' }}>{profileData?.email || t('profile.notSet')}</strong>
</div>
<div style={{ display: 'flex', alignItems: 'center', fontSize: 14 }}>
<SafetyOutlined style={{ marginRight: 12, color: '#165DFF', fontSize: 16 }} />
<span style={{ color: '#666' }}>所属角色:</span>
<span style={{ color: '#666' }}>{t('profile.role')}:</span>
<strong style={{ marginLeft: 4, color: '#333' }}>
{profileData?.roles?.map((r: any) => r.roleName).join(', ') || t('profile.notSet')}
</strong>
@@ -234,7 +236,7 @@ const Profile: React.FC = () => {
}}
>
{/* 基本资料 */}
<TabPane tab="基本资料" key="1">
<TabPane tab={t('profile.basicInfo')} key="1">
<div style={{ maxWidth: 500, margin: '0 auto', padding: '12px 0' }}>
<Form
form={form}
@@ -271,15 +273,15 @@ const Profile: React.FC = () => {
name="sex"
>
<Radio.Group>
<Radio value="0"><ManOutlined /> 男</Radio>
<Radio value="1"><WomanOutlined /> 女</Radio>
<Radio value="0"><ManOutlined /> {t('profile.male')}</Radio>
<Radio value="1"><WomanOutlined /> {t('profile.female')}</Radio>
</Radio.Group>
</Form.Item>
<Form.Item
label={t('users.phoneLabel')}
name="phonenumber"
rules={[{ pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号码' }]}
rules={[{ pattern: /^1[3-9]\d{9}$/, message: t('profile.phoneInvalid') }]}
>
<Input
prefix={<PhoneOutlined />}
@@ -291,11 +293,11 @@ const Profile: React.FC = () => {
<Form.Item
label={t('users.email')}
name="email"
rules={[{ type: 'email', message: '请输入正确的邮箱格式' }]}
rules={[{ type: 'email', message: t('profile.emailInvalid') }]}
>
<Input
prefix={<MailOutlined />}
placeholder="请输入邮箱"
placeholder={t('profile.emailPlaceholder')}
style={{ borderRadius: 6 }}
/>
</Form.Item>
@@ -305,7 +307,7 @@ const Profile: React.FC = () => {
name="remark"
>
<Input.TextArea
placeholder="请输入备注"
placeholder={t('profile.remarkPlaceholder')}
style={{ borderRadius: 6 }}
rows={3}
/>
@@ -323,7 +325,7 @@ const Profile: React.FC = () => {
width: 160,
}}
>
保存修改
{t('profile.saveChanges')}
</Button>
</Form.Item>
</Form>
@@ -331,7 +333,7 @@ const Profile: React.FC = () => {
</TabPane>
{/* 修改密码 */}
<TabPane tab="修改密码" key="2">
<TabPane tab={t('profile.changePassword')} key="2">
<div style={{ maxWidth: 500, margin: '0 auto', padding: '12px 0' }}>
<Form
form={pwdForm}
@@ -342,11 +344,11 @@ const Profile: React.FC = () => {
<Form.Item
label={t('profile.oldPassword')}
name="oldPassword"
rules={[{ required: true, message: '请输入旧密码' }]}
rules={[{ required: true, message: t('profile.oldPasswordPlaceholder') }]}
>
<Input.Password
prefix={<LockOutlined />}
placeholder="请输入旧密码"
placeholder={t('profile.oldPasswordPlaceholder')}
style={{ borderRadius: 6 }}
/>
</Form.Item>
@@ -355,13 +357,13 @@ const Profile: React.FC = () => {
label={t('profile.newPassword')}
name="newPassword"
rules={[
{ required: true, message: '请输入新密码' },
{ min: 6, message: '密码长度不能小于6位' },
{ required: true, message: t('profile.newPasswordPlaceholder') },
{ min: 6, message: t('profile.passwordLengthError') },
]}
>
<Input.Password
prefix={<LockOutlined />}
placeholder="请输入新密码"
placeholder={t('profile.newPasswordPlaceholder')}
style={{ borderRadius: 6 }}
/>
</Form.Item>
@@ -369,11 +371,11 @@ const Profile: React.FC = () => {
<Form.Item
label={t('profile.confirmPassword')}
name="confirmPassword"
rules={[{ required: true, message: '请确认新密码' }]}
rules={[{ required: true, message: t('profile.confirmPasswordRequired') }]}
>
<Input.Password
prefix={<LockOutlined />}
placeholder="请再次输入新密码"
placeholder={t('profile.confirmPasswordPlaceholder')}
style={{ borderRadius: 6 }}
/>
</Form.Item>
@@ -390,7 +392,7 @@ const Profile: React.FC = () => {
width: 160,
}}
>
确认修改
{t('profile.confirmChange')}
</Button>
</Form.Item>
</Form>