feat(settings): expose data retention controls

This commit is contained in:
jxxghp
2026-08-26 12:45:51 +08:00
parent 06c711bb03
commit f9ad7bc204
5 changed files with 133 additions and 0 deletions
+13
View File
@@ -2317,6 +2317,19 @@ export default {
dataCleanupSiteUserDataDaysHint: 'Unit: days. Set to 0 to skip cleanup for the site user data table', dataCleanupSiteUserDataDaysHint: 'Unit: days. Set to 0 to skip cleanup for the site user data table',
dataCleanupTransferHistoryDays: 'Transfer History Retention Days', dataCleanupTransferHistoryDays: 'Transfer History Retention Days',
dataCleanupTransferHistoryDaysHint: 'Unit: days. Set to 0 to skip cleanup for the transfer history table', dataCleanupTransferHistoryDaysHint: 'Unit: days. Set to 0 to skip cleanup for the transfer history table',
dataCleanupDownloadFailureDays: 'Download Failure Retention Days',
dataCleanupDownloadFailureDaysHint: 'Unit: days. Set to 0 to keep all download failure cooldown records',
dataCleanupSubscribeHistoryDays: 'Subscription History Retention Days',
dataCleanupSubscribeHistoryDaysHint: 'Unit: days. Set to 0 to keep all completed subscription history',
dataCleanupAgentChatDays: 'Agent Chat Retention Days',
dataCleanupAgentChatDaysHint:
'Unit: days. Set to 0 to keep all chats. Chats referenced by scheduled tasks are preserved',
dataCleanupAgentTaskRunDays: 'Agent Task Run Retention Days',
dataCleanupAgentTaskRunDaysHint: 'Unit: days. Set to 0 to keep all runs. Running and latest runs are preserved',
dataCleanupOutboxCompletedDays: 'Completed Outbox Retention Days',
dataCleanupOutboxCompletedDaysHint: 'Unit: days. Set to 0 to keep all successfully delivered durable events',
dataCleanupOutboxDeadDays: 'Dead Outbox Retention Days',
dataCleanupOutboxDeadDaysHint: 'Unit: days. Set to 0 to keep all durable events that exhausted their retries',
downloadFilesCleanupNotice: downloadFilesCleanupNotice:
'The download files table has no independent timestamp field. Its orphan record cleanup follows the retention period of download history.', 'The download files table has no independent timestamp field. Its orphan record cleanup follows the retention period of download history.',
pluginAutoReload: 'Plugin Hot Reload', pluginAutoReload: 'Plugin Hot Reload',
+12
View File
@@ -2283,6 +2283,18 @@ export default {
dataCleanupSiteUserDataDaysHint: '单位:天,0 表示不清理站点用户数据表', dataCleanupSiteUserDataDaysHint: '单位:天,0 表示不清理站点用户数据表',
dataCleanupTransferHistoryDays: '整理历史表保留天数', dataCleanupTransferHistoryDays: '整理历史表保留天数',
dataCleanupTransferHistoryDaysHint: '单位:天,0 表示不清理整理历史表', dataCleanupTransferHistoryDaysHint: '单位:天,0 表示不清理整理历史表',
dataCleanupDownloadFailureDays: '下载失败记录保留天数',
dataCleanupDownloadFailureDaysHint: '单位:天,0 表示不清理下载失败冷却记录',
dataCleanupSubscribeHistoryDays: '订阅历史表保留天数',
dataCleanupSubscribeHistoryDaysHint: '单位:天,0 表示保留全部已完成订阅历史',
dataCleanupAgentChatDays: 'Agent 会话历史保留天数',
dataCleanupAgentChatDaysHint: '单位:天,0 表示保留全部会话;定时任务引用的会话不会清理',
dataCleanupAgentTaskRunDays: 'Agent 任务运行历史保留天数',
dataCleanupAgentTaskRunDaysHint: '单位:天,0 表示保留全部运行历史;运行中和最后一次运行不会清理',
dataCleanupOutboxCompletedDays: 'Outbox 已完成记录保留天数',
dataCleanupOutboxCompletedDaysHint: '单位:天,0 表示不清理已成功投递的可靠事件记录',
dataCleanupOutboxDeadDays: 'Outbox 死信记录保留天数',
dataCleanupOutboxDeadDaysHint: '单位:天,0 表示不清理重试耗尽的可靠事件记录',
downloadFilesCleanupNotice: '下载文件表没有独立时间字段,会跟随下载历史表的保留周期清理其孤儿记录。', downloadFilesCleanupNotice: '下载文件表没有独立时间字段,会跟随下载历史表的保留周期清理其孤儿记录。',
pluginAutoReload: '插件热加载', pluginAutoReload: '插件热加载',
pluginAutoReloadHint: '修改插件文件后自动重新加载,开发插件时使用', pluginAutoReloadHint: '修改插件文件后自动重新加载,开发插件时使用',
+12
View File
@@ -2282,6 +2282,18 @@ export default {
dataCleanupSiteUserDataDaysHint: '單位:天,0 表示不清理站點用戶數據表', dataCleanupSiteUserDataDaysHint: '單位:天,0 表示不清理站點用戶數據表',
dataCleanupTransferHistoryDays: '整理歷史表保留天數', dataCleanupTransferHistoryDays: '整理歷史表保留天數',
dataCleanupTransferHistoryDaysHint: '單位:天,0 表示不清理整理歷史表', dataCleanupTransferHistoryDaysHint: '單位:天,0 表示不清理整理歷史表',
dataCleanupDownloadFailureDays: '下載失敗記錄保留天數',
dataCleanupDownloadFailureDaysHint: '單位:天,0 表示不清理下載失敗冷卻記錄',
dataCleanupSubscribeHistoryDays: '訂閱歷史表保留天數',
dataCleanupSubscribeHistoryDaysHint: '單位:天,0 表示保留全部已完成訂閱歷史',
dataCleanupAgentChatDays: 'Agent 會話歷史保留天數',
dataCleanupAgentChatDaysHint: '單位:天,0 表示保留全部會話;定時任務引用的會話不會清理',
dataCleanupAgentTaskRunDays: 'Agent 任務運行歷史保留天數',
dataCleanupAgentTaskRunDaysHint: '單位:天,0 表示保留全部運行歷史;運行中和最後一次運行不會清理',
dataCleanupOutboxCompletedDays: 'Outbox 已完成記錄保留天數',
dataCleanupOutboxCompletedDaysHint: '單位:天,0 表示不清理已成功投遞的可靠事件記錄',
dataCleanupOutboxDeadDays: 'Outbox 死信記錄保留天數',
dataCleanupOutboxDeadDaysHint: '單位:天,0 表示不清理重試耗盡的可靠事件記錄',
downloadFilesCleanupNotice: '下載文件表沒有獨立時間欄位,會跟隨下載歷史表的保留週期清理其孤兒記錄。', downloadFilesCleanupNotice: '下載文件表沒有獨立時間欄位,會跟隨下載歷史表的保留週期清理其孤兒記錄。',
pluginAutoReload: '插件熱加載', pluginAutoReload: '插件熱加載',
pluginAutoReloadHint: '修改插件文件後自動重新加載,開發插件時使用', pluginAutoReloadHint: '修改插件文件後自動重新加載,開發插件時使用',
@@ -101,6 +101,12 @@ const SystemSettings = ref<any>({
DATA_CLEANUP_DOWNLOAD_HISTORY_DAYS: 180, DATA_CLEANUP_DOWNLOAD_HISTORY_DAYS: 180,
DATA_CLEANUP_SITE_USERDATA_DAYS: 180, DATA_CLEANUP_SITE_USERDATA_DAYS: 180,
DATA_CLEANUP_TRANSFER_HISTORY_DAYS: 365 * 3, DATA_CLEANUP_TRANSFER_HISTORY_DAYS: 365 * 3,
DATA_CLEANUP_DOWNLOAD_FAILURE_DAYS: 7,
DATA_CLEANUP_SUBSCRIBE_HISTORY_DAYS: 365 * 3,
DATA_CLEANUP_AGENT_CHAT_DAYS: 180,
DATA_CLEANUP_AGENT_TASK_RUN_DAYS: 180,
DATA_CLEANUP_OUTBOX_COMPLETED_DAYS: 30,
DATA_CLEANUP_OUTBOX_DEAD_DAYS: 90,
// 本地数据库备份策略同时适用于 SQLite 与 PostgreSQL。 // 本地数据库备份策略同时适用于 SQLite 与 PostgreSQL。
DB_BACKUP_ENABLE: false, DB_BACKUP_ENABLE: false,
DB_BACKUP_CRON: '0 3 * * *', DB_BACKUP_CRON: '0 3 * * *',
@@ -2695,6 +2701,84 @@ watch(currentLlmSnapshotKey, (snapshotKey, previousSnapshotKey) => {
prepend-inner-icon="mdi-swap-horizontal" prepend-inner-icon="mdi-swap-horizontal"
/> />
</VCol> </VCol>
<VCol cols="12" md="6">
<VTextField
v-model.number="SystemSettings.Advanced.DATA_CLEANUP_DOWNLOAD_FAILURE_DAYS"
:label="t('setting.system.dataCleanupDownloadFailureDays')"
:hint="t('setting.system.dataCleanupDownloadFailureDaysHint')"
persistent-hint
min="0"
type="number"
:suffix="t('setting.system.day')"
:rules="dataCleanupFieldRules"
prepend-inner-icon="mdi-alert-circle-outline"
/>
</VCol>
<VCol cols="12" md="6">
<VTextField
v-model.number="SystemSettings.Advanced.DATA_CLEANUP_SUBSCRIBE_HISTORY_DAYS"
:label="t('setting.system.dataCleanupSubscribeHistoryDays')"
:hint="t('setting.system.dataCleanupSubscribeHistoryDaysHint')"
persistent-hint
min="0"
type="number"
:suffix="t('setting.system.day')"
:rules="dataCleanupFieldRules"
prepend-inner-icon="mdi-calendar-check-outline"
/>
</VCol>
<VCol cols="12" md="6">
<VTextField
v-model.number="SystemSettings.Advanced.DATA_CLEANUP_AGENT_CHAT_DAYS"
:label="t('setting.system.dataCleanupAgentChatDays')"
:hint="t('setting.system.dataCleanupAgentChatDaysHint')"
persistent-hint
min="0"
type="number"
:suffix="t('setting.system.day')"
:rules="dataCleanupFieldRules"
prepend-inner-icon="mdi-message-text-clock-outline"
/>
</VCol>
<VCol cols="12" md="6">
<VTextField
v-model.number="SystemSettings.Advanced.DATA_CLEANUP_AGENT_TASK_RUN_DAYS"
:label="t('setting.system.dataCleanupAgentTaskRunDays')"
:hint="t('setting.system.dataCleanupAgentTaskRunDaysHint')"
persistent-hint
min="0"
type="number"
:suffix="t('setting.system.day')"
:rules="dataCleanupFieldRules"
prepend-inner-icon="mdi-robot-outline"
/>
</VCol>
<VCol cols="12" md="6">
<VTextField
v-model.number="SystemSettings.Advanced.DATA_CLEANUP_OUTBOX_COMPLETED_DAYS"
:label="t('setting.system.dataCleanupOutboxCompletedDays')"
:hint="t('setting.system.dataCleanupOutboxCompletedDaysHint')"
persistent-hint
min="0"
type="number"
:suffix="t('setting.system.day')"
:rules="dataCleanupFieldRules"
prepend-inner-icon="mdi-check-circle-outline"
/>
</VCol>
<VCol cols="12" md="6">
<VTextField
v-model.number="SystemSettings.Advanced.DATA_CLEANUP_OUTBOX_DEAD_DAYS"
:label="t('setting.system.dataCleanupOutboxDeadDays')"
:hint="t('setting.system.dataCleanupOutboxDeadDaysHint')"
persistent-hint
min="0"
type="number"
:suffix="t('setting.system.day')"
:rules="dataCleanupFieldRules"
prepend-inner-icon="mdi-alert-octagon-outline"
/>
</VCol>
</template> </template>
</VRow> </VRow>
</div> </div>
@@ -1111,6 +1111,12 @@ describe('AccountSettingSystem', () => {
await fireEvent.update(dialog.getByLabelText('下载历史表保留天数'), '30') await fireEvent.update(dialog.getByLabelText('下载历史表保留天数'), '30')
await fireEvent.update(dialog.getByLabelText('站点数据表保留天数'), '60') await fireEvent.update(dialog.getByLabelText('站点数据表保留天数'), '60')
await fireEvent.update(dialog.getByLabelText('整理历史表保留天数'), '90') await fireEvent.update(dialog.getByLabelText('整理历史表保留天数'), '90')
await fireEvent.update(dialog.getByLabelText('下载失败记录保留天数'), '7')
await fireEvent.update(dialog.getByLabelText('订阅历史表保留天数'), '365')
await fireEvent.update(dialog.getByLabelText('Agent 会话历史保留天数'), '120')
await fireEvent.update(dialog.getByLabelText('Agent 任务运行历史保留天数'), '60')
await fireEvent.update(dialog.getByLabelText('Outbox 已完成记录保留天数'), '14')
await fireEvent.update(dialog.getByLabelText('Outbox 死信记录保留天数'), '45')
await user.click(dialog.getByRole('tab', { name: '日志' })) await user.click(dialog.getByRole('tab', { name: '日志' }))
await selectOption('日志等级', 'ERROR - 错误') await selectOption('日志等级', 'ERROR - 错误')
@@ -1124,8 +1130,14 @@ describe('AccountSettingSystem', () => {
expect(findPost('system/env')?.[1]).toEqual( expect(findPost('system/env')?.[1]).toEqual(
expect.objectContaining({ expect.objectContaining({
DATA_CLEANUP_DOWNLOAD_HISTORY_DAYS: 30, DATA_CLEANUP_DOWNLOAD_HISTORY_DAYS: 30,
DATA_CLEANUP_DOWNLOAD_FAILURE_DAYS: 7,
DATA_CLEANUP_SUBSCRIBE_HISTORY_DAYS: 365,
DATA_CLEANUP_AGENT_CHAT_DAYS: 120,
DATA_CLEANUP_AGENT_TASK_RUN_DAYS: 60,
DATA_CLEANUP_ENABLE: true, DATA_CLEANUP_ENABLE: true,
DATA_CLEANUP_MESSAGE_DAYS: 0, DATA_CLEANUP_MESSAGE_DAYS: 0,
DATA_CLEANUP_OUTBOX_COMPLETED_DAYS: 14,
DATA_CLEANUP_OUTBOX_DEAD_DAYS: 45,
DATA_CLEANUP_SITE_USERDATA_DAYS: 60, DATA_CLEANUP_SITE_USERDATA_DAYS: 60,
DATA_CLEANUP_TRANSFER_HISTORY_DAYS: 90, DATA_CLEANUP_TRANSFER_HISTORY_DAYS: 90,
DEBUG: true, DEBUG: true,