From 51246ea31b4eccebb6a9479452c3f82d64e0849a Mon Sep 17 00:00:00 2001 From: Soulter <37870767+Soulter@users.noreply.github.com> Date: Sun, 26 Oct 2025 17:29:04 +0800 Subject: [PATCH] fix: apply configuration option to enable/disable WebUI in AstrBotDashboard (#3152) --- astrbot/core/initial_loader.py | 9 ++++++--- astrbot/dashboard/server.py | 5 +++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/astrbot/core/initial_loader.py b/astrbot/core/initial_loader.py index b3eeb6e88..c6c01a304 100644 --- a/astrbot/core/initial_loader.py +++ b/astrbot/core/initial_loader.py @@ -41,10 +41,13 @@ class InitialLoader: self.dashboard_server = AstrBotDashboard( core_lifecycle, self.db, core_lifecycle.dashboard_shutdown_event, webui_dir ) - task = asyncio.gather( - core_task, self.dashboard_server.run() - ) # 启动核心任务和仪表板服务器 + coro = self.dashboard_server.run() + if coro: + # 启动核心任务和仪表板服务器 + task = asyncio.gather(core_task, coro) + else: + task = core_task try: await task # 整个AstrBot在这里运行 except asyncio.CancelledError: diff --git a/astrbot/dashboard/server.py b/astrbot/dashboard/server.py index fca650fd0..31507e2ce 100644 --- a/astrbot/dashboard/server.py +++ b/astrbot/dashboard/server.py @@ -178,6 +178,11 @@ class AstrBotDashboard: else: port = self.core_lifecycle.astrbot_config["dashboard"].get("port", 6185) host = self.core_lifecycle.astrbot_config["dashboard"].get("host", "0.0.0.0") + enable = self.core_lifecycle.astrbot_config["dashboard"].get("enable", True) + + if not enable: + logger.info("WebUI 已被禁用") + return logger.info(f"正在启动 WebUI, 监听地址: http://{host}:{port}")