feat: 添加基建配置文件设置接口

This commit is contained in:
DLmaster361
2025-08-17 15:54:54 +08:00
parent 8e2c6bb642
commit 515367f61f
6 changed files with 52 additions and 7 deletions

View File

@@ -829,6 +829,26 @@ class AppConfig(GlobalConfig):
await script_config.UserData.setOrder([uuid.UUID(_) for _ in index_list])
await self.ScriptConfig.save()
async def set_infrastructure(
self, script_id: str, user_id: str, jsonFile: str
) -> None:
logger.info(f"{script_id} - {user_id} 设置基建配置:{jsonFile}")
json_path = Path(jsonFile)
if not json_path.exists():
raise FileNotFoundError(f"File not found: {json_path}")
(Path.cwd() / f"data/{script_id}/{user_id}/Infrastructure").mkdir(
parents=True, exist_ok=True
)
shutil.copy(
json_path,
Path.cwd()
/ f"data/{script_id}/{user_id}/Infrastructure/infrastructure.json",
)
async def add_plan(
self, script: Literal["MaaPlan"]
) -> tuple[uuid.UUID, ConfigBase]: