feat: add date range preset constants and use them in the log filter
This commit is contained in:
parent
46c561eef2
commit
2836ec2eb3
@ -21,6 +21,8 @@ import React from 'react';
|
|||||||
import { Button, Form } from '@douyinfe/semi-ui';
|
import { Button, Form } from '@douyinfe/semi-ui';
|
||||||
import { IconSearch } from '@douyinfe/semi-icons';
|
import { IconSearch } from '@douyinfe/semi-icons';
|
||||||
|
|
||||||
|
import { DATE_RANGE_PRESETS } from '../../../constants/console.constants';
|
||||||
|
|
||||||
const MjLogsFilters = ({
|
const MjLogsFilters = ({
|
||||||
formInitValues,
|
formInitValues,
|
||||||
setFormApi,
|
setFormApi,
|
||||||
@ -54,6 +56,11 @@ const MjLogsFilters = ({
|
|||||||
showClear
|
showClear
|
||||||
pure
|
pure
|
||||||
size='small'
|
size='small'
|
||||||
|
presets={DATE_RANGE_PRESETS.map(preset => ({
|
||||||
|
text: t(preset.text),
|
||||||
|
start: preset.start(),
|
||||||
|
end: preset.end()
|
||||||
|
}))}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -21,6 +21,8 @@ import React from 'react';
|
|||||||
import { Button, Form } from '@douyinfe/semi-ui';
|
import { Button, Form } from '@douyinfe/semi-ui';
|
||||||
import { IconSearch } from '@douyinfe/semi-icons';
|
import { IconSearch } from '@douyinfe/semi-icons';
|
||||||
|
|
||||||
|
import { DATE_RANGE_PRESETS } from '../../../constants/console.constants';
|
||||||
|
|
||||||
const TaskLogsFilters = ({
|
const TaskLogsFilters = ({
|
||||||
formInitValues,
|
formInitValues,
|
||||||
setFormApi,
|
setFormApi,
|
||||||
@ -54,6 +56,11 @@ const TaskLogsFilters = ({
|
|||||||
showClear
|
showClear
|
||||||
pure
|
pure
|
||||||
size='small'
|
size='small'
|
||||||
|
presets={DATE_RANGE_PRESETS.map(preset => ({
|
||||||
|
text: t(preset.text),
|
||||||
|
start: preset.start(),
|
||||||
|
end: preset.end()
|
||||||
|
}))}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -21,6 +21,8 @@ import React from 'react';
|
|||||||
import { Button, Form } from '@douyinfe/semi-ui';
|
import { Button, Form } from '@douyinfe/semi-ui';
|
||||||
import { IconSearch } from '@douyinfe/semi-icons';
|
import { IconSearch } from '@douyinfe/semi-icons';
|
||||||
|
|
||||||
|
import { DATE_RANGE_PRESETS } from '../../../constants/console.constants';
|
||||||
|
|
||||||
const LogsFilters = ({
|
const LogsFilters = ({
|
||||||
formInitValues,
|
formInitValues,
|
||||||
setFormApi,
|
setFormApi,
|
||||||
@ -55,6 +57,11 @@ const LogsFilters = ({
|
|||||||
showClear
|
showClear
|
||||||
pure
|
pure
|
||||||
size='small'
|
size='small'
|
||||||
|
presets={DATE_RANGE_PRESETS.map(preset => ({
|
||||||
|
text: t(preset.text),
|
||||||
|
start: preset.start(),
|
||||||
|
end: preset.end()
|
||||||
|
}))}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
49
web/src/constants/console.constants.js
Normal file
49
web/src/constants/console.constants.js
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2025 QuantumNous
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
For commercial licensing, please contact support@quantumnous.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
|
// ========== 日期预设常量 ==========
|
||||||
|
export const DATE_RANGE_PRESETS = [
|
||||||
|
{
|
||||||
|
text: '今天',
|
||||||
|
start: () => dayjs().startOf('day').toDate(),
|
||||||
|
end: () => dayjs().endOf('day').toDate()
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: '近 7 天',
|
||||||
|
start: () => dayjs().subtract(6, 'day').startOf('day').toDate(),
|
||||||
|
end: () => dayjs().endOf('day').toDate()
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: '本周',
|
||||||
|
start: () => dayjs().startOf('week').toDate(),
|
||||||
|
end: () => dayjs().endOf('week').toDate()
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: '近 30 天',
|
||||||
|
start: () => dayjs().subtract(29, 'day').startOf('day').toDate(),
|
||||||
|
end: () => dayjs().endOf('day').toDate()
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: '本月',
|
||||||
|
start: () => dayjs().startOf('month').toDate(),
|
||||||
|
end: () => dayjs().endOf('month').toDate()
|
||||||
|
},
|
||||||
|
];
|
||||||
@ -2084,5 +2084,10 @@
|
|||||||
"原价": "Original price",
|
"原价": "Original price",
|
||||||
"优惠": "Discount",
|
"优惠": "Discount",
|
||||||
"折": "% off",
|
"折": "% off",
|
||||||
"节省": "Save"
|
"节省": "Save",
|
||||||
|
"今天": "Today",
|
||||||
|
"近 7 天": "Last 7 Days",
|
||||||
|
"本周": "This Week",
|
||||||
|
"本月": "This Month",
|
||||||
|
"近 30 天": "Last 30 Days"
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user