From cf3f3727f9704919bd8c3a8d9ecdbc6846b40378 Mon Sep 17 00:00:00 2001 From: x1ao4 Date: Thu, 22 May 2025 19:03:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=88=A0=E9=99=A4=E8=BD=AC?= =?UTF-8?q?=E5=AD=98=E8=AE=B0=E5=BD=95=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/run.py | 57 ++++++++++++ app/static/css/main.css | 91 +++++++++++++++++- app/templates/index.html | 194 ++++++++++++++++++++++++++++++++++++--- 3 files changed, 327 insertions(+), 15 deletions(-) diff --git a/app/run.py b/app/run.py index 82e16b0..596bbd0 100644 --- a/app/run.py +++ b/app/run.py @@ -836,6 +836,63 @@ def get_history_records(): return jsonify({"success": True, "data": result}) +# 删除转存记录 +@app.route("/delete_history_records", methods=["POST"]) +def delete_history_records(): + if not is_login(): + return jsonify({"success": False, "message": "未登录"}) + + # 获取要删除的记录ID列表 + record_ids = request.json.get("record_ids", []) + + if not record_ids: + return jsonify({"success": False, "message": "未提供要删除的记录ID"}) + + # 初始化数据库 + db = RecordDB() + + # 删除记录 + deleted_count = 0 + for record_id in record_ids: + deleted_count += db.delete_record(record_id) + + return jsonify({ + "success": True, + "message": f"成功删除 {deleted_count} 条记录", + "deleted_count": deleted_count + }) + + +# 删除单条转存记录 +@app.route("/delete_history_record", methods=["POST"]) +def delete_history_record(): + if not is_login(): + return jsonify({"success": False, "message": "未登录"}) + + # 获取要删除的记录ID + record_id = request.json.get("id") + + if not record_id: + return jsonify({"success": False, "message": "未提供要删除的记录ID"}) + + # 初始化数据库 + db = RecordDB() + + # 删除记录 + deleted = db.delete_record(record_id) + + if deleted: + return jsonify({ + "success": True, + "message": "成功删除 1 条记录", + }) + else: + return jsonify({ + "success": False, + "message": "记录删除失败,可能记录不存在", + }) + + # 辅助函数:格式化记录 def format_records(records): for record in records: diff --git a/app/static/css/main.css b/app/static/css/main.css index 685390c..f4a70c1 100644 --- a/app/static/css/main.css +++ b/app/static/css/main.css @@ -92,6 +92,8 @@ body.login-page { left: 50%; transform: translate(-50%, -50%); z-index: 9999; + width: auto; + max-width: 80%; } .toast-custom { @@ -100,13 +102,15 @@ body.login-page { box-shadow: 0 3px 7px rgba(0, 0, 0, 0.1); border: none; border-radius: 6px; + margin: 0 auto; } .toast-body-custom { text-align: center; - padding: 1rem 0.75rem; + padding: 1rem 1.2rem; color: #fff; font-size: 0.95rem; + white-space: nowrap; } /* --------------- 底部按钮 --------------- */ @@ -3764,3 +3768,88 @@ input.no-spinner { padding-right: 15px !important; } } + +/* --------------- 转存记录相关样式 --------------- */ +.selected-record { + background-color: var(--button-gray-background-color) !important; +} + +/* 删除按钮样式 */ +.delete-record-btn { + color: #dc3545; + cursor: pointer; + display: inline-flex; + align-items: center; + justify-content: center; + width: 24px; + height: 24px; + border-radius: 4px; + transition: background-color 0.2s ease; + visibility: hidden; /* 默认隐藏 */ +} + +/* 删除按钮图标大小 */ +.delete-record-btn .bi-trash3 { + font-size: 1rem; +} + +/* 选中行或鼠标悬停行时显示删除按钮 */ +tr.selected-record .delete-record-btn, +.selectable-records tbody tr:hover .delete-record-btn { + visibility: visible; +} + +/* 表头中的删除按钮仅在有选中行时显示 */ +table th .delete-record-btn { + visibility: hidden; +} + +/* 禁止在表格中选择文本,以便更好地支持点击选择 */ +table.selectable-records { + user-select: none; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; +} + +table.selectable-records tbody tr { + cursor: pointer; +} + +/* 修改表格行悬停样式,使用变量保持一致性 */ +table.selectable-records tbody tr:hover { + background-color: var(--button-gray-background-color); +} + +/* 确保展开按钮在选中状态下仍然可见 */ +tr.selected-record .expand-button { + z-index: 2; +} + +/* 当鼠标悬停在展开按钮或删除按钮上时,不改变按钮的背景色 */ +table.selectable-records .expand-button:hover, +table.selectable-records .delete-record-btn:hover { + background-color: transparent !important; +} + +/* 选中行或鼠标悬停行的大小列样式 */ +tr.selected-record .file-size-cell .file-size-value, +.selectable-records tbody tr:hover .file-size-cell .file-size-value { + display: none; /* 隐藏文件大小信息 */ +} + +tr.selected-record .file-size-cell .delete-record-btn, +.selectable-records tbody tr:hover .file-size-cell .delete-record-btn { + display: flex; + justify-content: flex-start; /* 居左对齐 */ + align-items: center; + width: auto; + height: 100%; + margin-left: 0; /* 确保没有左边距 */ + padding-left: 0; /* 确保没有左内边距 */ +} + +/* 当鼠标悬停在展开按钮或删除按钮上时,不改变按钮的背景色 */ +table.selectable-records .expand-button:hover { + background-color: #fff !important; /* 保持展开按钮原有的白色背景 */ +} diff --git a/app/templates/index.html b/app/templates/index.html index 664f447..fe2363b 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -685,14 +685,14 @@
- +
- + @@ -700,7 +700,9 @@ - + - + @@ -754,7 +761,7 @@
- 显示 {{ history.pagination && history.pagination.total_records > 0 ? ((historyParams.page - 1) * historyParams.page_size + 1) + '-' + Math.min(historyParams.page * historyParams.page_size, history.pagination.total_records) : '0' }} 条,共 {{ history.pagination ? history.pagination.total_records : 0 }} 条记录 + 显示 {{ history.pagination && history.pagination.total_records > 0 ? ((historyParams.page - 1) * historyParams.page_size + 1) + '-' + Math.min(historyParams.page * historyParams.page_size, history.pagination.total_records) : '0' }} 条,共 {{ history.pagination ? history.pagination.total_records : 0 }} 条记录{{ selectedRecords.length > 0 ? ',已选中 ' + selectedRecords.length + ' 条记录' : '' }}
转存日期 任务名称 原文件 转存为 大小 大小 修改日期
暂无记录
{{ record.transfer_time_readable }}
{{ record.task_name }}
-
+
@@ -723,7 +725,7 @@ v-check-overflow="index + '|original_name'"> {{ record.original_name }}
-
+
@@ -737,14 +739,19 @@ v-check-overflow="index + '|renamed_to'"> {{ record.renamed_to }}
-
+
{{ record.renamed_to }}
{{ record.file_size_readable }} + {{ record.file_size_readable }} + + + + {{ record.modify_date_readable }}