diff --git a/web/src/pages/Setting/Operation/SettingsLog.jsx b/web/src/pages/Setting/Operation/SettingsLog.jsx index dcd17081..067e968b 100644 --- a/web/src/pages/Setting/Operation/SettingsLog.jsx +++ b/web/src/pages/Setting/Operation/SettingsLog.jsx @@ -18,7 +18,7 @@ For commercial licensing, please contact support@quantumnous.com */ import React, { useEffect, useState, useRef } from 'react'; -import { Button, Col, Form, Row, Spin, DatePicker } from '@douyinfe/semi-ui'; +import { Button, Col, Form, Row, Spin, DatePicker, Typography, Modal } from '@douyinfe/semi-ui'; import dayjs from 'dayjs'; import { useTranslation } from 'react-i18next'; import { @@ -29,6 +29,8 @@ import { showWarning, } from '../../../helpers'; +const { Text } = Typography; + export default function SettingsLog(props) { const { t } = useTranslation(); const [loading, setLoading] = useState(false); @@ -78,24 +80,75 @@ export default function SettingsLog(props) { }); } async function onCleanHistoryLog() { - try { - setLoadingCleanHistoryLog(true); - if (!inputs.historyTimestamp) throw new Error(t('请选择日志记录时间')); - const res = await API.delete( - `/api/log/?target_timestamp=${Date.parse(inputs.historyTimestamp) / 1000}`, - ); - const { success, message, data } = res.data; - if (success) { - showSuccess(`${data} ${t('条日志已清理!')}`); - return; - } else { - throw new Error(t('日志清理失败:') + message); - } - } catch (error) { - showError(error.message); - } finally { - setLoadingCleanHistoryLog(false); + if (!inputs.historyTimestamp) { + showError(t('请选择日志记录时间')); + return; } + + const now = dayjs(); + const targetDate = dayjs(inputs.historyTimestamp); + const targetTime = targetDate.format('YYYY-MM-DD HH:mm:ss'); + const currentTime = now.format('YYYY-MM-DD HH:mm:ss'); + const daysDiff = now.diff(targetDate, 'day'); + + Modal.confirm({ + title: t('确认清除历史日志'), + content: ( +
+
+
+