From abaa40d8196da95a27ec3c968656e3f3f907e104 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Sat, 9 May 2026 21:22:02 +0800 Subject: [PATCH] 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. --- src/locales/en-US.ts | 17 +++++ src/locales/zh-CN.ts | 15 ++++ src/locales/zh-TW.ts | 15 ++++ src/views/setting/AccountSettingSystem.vue | 84 ++++++++++++++++++++++ 4 files changed, 131 insertions(+) diff --git a/src/locales/en-US.ts b/src/locales/en-US.ts index 19e7d9f7..8ab1e6e9 100644 --- a/src/locales/en-US.ts +++ b/src/locales/en-US.ts @@ -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.', diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts index 9de68e24..cee563db 100644 --- a/src/locales/zh-CN.ts +++ b/src/locales/zh-CN.ts @@ -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', diff --git a/src/locales/zh-TW.ts b/src/locales/zh-TW.ts index df57fe90..f2b32880 100644 --- a/src/locales/zh-TW.ts +++ b/src/locales/zh-TW.ts @@ -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', diff --git a/src/views/setting/AccountSettingSystem.vue b/src/views/setting/AccountSettingSystem.vue index e67753d4..4fde21d0 100644 --- a/src/views/setting/AccountSettingSystem.vue +++ b/src/views/setting/AccountSettingSystem.vue @@ -72,6 +72,11 @@ const SystemSettings = ref({ 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) => {
{{ t('setting.system.log') }}
+ +
{{ t('setting.system.data') }}
+
{{ t('setting.system.lab') }}
@@ -1973,6 +1986,77 @@ watch(currentLlmSnapshotKey, (snapshotKey, previousSnapshotKey) => { + +
+ + + + + + + {{ t('setting.system.downloadFilesCleanupNotice') }} + + + + + + + + + + + + + + + +
+