fix: datatime format support preview (#3572)

This commit is contained in:
katherinehhh 2024-02-26 17:00:18 +08:00 committed by GitHub
parent 88b281277c
commit 0e728ca5a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 9 deletions

View File

@ -65,15 +65,12 @@ const InternalExpiresRadio = (props) => {
{props.options.map((v) => { {props.options.map((v) => {
if (v.value === 'custom') { if (v.value === 'custom') {
return ( return (
<Radio value={v.value}> <Radio value={v.value} key={v.value}>
<Input <Input
style={{ width: '150px' }} style={{ width: '150px' }}
defaultValue={targetValue} defaultValue={targetValue}
onChange={(e) => { onChange={(e) => {
if ( if (e.target.value) {
e.target.value &&
moment(timeFormat ? date.format() : date.toLocaleString(), e.target.value).isValid()
) {
setCustomFormatPreview(date.format(e.target.value)); setCustomFormatPreview(date.format(e.target.value));
} else { } else {
setCustomFormatPreview(null); setCustomFormatPreview(null);
@ -87,7 +84,11 @@ const InternalExpiresRadio = (props) => {
</Radio> </Radio>
); );
} }
return <Radio value={v.value}>{v.label}</Radio>; return (
<Radio value={v.value} key={v.value}>
{v.label}
</Radio>
);
})} })}
</Space> </Space>
</Radio.Group> </Radio.Group>

View File

@ -1463,13 +1463,13 @@ export const SchemaSettingsDateFormat = function DateFormatConfig(props: { field
} }
`, `,
defaultValue: 'dddd', defaultValue: 'dddd',
formats: ['MMMMM Do YYYY', 'YYYY-MM-DD', 'MM/DD/YY', 'YYYY/MM/DD', 'DD/MM/YYYY'], formats: ['MMMM Do YYYY', 'YYYY-MM-DD', 'MM/DD/YY', 'YYYY/MM/DD', 'DD/MM/YYYY'],
}, },
default: dateFormatDefaultValue, default: dateFormatDefaultValue,
enum: [ enum: [
{ {
label: DateFormatCom({ format: 'MMMMM Do YYYY' }), label: DateFormatCom({ format: 'MMMM Do YYYY' }),
value: 'MMMMM Do YYYY', value: 'MMMM Do YYYY',
}, },
{ {
label: DateFormatCom({ format: 'YYYY-MM-DD' }), label: DateFormatCom({ format: 'YYYY-MM-DD' }),