中英文切换

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

@@ -4,14 +4,15 @@ import {
} from 'antd';
import { EditOutlined, DeleteOutlined } from '@ant-design/icons';
import { useTranslation } from 'react-i18next';
import i18n from '../i18n';
const DictManager = ({
title,
data,
fields = [
{ name: 'storeValue', label: '存储值', required: true },
{ name: 'displayName', label: t('common.name'), required: true },
{ name: 'remark', label: t('roles.remark'), required: false }
{ name: 'storeValue', label: i18n.t('common.storeValue'), required: true },
{ name: 'displayName', label: i18n.t('common.name'), required: true },
{ name: 'remark', label: i18n.t('roles.remark'), required: false }
],
onAdd,
onUpdate,
@@ -19,6 +20,7 @@ const DictManager = ({
refresh,
loading,
}) => {
const { t } = useTranslation();
const [visible, setVisible] = useState(false);
const [form] = Form.useForm();
const [editing, setEditing] = useState(null);
@@ -26,7 +28,6 @@ const DictManager = ({
// 打开新增
const handleAddNew = () => {
const { t } = useTranslation();
setEditing(null);
form.resetFields();
setVisible(true);
@@ -57,10 +58,10 @@ const DictManager = ({
setEditing(null);
refresh?.();
} else {
messageApi.error(res?.msg || '操作失败');
messageApi.error(res?.msg || t('common.operationFailed'));
}
} catch (err) {
messageApi.error('提交失败');
messageApi.error(t('common.submitFail'));
}
};
@@ -77,11 +78,11 @@ const DictManager = ({
render: (_, record) => (
<Space>
<Button type="link" icon={<EditOutlined />} onClick={() => handleEdit(record)}>
编辑
{t('common.edit')}
</Button>
<Popconfirm
title="确定要删除这条数据吗?"
description="删除后将无法恢复"
title={t('common.confirmDeleteRecord')}
description={t('common.deleteIrreversible')}
okText={t('common.ok')}
cancelText={t('common.cancel')}
onConfirm={async () => {
@@ -98,9 +99,9 @@ const DictManager = ({
}
}}
>
<Button type="link" danger icon={<DeleteOutlined />}>
删除
</Button>
<Button type="link" danger icon={<DeleteOutlined />}>
{t('common.delete')}
</Button>
</Popconfirm>
</Space>
),
@@ -111,7 +112,7 @@ const DictManager = ({
<Card size="small" title={title} style={{ marginBottom: 16 }}>
{contextHolder}
<Button type="primary" size="small" onClick={handleAddNew}>
新增
{t('common.addNew')}
</Button>
<Table
@@ -136,7 +137,7 @@ const DictManager = ({
key={item.name}
name={item.name}
label={item.label}
rules={[{ required: item.required, message: `请输入${item.label}` }]}
rules={[{ required: item.required, message: `${t('common.pleaseInput')}${item.label}` }]}
>
<Input />
</Form.Item>