diff --git a/public/_locales/zh_CN/messages.json b/public/_locales/zh_CN/messages.json index 2a92b0d..9f7776a 100644 --- a/public/_locales/zh_CN/messages.json +++ b/public/_locales/zh_CN/messages.json @@ -971,18 +971,6 @@ "message": "空值率", "description": "Translation key: testDataGenerator_nullRate" }, - "testDataGenerator_nullRateLow": { - "message": "低 (5%)", - "description": "Translation key: testDataGenerator_nullRateLow" - }, - "testDataGenerator_nullRateMedium": { - "message": "中 (20%)", - "description": "Translation key: testDataGenerator_nullRateMedium" - }, - "testDataGenerator_nullRateHigh": { - "message": "高 (50%)", - "description": "Translation key: testDataGenerator_nullRateHigh" - }, "testDataGenerator_uniqueConstraint": { "message": "唯一性约束", "description": "Translation key: testDataGenerator_uniqueConstraint" diff --git a/src/pages/TestDataGenerator/components/FieldEditor.tsx b/src/pages/TestDataGenerator/components/FieldEditor.tsx index e074ba0..06af793 100644 --- a/src/pages/TestDataGenerator/components/FieldEditor.tsx +++ b/src/pages/TestDataGenerator/components/FieldEditor.tsx @@ -38,7 +38,14 @@ export default function FieldEditor({ field, onChange }: FieldEditorProps) { }; const handleNullRateChange = (nullRate: number) => { - onChange({ ...field, nullRate }); + // 限制范围 0-100 + const clampedRate = Math.max(0, Math.min(100, nullRate)); + // 设置为 100% 时自动设为必填 + if (clampedRate === 100) { + onChange({ ...field, nullRate: clampedRate, required: true }); + } else { + onChange({ ...field, nullRate: clampedRate }); + } }; const handleUniqueChange = (unique: boolean) => { @@ -63,9 +70,10 @@ export default function FieldEditor({ field, onChange }: FieldEditorProps) { }; const nullRatePresets = [ - { label: t('testDataGenerator_nullRateLow'), value: 5 }, - { label: t('testDataGenerator_nullRateMedium'), value: 20 }, - { label: t('testDataGenerator_nullRateHigh'), value: 50 }, + { label: '5%', value: 5 }, + { label: '20%', value: 20 }, + { label: '50%', value: 50 }, + { label: '75%', value: 75 }, ]; return ( @@ -129,7 +137,12 @@ export default function FieldEditor({ field, onChange }: FieldEditorProps) { handleNullRateChange(Number(e.target.value))} + onChange={(e) => { + const value = Number(e.target.value); + if (value >= 0 && value <= 100) { + handleNullRateChange(value); + } + }} min={0} max={100} step={5} diff --git a/src/pages/TestDataGenerator/components/GenerateOptions.tsx b/src/pages/TestDataGenerator/components/GenerateOptions.tsx index 0e3c8ca..aa8bfef 100644 --- a/src/pages/TestDataGenerator/components/GenerateOptions.tsx +++ b/src/pages/TestDataGenerator/components/GenerateOptions.tsx @@ -5,13 +5,6 @@ import { useI18n } from '@/utils/chromeI18n'; import { Input } from '@/components/ui/input'; -import { - Select, - SelectContent, - SelectItem, - SelectTrigger, - SelectValue, -} from '@/components/ui/select'; interface GenerateOptionsProps { count: number; @@ -22,7 +15,12 @@ interface GenerateOptionsProps { onDefaultNullRateChange: (rate: number) => void; } -const COUNT_PRESETS = [10, 50, 100, 500, 1000, 5000, 10000]; +const COUNT_PRESETS = [50, 100, 1000, 5000, 10000]; + +const FORMAT_OPTIONS = [ + { value: 'json' as const, label: 'JSON' }, + { value: 'csv' as const, label: 'CSV' }, +]; export default function GenerateOptions({ count, @@ -76,15 +74,21 @@ export default function GenerateOptions({ - +
+ {FORMAT_OPTIONS.map((option) => ( + + ))} +
{/* 默认空值率 */}