Skip to content

Commit 2c732a6

Browse files
committed
Update audit log date range validation to 180 days
- Adjusted date range validation logic to limit selections to a maximum of 180 days instead of one year. - Updated related comments and user messages to reflect the new 180-day constraint. - Modified API request to fetch audit logs starting from 180 days ago.
1 parent bec3579 commit 2c732a6

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

src/pages/audit-logs.tsx

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -263,15 +263,15 @@ export const AuditLogs = () => {
263263
const handleDateRangeChange = (
264264
dates: [Dayjs | null, Dayjs | null] | null,
265265
) => {
266-
// 验证日期范围不超过一年
266+
// 验证日期范围不超过180天
267267
if (dates?.[0] && dates?.[1]) {
268268
const startDate = dates[0];
269269
const endDate = dates[1];
270270
const diffInDays = endDate.diff(startDate, 'day');
271271

272-
if (diffInDays > 365) {
273-
// 如果超过一年,自动调整为一年
274-
const adjustedEndDate = startDate.add(365, 'day');
272+
if (diffInDays > 180) {
273+
// 如果超过180天,自动调整为180天
274+
const adjustedEndDate = startDate.add(180, 'day');
275275
setDateRange([startDate, adjustedEndDate]);
276276
} else {
277277
setDateRange(dates);
@@ -282,40 +282,40 @@ export const AuditLogs = () => {
282282
setOffset(0); // 重置到第一页
283283
};
284284

285-
// 限制日期选择:不能超过一年,不能选择未来日期,不能选择超过一年前的日期
285+
// 限制日期选择:不能超过180天,不能选择未来日期,不能选择超过180天前的日期
286286
const disabledDate = (current: Dayjs | null) => {
287287
if (!current) return false;
288288

289289
const today = dayjs();
290-
const oneYearAgo = today.subtract(1, 'year');
290+
const oneHundredEightyDaysAgo = today.subtract(180, 'day');
291291

292292
// 不能选择未来日期
293293
if (current.isAfter(today, 'day')) {
294294
return true;
295295
}
296296

297-
// 不能选择超过一年前的日期(从今天开始往过去超过一年
298-
if (current.isBefore(oneYearAgo, 'day')) {
297+
// 不能选择超过180天前的日期(从今天开始往过去超过180天
298+
if (current.isBefore(oneHundredEightyDaysAgo, 'day')) {
299299
return true;
300300
}
301301

302-
// 如果已经选择了开始日期,限制结束日期不能超过开始日期一年
302+
// 如果已经选择了开始日期,限制结束日期不能超过开始日期180天
303303
if (dateRange?.[0] && !dateRange[1]) {
304304
const startDate = dateRange[0];
305-
const oneYearLater = startDate.add(1, 'year');
305+
const oneHundredEightyDaysLater = startDate.add(180, 'day');
306306
return (
307307
current.isBefore(startDate, 'day') ||
308-
current.isAfter(oneYearLater, 'day')
308+
current.isAfter(oneHundredEightyDaysLater, 'day')
309309
);
310310
}
311311

312-
// 如果已经选择了结束日期,限制开始日期不能早于结束日期一年
312+
// 如果已经选择了结束日期,限制开始日期不能早于结束日期180天
313313
if (!dateRange?.[0] && dateRange?.[1]) {
314314
const endDate = dateRange[1];
315-
const oneYearEarlier = endDate.subtract(1, 'year');
315+
const oneHundredEightyDaysEarlier = endDate.subtract(180, 'day');
316316
return (
317317
current.isAfter(endDate, 'day') ||
318-
current.isBefore(oneYearEarlier, 'day')
318+
current.isBefore(oneHundredEightyDaysEarlier, 'day')
319319
);
320320
}
321321

@@ -391,8 +391,8 @@ export const AuditLogs = () => {
391391
操作日志
392392
</h2>
393393
<p className="text-gray-500 text-sm mt-1">
394-
日志功能从 2025 年 11 月 17
395-
日开始测试,没有更早的数据。将仅保留一年内的数据
394+
日志功能从 2025 年 11 月 17 日开始测试,没有更早的数据。将仅保留
395+
180 天内的数据
396396
</p>
397397
</div>
398398
<Space>

src/utils/hooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export const useAuditLogs = ({
148148
api.getAuditLogs({
149149
offset: 0,
150150
limit: 1000,
151-
startDate: dayjs().subtract(1, 'year').toISOString(),
151+
startDate: dayjs().subtract(180, 'day').toISOString(),
152152
}),
153153
});
154154

0 commit comments

Comments
 (0)