feat: add data cleanup settings tab

Expose the cleanup switch and per-table retention periods in advanced settings so administrators can manage data cleanup from the UI.
This commit is contained in:
jxxghp
2026-05-09 21:22:02 +08:00
parent 0d05a104c4
commit abaa40d819
4 changed files with 131 additions and 0 deletions

View File

@@ -1442,6 +1442,7 @@ export default {
media: 'Media',
network: 'Network',
log: 'Log',
data: 'Data',
lab: 'Lab',
downloaderSaveSuccess: 'Downloader settings saved successfully',
downloaderSaveFailed: 'Failed to save downloader settings!',
@@ -1539,6 +1540,21 @@ export default {
logBackupCountMin: 'Maximum number of log file backups must be greater than or equal to 1',
logFileFormat: 'Log File Format',
logFileFormatHint: 'Set the output format of log files to customize the displayed content of logs',
dataCleanupEnable: 'Enable Data Cleanup',
dataCleanupEnableHint: 'When disabled, scheduled data cleanup tasks will be skipped',
dataCleanupDaysRequired: 'Please enter a cleanup retention period',
dataCleanupDaysMin: 'Cleanup retention period must be greater than or equal to 0',
dataCleanupMessageDays: 'Message Retention Days',
dataCleanupMessageDaysHint: 'Unit: days. Set to 0 to skip cleanup for the message table',
dataCleanupDownloadHistoryDays: 'Download History Retention Days',
dataCleanupDownloadHistoryDaysHint:
'Unit: days. Set to 0 to skip cleanup for download history and its related orphaned download file records',
dataCleanupSiteUserDataDays: 'Site User Data Retention Days',
dataCleanupSiteUserDataDaysHint: 'Unit: days. Set to 0 to skip cleanup for the site user data table',
dataCleanupTransferHistoryDays: 'Transfer History Retention Days',
dataCleanupTransferHistoryDaysHint: 'Unit: days. Set to 0 to skip cleanup for the transfer history table',
downloadFilesCleanupNotice:
'The download files table has no independent timestamp field. Its orphan record cleanup follows the retention period of download history.',
pluginAutoReload: 'Plugin Hot Reload',
pluginAutoReloadHint: 'Automatically reload after modifying plugin files, used when developing plugins',
pluginLocalRepoPaths: 'Local Plugin Repository Paths',
@@ -1585,6 +1601,7 @@ export default {
},
mb: 'MB',
hour: 'hour',
day: 'day',
customizeWallpaperApi: 'Customize Wallpaper Api',
customizeWallpaperApiHint:
'It will get the image file extension format images that are allowed in settings in the content returned by the API.',

View File

@@ -1428,6 +1428,7 @@ export default {
media: '媒体',
network: '网络',
log: '日志',
data: '数据',
lab: '实验室',
downloaderSaveSuccess: '下载器设置保存成功',
downloaderSaveFailed: '下载器设置保存失败!',
@@ -1519,6 +1520,19 @@ export default {
logBackupCountMin: '日志文件最大备份数量必须大于等于1',
logFileFormat: '日志文件格式',
logFileFormatHint: '设置日志文件的输出格式,用于自定义日志的显示内容',
dataCleanupEnable: '启用数据清理',
dataCleanupEnableHint: '总开关关闭时将跳过定时数据清理任务',
dataCleanupDaysRequired: '请输入清理周期',
dataCleanupDaysMin: '清理周期必须大于等于0',
dataCleanupMessageDays: '消息表保留天数',
dataCleanupMessageDaysHint: '单位0 表示不清理消息表数据',
dataCleanupDownloadHistoryDays: '下载历史表保留天数',
dataCleanupDownloadHistoryDaysHint: '单位0 表示不清理下载历史及其关联的下载文件孤儿记录',
dataCleanupSiteUserDataDays: '站点数据表保留天数',
dataCleanupSiteUserDataDaysHint: '单位0 表示不清理站点用户数据表',
dataCleanupTransferHistoryDays: '整理历史表保留天数',
dataCleanupTransferHistoryDaysHint: '单位0 表示不清理整理历史表',
downloadFilesCleanupNotice: '下载文件表没有独立时间字段,会跟随下载历史表的保留周期清理其孤儿记录。',
pluginAutoReload: '插件热加载',
pluginAutoReloadHint: '修改插件文件后自动重新加载,开发插件时使用',
pluginLocalRepoPaths: '本地插件仓库路径',
@@ -1562,6 +1576,7 @@ export default {
},
mb: 'MB',
hour: '小时',
day: '天',
customizeWallpaperApi: '自定义壁纸API地址',
customizeWallpaperApiHint: '会获取API返回内容中所有允许的安全域名地址的图片需要同步设置安全域名地址',
customizeWallpaperApiRequired: '必填项请输入自定义壁纸API',

View File

@@ -1430,6 +1430,7 @@ export default {
media: '媒體',
network: '網絡',
log: '日誌',
data: '數據',
lab: '實驗室',
downloaderSaveSuccess: '下載器設置保存成功',
downloaderSaveFailed: '下載器設置保存失敗!',
@@ -1521,6 +1522,19 @@ export default {
logBackupCountMin: '日誌文件最大備份數量必須大於等於1',
logFileFormat: '日誌文件格式',
logFileFormatHint: '設置日誌文件的輸出格式,用於自定義日誌的顯示內容',
dataCleanupEnable: '啟用數據清理',
dataCleanupEnableHint: '總開關關閉時將跳過定時數據清理任務',
dataCleanupDaysRequired: '請輸入清理週期',
dataCleanupDaysMin: '清理週期必須大於等於0',
dataCleanupMessageDays: '消息表保留天數',
dataCleanupMessageDaysHint: '單位0 表示不清理消息表數據',
dataCleanupDownloadHistoryDays: '下載歷史表保留天數',
dataCleanupDownloadHistoryDaysHint: '單位0 表示不清理下載歷史及其關聯的下載文件孤兒記錄',
dataCleanupSiteUserDataDays: '站點數據表保留天數',
dataCleanupSiteUserDataDaysHint: '單位0 表示不清理站點用戶數據表',
dataCleanupTransferHistoryDays: '整理歷史表保留天數',
dataCleanupTransferHistoryDaysHint: '單位0 表示不清理整理歷史表',
downloadFilesCleanupNotice: '下載文件表沒有獨立時間欄位,會跟隨下載歷史表的保留週期清理其孤兒記錄。',
pluginAutoReload: '插件熱加載',
pluginAutoReloadHint: '修改插件文件後自動重新加載,開發插件時使用',
pluginLocalRepoPaths: '本地插件倉庫路徑',
@@ -1564,6 +1578,7 @@ export default {
},
mb: 'MB',
hour: '小時',
day: '天',
customizeWallpaperApi: '自定義壁紙API',
customizeWallpaperApiHint: '會獲取 API 返回內容中所有安全設置中允許的圖片地址,需要設置安全域名白名單',
customizeWallpaperApiRequired: '必填項請輸出自定義壁紙API',

View File

@@ -72,6 +72,11 @@ const SystemSettings = ref<any>({
DB_WAL_ENABLE: false,
AUTO_UPDATE_RESOURCE: true,
MOVIEPILOT_AUTO_UPDATE: false,
DATA_CLEANUP_ENABLE: false,
DATA_CLEANUP_MESSAGE_DAYS: 90,
DATA_CLEANUP_DOWNLOAD_HISTORY_DAYS: 180,
DATA_CLEANUP_SITE_USERDATA_DAYS: 180,
DATA_CLEANUP_TRANSFER_HISTORY_DAYS: 365 * 3,
// 媒体
RECOGNIZE_PLUGIN_FIRST: false,
MEDIA_RECOGNIZE_SHARE: true,
@@ -406,6 +411,11 @@ const logLevelItems = [
{ title: t('setting.system.logLevelItems.critical'), value: 'CRITICAL' },
]
const dataCleanupFieldRules = [
(v: any) => v === 0 || !!v || t('setting.system.dataCleanupDaysRequired'),
(v: any) => v >= 0 || t('setting.system.dataCleanupDaysMin'),
]
// 安全域名添加变量
const newSecurityDomain = ref('')
@@ -1520,6 +1530,9 @@ watch(currentLlmSnapshotKey, (snapshotKey, previousSnapshotKey) => {
<VTab value="log">
<div>{{ t('setting.system.log') }}</div>
</VTab>
<VTab value="data">
<div>{{ t('setting.system.data') }}</div>
</VTab>
<VTab value="dev">
<div>{{ t('setting.system.lab') }}</div>
</VTab>
@@ -1973,6 +1986,77 @@ watch(currentLlmSnapshotKey, (snapshotKey, previousSnapshotKey) => {
</VRow>
</div>
</VWindowItem>
<VWindowItem value="data">
<div>
<VRow>
<VCol cols="12">
<VSwitch
v-model="SystemSettings.Advanced.DATA_CLEANUP_ENABLE"
:label="t('setting.system.dataCleanupEnable')"
:hint="t('setting.system.dataCleanupEnableHint')"
persistent-hint
/>
</VCol>
<VCol cols="12">
<VAlert type="info" variant="tonal">
{{ t('setting.system.downloadFilesCleanupNotice') }}
</VAlert>
</VCol>
<VCol cols="12" md="6">
<VTextField
v-model.number="SystemSettings.Advanced.DATA_CLEANUP_MESSAGE_DAYS"
:label="t('setting.system.dataCleanupMessageDays')"
:hint="t('setting.system.dataCleanupMessageDaysHint')"
persistent-hint
min="0"
type="number"
:suffix="t('setting.system.day')"
:rules="dataCleanupFieldRules"
prepend-inner-icon="mdi-email-outline"
/>
</VCol>
<VCol cols="12" md="6">
<VTextField
v-model.number="SystemSettings.Advanced.DATA_CLEANUP_DOWNLOAD_HISTORY_DAYS"
:label="t('setting.system.dataCleanupDownloadHistoryDays')"
:hint="t('setting.system.dataCleanupDownloadHistoryDaysHint')"
persistent-hint
min="0"
type="number"
:suffix="t('setting.system.day')"
:rules="dataCleanupFieldRules"
prepend-inner-icon="mdi-download-circle-outline"
/>
</VCol>
<VCol cols="12" md="6">
<VTextField
v-model.number="SystemSettings.Advanced.DATA_CLEANUP_SITE_USERDATA_DAYS"
:label="t('setting.system.dataCleanupSiteUserDataDays')"
:hint="t('setting.system.dataCleanupSiteUserDataDaysHint')"
persistent-hint
min="0"
type="number"
:suffix="t('setting.system.day')"
:rules="dataCleanupFieldRules"
prepend-inner-icon="mdi-chart-line"
/>
</VCol>
<VCol cols="12" md="6">
<VTextField
v-model.number="SystemSettings.Advanced.DATA_CLEANUP_TRANSFER_HISTORY_DAYS"
:label="t('setting.system.dataCleanupTransferHistoryDays')"
:hint="t('setting.system.dataCleanupTransferHistoryDaysHint')"
persistent-hint
min="0"
type="number"
:suffix="t('setting.system.day')"
:rules="dataCleanupFieldRules"
prepend-inner-icon="mdi-swap-horizontal"
/>
</VCol>
</VRow>
</div>
</VWindowItem>
<VWindowItem value="dev">
<div>
<VRow>