diff --git a/app/run.py b/app/run.py index be2f470..2392e3c 100644 --- a/app/run.py +++ b/app/run.py @@ -1358,12 +1358,66 @@ def delete_history_records(): deleted_count += db.delete_record(record_id) return jsonify({ - "success": True, + "success": True, "message": f"成功删除 {deleted_count} 条记录", "deleted_count": deleted_count }) +# 获取任务最新转存记录日期 +@app.route("/task_latest_records") +def get_task_latest_records(): + if not is_login(): + return jsonify({"success": False, "message": "未登录"}) + + try: + # 初始化数据库 + db = RecordDB() + + # 获取所有任务的最新转存记录 + cursor = db.conn.cursor() + query = """ + SELECT task_name, MAX(transfer_time) as latest_transfer_time + FROM transfer_records + WHERE task_name != 'rename' + GROUP BY task_name + """ + cursor.execute(query) + results = cursor.fetchall() + + # 转换为字典格式 + task_latest_records = {} + for row in results: + task_name, latest_time = row + if latest_time: + try: + # 确保时间戳在合理范围内 + timestamp = int(latest_time) + if timestamp > 9999999999: # 检测是否为毫秒级时间戳(13位) + timestamp = timestamp / 1000 # 转换为秒级时间戳 + + if 0 < timestamp < 4102444800: # 从1970年到2100年的合理时间戳范围 + # 格式化为月-日格式 + date_obj = datetime.fromtimestamp(timestamp) + formatted_date = date_obj.strftime("%m-%d") + task_latest_records[task_name] = formatted_date + except (ValueError, TypeError, OverflowError): + pass # 忽略无效的时间戳 + + db.close() + + return jsonify({ + "success": True, + "data": task_latest_records + }) + + except Exception as e: + return jsonify({ + "success": False, + "message": f"获取任务最新记录失败: {str(e)}" + }) + + # 删除单条转存记录 @app.route("/delete_history_record", methods=["POST"]) def delete_history_record(): diff --git a/app/static/css/main.css b/app/static/css/main.css index 5154eb2..27e6fe9 100644 --- a/app/static/css/main.css +++ b/app/static/css/main.css @@ -4055,24 +4055,45 @@ table.selectable-records .expand-button:hover { } } +/* 任务最近更新日期样式 */ +.task-latest-date { + color: var(--dark-text-color); + font-size: 0.95rem; + font-weight: normal; + opacity: 1; + transition: opacity 0.2s ease; +} + +/* 悬停显示模式 */ +.task .btn:not(:hover) .task-latest-date.hover-only { + opacity: 0; +} + +.task .btn:hover .task-latest-date.hover-only { + opacity: 1; +} + +/* 显示设置行样式 */ +.display-setting-row > [class*='col-'] { + padding-left: 4px !important; + padding-right: 4px !important; +} + +.display-setting-row { + margin-left: -4px !important; + margin-right: -4px !important; +} + @media (min-width: 992px) { .display-setting-row > .col-lg-3 { padding-left: 4px !important; padding-right: 4px !important; } - .display-setting-row { - margin-left: -4px !important; - margin-right: -4px !important; - } } -.display-setting-row > [class*='col-'] { - padding-left: 4px !important; - padding-right: 4px !important; -} -.display-setting-row { - margin-left: -4px !important; - margin-right: -4px !important; +/* 调整显示设置第二行的上边距,使其与第一行保持8px间距 */ +.display-setting-row + .display-setting-row { + margin-top: -8px !important; } /* 文件整理性能设置样式 */ diff --git a/app/templates/index.html b/app/templates/index.html index b854762..41dfb67 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -705,6 +705,20 @@ +
+
+
+
+ 最近更新日期 +
+ +
+
+
@@ -781,6 +795,11 @@
# + + · {{ taskLatestRecords[task.taskname] }} +
@@ -1613,7 +1632,8 @@ run_task: "always", delete_task: "always", refresh_plex: "always", - refresh_alist: "always" + refresh_alist: "always", + latest_update_date: "always" }, file_performance: { api_page_size: 200, @@ -1642,6 +1662,7 @@ taskDirs: [""], taskDirSelected: "", taskNameFilter: "", + taskLatestRecords: {}, // 存储每个任务的最新转存记录日期 modalLoading: false, smart_param: { index: null, @@ -2538,9 +2559,14 @@ run_task: "always", delete_task: "always", refresh_plex: "always", - refresh_alist: "always" + refresh_alist: "always", + latest_update_date: "always" }; } + // 确保最近更新日期配置存在(向后兼容) + if (!config_data.button_display.latest_update_date) { + config_data.button_display.latest_update_date = "always"; + } // 确保文件整理性能配置存在 if (!config_data.file_performance) { config_data.file_performance = { @@ -2563,7 +2589,10 @@ setTimeout(() => { this.configModified = false; }, 100); - + + // 加载任务最新记录 + this.loadTaskLatestRecords(); + // 数据加载完成后检查分享链接状态 if (this.activeTab === 'tasklist') { setTimeout(() => { @@ -4138,6 +4167,20 @@ } }); }, + loadTaskLatestRecords() { + // 获取所有任务的最新转存记录日期 + axios.get('/task_latest_records') + .then(response => { + if (response.data.success) { + this.taskLatestRecords = response.data.data; + } else { + console.error('获取任务最新记录失败:', response.data.message); + } + }) + .catch(error => { + console.error('获取任务最新记录失败:', error); + }); + }, openDatePicker(index) { // 使用$refs访问对应的日期选择器并打开它 const dateRef = this.$refs[`enddate_${index}`];