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