diff --git a/app/run.py b/app/run.py index 64791a0..596bbd0 100644 --- a/app/run.py +++ b/app/run.py @@ -25,6 +25,8 @@ import base64 import sys import os import re +import random +import time parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) sys.path.insert(0, parent_dir) @@ -683,6 +685,18 @@ def add_task(): # 定时任务执行的函数 def run_python(args): logging.info(f">>> 定时运行任务") + # 检查是否需要随机延迟执行 + if delay := config_data.get("crontab_delay"): + try: + delay_seconds = int(delay) + if delay_seconds > 0: + # 在0到设定值之间随机选择一个延迟时间 + random_delay = random.randint(0, delay_seconds) + logging.info(f">>> 随机延迟执行 {random_delay}秒") + time.sleep(random_delay) + except (ValueError, TypeError): + logging.warning(f">>> 延迟执行设置无效: {delay}") + os.system(f"{PYTHON_PATH} {args}") @@ -708,6 +722,9 @@ def reload_tasks(): logging.info(">>> 重载调度器") logging.info(f"调度状态: {scheduler_state_map[scheduler.state]}") logging.info(f"定时规则: {crontab}") + # 记录延迟执行设置 + if delay := config_data.get("crontab_delay"): + logging.info(f"延迟执行: 0-{delay}秒") logging.info(f"现有任务: {scheduler.get_jobs()}") return True else: @@ -740,6 +757,10 @@ def init(): # 默认定时规则 if not config_data.get("crontab"): config_data["crontab"] = "0 8,18,20 * * *" + + # 默认延迟执行设置 + if "crontab_delay" not in config_data: + config_data["crontab_delay"] = 0 # 初始化插件配置 _, plugins_config_default, task_plugins_config_default = Config.load_plugins() @@ -815,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: @@ -871,10 +949,13 @@ def get_user_info(): "is_active": account.is_active }) else: + # 检查是否有移动端参数 + has_mparam = bool(account.mparam) user_info_list.append({ "index": idx, "nickname": "", - "is_active": False + "is_active": False, + "has_mparam": has_mparam }) return jsonify({"success": True, "data": user_info_list}) diff --git a/app/static/css/main.css b/app/static/css/main.css index da24ce9..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; } /* --------------- 底部按钮 --------------- */ @@ -3724,3 +3728,128 @@ input::-moz-list-button { background-color: #f7f7fa; /* 表头悬停背景色 */ cursor: pointer; } + +/* 移除number类型输入框的上下箭头 */ +input.no-spinner::-webkit-outer-spin-button, +input.no-spinner::-webkit-inner-spin-button { + -webkit-appearance: none; + margin: 0; +} + +/* Firefox也需要特别处理 */ +input.no-spinner { + -moz-appearance: textfield; +} + +/* 秒字框正方形样式 */ +.square-append { + width: 32px; + height: 32px; + display: flex; + align-items: center; + justify-content: center; + padding: 0 !important; +} + +/* 确保Crontab和延迟执行框在移动端也保持一行 */ +@media (max-width: 767.98px) { + .row.mb-2 .col-sm-6 { + flex: 0 0 50%; + max-width: 50%; + } + + .row.mb-2 .col-sm-6.pr-1 { + padding-right: 4px !important; + padding-left: 15px !important; + } + + .row.mb-2 .col-sm-6.pl-1 { + padding-left: 4px !important; + 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 280f0d9..fe2363b 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -252,7 +252,7 @@
- {{ userInfoList[index].nickname || '未登录' }} + {{ userInfoList[index].nickname || (userInfoList[index].has_mparam ? '仅签到' : '未登录') }}
@@ -273,11 +273,26 @@
-
-
- Crontab +
+
+
+
+ Crontab +
+ +
+
+
+
+
+ 延迟执行 +
+ +
+ +
+
-
@@ -670,14 +685,14 @@
- +
- + @@ -685,7 +700,9 @@ - + - + @@ -739,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 }}
-
+
@@ -708,7 +725,7 @@ v-check-overflow="index + '|original_name'"> {{ record.original_name }}
-
+
@@ -722,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 }}