From c8e34ff26ff27de269569be0615c827c992e178d Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Sun, 2 Nov 2025 12:52:46 +0800 Subject: [PATCH] [WIP] Translate mixed English comments to Chinese (#3256) * Initial plan * Changes before error encountered Co-authored-by: LIghtJUNction <106986785+LIghtJUNction@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: LIghtJUNction <106986785+LIghtJUNction@users.noreply.github.com> --- astrbot/dashboard/routes/chat.py | 8 ++++---- astrbot/dashboard/server.py | 2 +- main.py | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/astrbot/dashboard/routes/chat.py b/astrbot/dashboard/routes/chat.py index 6954f2d6..5156e14e 100644 --- a/astrbot/dashboard/routes/chat.py +++ b/astrbot/dashboard/routes/chat.py @@ -134,10 +134,10 @@ class ChatRoute(Route): if not conversation_id: return Response().error("conversation_id is empty").__dict__ - # append user message + # 追加用户消息 webchat_conv_id = await self._get_webchat_conv_id_from_conv_id(conversation_id) - # Get conversation-specific queues + # 获取会话特定的队列 back_queue = webchat_queue_mgr.get_or_create_back_queue(webchat_conv_id) new_his = {"type": "user", "message": message} @@ -200,7 +200,7 @@ class ChatRoute(Route): or not streaming or type == "break" ): - # append bot message + # 追加机器人消息 new_his = {"type": "bot", "message": result_text} await self.platform_history_mgr.insert( platform_id="webchat", @@ -212,7 +212,7 @@ class ChatRoute(Route): except BaseException as e: logger.exception(f"WebChat stream unexpected error: {e}", exc_info=True) - # Put message to conversation-specific queue + # 将消息放入会话特定的队列 chat_queue = webchat_queue_mgr.get_or_create_queue(webchat_conv_id) await chat_queue.put( ( diff --git a/astrbot/dashboard/server.py b/astrbot/dashboard/server.py index 775983ef..3fb988a6 100644 --- a/astrbot/dashboard/server.py +++ b/astrbot/dashboard/server.py @@ -105,7 +105,7 @@ class AstrBotDashboard: allowed_endpoints = ["/api/auth/login", "/api/file"] if any(request.path.startswith(prefix) for prefix in allowed_endpoints): return None - # claim jwt + # 声明 JWT token = request.headers.get("Authorization") if not token: r = jsonify(Response().error("未授权").__dict__) diff --git a/main.py b/main.py index b453cdfb..60879f06 100644 --- a/main.py +++ b/main.py @@ -11,7 +11,7 @@ from astrbot.core.initial_loader import InitialLoader from astrbot.core.utils.astrbot_path import get_astrbot_data_path from astrbot.core.utils.io import download_dashboard, get_dashboard_version -# add parent path to sys.path +# 将父目录添加到 sys.path sys.path.append(Path(__file__).parent.as_posix()) logo_tmpl = r""" @@ -34,7 +34,7 @@ def check_env(): os.makedirs("data/plugins", exist_ok=True) os.makedirs("data/temp", exist_ok=True) - # workaround for issue #181 + # 针对问题 #181 的临时解决方案 mimetypes.add_type("text/javascript", ".js") mimetypes.add_type("text/javascript", ".mjs") mimetypes.add_type("application/json", ".json") @@ -53,7 +53,7 @@ async def check_dashboard_files(webui_dir: str | None = None): if os.path.exists(data_dist_path): v = await get_dashboard_version() if v is not None: - # has file + # 存在文件 if v == f"v{VERSION}": logger.info("WebUI 版本已是最新。") else: @@ -88,16 +88,16 @@ if __name__ == "__main__": check_env() - # start log broker + # 启动日志代理 log_broker = LogBroker() LogManager.set_queue_handler(logger, log_broker) - # check dashboard files + # 检查仪表板文件 webui_dir = asyncio.run(check_dashboard_files(args.webui_dir)) db = db_helper - # print logo + # 打印 logo logger.info(logo_tmpl) core_lifecycle = InitialLoader(db, log_broker)