🧹 清理调试日志

- 移除日志弹窗调试日志
- 移除openModal调试日志
- 移除账号API调试日志
- 移除账号加载调试日志

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-10 20:11:18 +08:00
parent fc7ef70259
commit 2e7dc95d55
2 changed files with 5 additions and 43 deletions

14
app.py
View File

@@ -1030,7 +1030,6 @@ def load_user_accounts(user_id):
user_accounts[user_id] = {} user_accounts[user_id] = {}
accounts_data = database.get_user_accounts(user_id) accounts_data = database.get_user_accounts(user_id)
print(f"[加载账号] 用户{user_id} 从数据库获取到 {len(accounts_data)} 条记录")
for acc_data in accounts_data: for acc_data in accounts_data:
account = Account( account = Account(
account_id=acc_data['id'], account_id=acc_data['id'],
@@ -1041,7 +1040,6 @@ def load_user_accounts(user_id):
remark=acc_data['remark'] or '' remark=acc_data['remark'] or ''
) )
user_accounts[user_id][account.id] = account user_accounts[user_id][account.id] = account
print(f"[加载账号] 加载: {account.id} -> {account.username}")
# ==================== Bug反馈API用户端 ==================== # ==================== Bug反馈API用户端 ====================
@@ -1149,23 +1147,13 @@ def delete_feedback_api(feedback_id):
def get_accounts(): def get_accounts():
"""获取当前用户的所有账号""" """获取当前用户的所有账号"""
user_id = current_user.id user_id = current_user.id
print(f"[账号API] 请求来自用户{user_id} (类型:{type(user_id).__name__}), user_accounts keys: {list(user_accounts.keys())}")
# 检查是否需要强制刷新(容器重启后内存数据丢失)
refresh = request.args.get('refresh', 'false').lower() == 'true' refresh = request.args.get('refresh', 'false').lower() == 'true'
# 如果user_accounts中没有数据或者请求刷新则从数据库加载 # 如果user_accounts中没有数据或者请求刷新则从数据库加载
not_in = user_id not in user_accounts if user_id not in user_accounts or len(user_accounts.get(user_id, {})) == 0 or refresh:
is_empty = len(user_accounts.get(user_id, {})) == 0
need_load = not_in or is_empty or refresh
print(f"[账号API] 检查: not_in={not_in}, empty={is_empty}, refresh={refresh}, need_load={need_load}")
if need_load:
load_user_accounts(user_id) load_user_accounts(user_id)
print(f"[账号API] 加载后有 {len(user_accounts.get(user_id, {}))} 个账号")
accounts = user_accounts.get(user_id, {}) accounts = user_accounts.get(user_id, {})
print(f"[账号API] 返回 {len(accounts)} 个账号")
return jsonify([acc.to_dict() for acc in accounts.values()]) return jsonify([acc.to_dict() for acc in accounts.values()])

View File

@@ -1331,45 +1331,28 @@
if (schedule) openScheduleModal(schedule); if (schedule) openScheduleModal(schedule);
} }
function viewScheduleLogs(scheduleId) { function viewScheduleLogs(scheduleId) {
console.log('[日志弹窗] 开始查看日志, scheduleId=', scheduleId, '(类型:', typeof scheduleId + ')');
console.log('[日志弹窗] 当前schedules数组:', schedules);
// 类型转换确保兼容性
const numericId = parseInt(scheduleId, 10); const numericId = parseInt(scheduleId, 10);
const schedule = schedules.find(s => s.id == numericId);
const schedule = schedules.find(s => s.id == numericId); // 使用宽松相等
if (!schedule) { if (!schedule) {
console.error('[日志弹窗] 未找到任务, scheduleId=', scheduleId);
console.error('[日志弹窗] 可用的任务IDs:', schedules.map(s => s.id));
showToast('未找到该定时任务', 'error'); showToast('未找到该定时任务', 'error');
return; return;
} }
console.log('[日志弹窗] 找到任务:', schedule);
document.getElementById("scheduleLogsTitle").textContent = "【" + (schedule.name || "未命名任务") + "】 执行日志"; document.getElementById("scheduleLogsTitle").textContent = "【" + (schedule.name || "未命名任务") + "】 执行日志";
console.log('[日志弹窗] 开始请求API');
fetch("/api/schedules/" + numericId + "/logs?limit=20") fetch("/api/schedules/" + numericId + "/logs?limit=20")
.then(r => { .then(r => r.json())
console.log('[日志弹窗] API响应状态:', r.status);
return r.json();
})
.then(logs => { .then(logs => {
console.log('[日志弹窗] 收到日志数据:', logs);
const container = document.getElementById("scheduleLogsList"); const container = document.getElementById("scheduleLogsList");
if (!container) { if (!container) {
console.error('[日志弹窗] 找不到日志容器元素 scheduleLogsList');
showToast('页面元素加载异常', 'error'); showToast('页面元素加载异常', 'error');
return; return;
} }
if (!logs || logs.length === 0) { if (!logs || logs.length === 0) {
console.log('[日志弹窗] 无日志,显示空状态');
container.innerHTML = "<div class=\"empty-state\"><p>暂无执行日志</p></div>"; container.innerHTML = "<div class=\"empty-state\"><p>暂无执行日志</p></div>";
} else { } else {
console.log('[日志弹窗] 渲染', logs.length, '条日志');
let html = "<div style=\"display: flex; flex-direction: column; gap: 12px;\">"; let html = "<div style=\"display: flex; flex-direction: column; gap: 12px;\">";
logs.forEach(log => { logs.forEach(log => {
const statusClass = log.status === "success" ? "status-completed" : (log.status === "failed" ? "status-error" : "status-running"); const statusClass = log.status === "success" ? "status-completed" : (log.status === "failed" ? "status-error" : "status-running");
@@ -1390,12 +1373,9 @@
container.innerHTML = html; container.innerHTML = html;
} }
console.log('[日志弹窗] 准备打开弹窗');
openModal("scheduleLogsModal"); openModal("scheduleLogsModal");
console.log('[日志弹窗] 弹窗已打开');
}) })
.catch(err => { .catch(err => {
console.error('[日志弹窗] 请求失败:', err);
showToast("加载日志失败", "error"); showToast("加载日志失败", "error");
}); });
} }
@@ -1735,13 +1715,7 @@
// ==================== 通用函数 ==================== // ==================== 通用函数 ====================
function openModal(id) { function openModal(id) {
const element = document.getElementById(id); const element = document.getElementById(id);
console.log('[openModal] 打开弹窗:', id, '元素:', element); if (element) element.classList.add('active');
if (element) {
element.classList.add('active');
console.log('[openModal] 已添加active类, classList:', element.classList);
} else {
console.error('[openModal] 未找到元素:', id);
}
} }
function closeModal(id) { function closeModal(id) {
const element = document.getElementById(id); const element = document.getElementById(id);