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 个 +