From 060c7e0145acceddc9c85155c5b933d5cc1589bc Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Sun, 11 May 2025 18:09:36 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9Bfix:=20=E4=BF=AE=E5=A4=8D=20CLI=20?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E4=B8=8B=E8=B7=AF=E5=BE=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=20WebUI=20=E5=92=8C=20MCP=20Server=20?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E5=8A=A0=E8=BD=BD=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astrbot/dashboard/routes/tools.py | 4 ++-- astrbot/dashboard/server.py | 7 ++----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/astrbot/dashboard/routes/tools.py b/astrbot/dashboard/routes/tools.py index f8cd9c8f6..d38014c71 100644 --- a/astrbot/dashboard/routes/tools.py +++ b/astrbot/dashboard/routes/tools.py @@ -7,6 +7,7 @@ from quart import request from astrbot.core import logger from astrbot.core.core_lifecycle import AstrBotCoreLifecycle +from astrbot.core.utils.astrbot_path import get_astrbot_data_path from .route import Response, Route, RouteContext @@ -31,8 +32,7 @@ class ToolsRoute(Route): @property def mcp_config_path(self): - current_dir = os.path.dirname(os.path.abspath(__file__)) - data_dir = os.path.abspath(os.path.join(current_dir, "../../../data")) + data_dir = get_astrbot_data_path() return os.path.join(data_dir, "mcp_server.json") def load_mcp_config(self): diff --git a/astrbot/dashboard/server.py b/astrbot/dashboard/server.py index e4e4d60b7..5d6a78a6e 100644 --- a/astrbot/dashboard/server.py +++ b/astrbot/dashboard/server.py @@ -13,10 +13,7 @@ from .routes.route import RouteContext, Response from astrbot.core import logger, WEBUI_SK from astrbot.core.db import BaseDatabase from astrbot.core.utils.io import get_local_ip_addresses - -DATAPATH = os.path.abspath( - os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../data") -) +from astrbot.core.utils.astrbot_path import get_astrbot_data_path class AstrBotDashboard: @@ -28,7 +25,7 @@ class AstrBotDashboard: ) -> None: self.core_lifecycle = core_lifecycle self.config = core_lifecycle.astrbot_config - self.data_path = os.path.abspath(os.path.join(DATAPATH, "dist")) + self.data_path = os.path.abspath(os.path.join(get_astrbot_data_path, "dist")) self.app = Quart("dashboard", static_folder=self.data_path, static_url_path="/") self.app.config["MAX_CONTENT_LENGTH"] = ( 128 * 1024 * 1024