From be9ec5e9a268d68f3b6f8bafbe99d7c6f5a44bfc Mon Sep 17 00:00:00 2001 From: yuyx <237899745@qq.com> Date: Wed, 7 Jan 2026 23:56:16 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=94=A8=E6=88=B7=E7=AB=AF=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E9=87=91=E5=B1=B1=E6=96=87=E6=A1=A3=E5=9C=A8=E7=BA=BF?= =?UTF-8?q?=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 /api/kdocs/status 接口(用户端简化版) - 工具栏显示"表格上传: ✅ 就绪"或"⚠️ 离线" - 页面加载时获取状态,每60秒自动刷新 - 系统未启用时不显示 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- routes/api_user.py | 34 ++++++++++++++++++++++++++++++++++ templates/index.html | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/routes/api_user.py b/routes/api_user.py index 8055d15..cb40502 100644 --- a/routes/api_user.py +++ b/routes/api_user.py @@ -348,3 +348,37 @@ def get_run_stats(): "today_attachments": stats.get("total_attachments", 0), } ) + + +@api_user_bp.route("/api/kdocs/status", methods=["GET"]) +@login_required +def get_kdocs_status_for_user(): + """获取金山文档在线状态(用户端简化版)""" + try: + # 检查系统是否启用了金山文档功能 + cfg = database.get_system_config() or {} + kdocs_enabled = int(cfg.get("kdocs_enabled") or 0) + + if not kdocs_enabled: + return jsonify({"enabled": False, "online": False, "message": "未启用"}) + + # 获取金山文档状态 + from services.kdocs_uploader import get_kdocs_uploader + + kdocs = get_kdocs_uploader() + status = kdocs.get_status() + + login_required_flag = status.get("login_required", False) + last_login_ok = status.get("last_login_ok") + + # 判断是否在线 + is_online = not login_required_flag and last_login_ok is True + + return jsonify({ + "enabled": True, + "online": is_online, + "message": "就绪" if is_online else "离线" + }) + except Exception as e: + logger.error(f"获取金山文档状态失败: {e}") + return jsonify({"enabled": False, "online": False, "message": "获取失败"}) diff --git a/templates/index.html b/templates/index.html index 3bcd845..5f78d9c 100644 --- a/templates/index.html +++ b/templates/index.html @@ -552,6 +552,12 @@ 已选 0 +