## 主要修复 - 修复Creo软件运行状态检测失败问题 - 添加完整的软件停止功能支持 - 改进多进程软件的进程管理逻辑 ## 技术改进 - 更新软件配置支持多进程名称检测 - 优化进程停止逻辑,增加超时配置 - 新增 stop_software WebSocket消息类型 - 完善错误处理和日志记录 ## 配置更新 - configs/software_config.yaml: 支持进程名称列表和停止超时 - 添加Revit 2017配置支持 ## 文档更新 - README.md: 更新软件配置说明和API列表 - frontend-api-docs.md: 添加停止软件API文档 - CHECKPOINT.md: 记录修复进展和解决方案 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
81 lines
2.3 KiB
Python
81 lines
2.3 KiB
Python
import os
|
|
from typing import List, Optional
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
import yaml
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
"""应用配置类"""
|
|
model_config = SettingsConfigDict(
|
|
env_file=".env",
|
|
env_file_encoding="utf-8"
|
|
)
|
|
|
|
# 基础配置
|
|
app_name: str = "CadHubManage"
|
|
debug: bool = False
|
|
host: str = "0.0.0.0"
|
|
port: int = 8000
|
|
|
|
# JWT配置
|
|
secret_key: str = "your-secret-key-change-in-production"
|
|
algorithm: str = "HS256"
|
|
access_token_expire_minutes: int = 30
|
|
refresh_token_expire_days: int = 7
|
|
|
|
# 软件配置文件路径
|
|
software_config_path: str = "configs/software_config.yaml"
|
|
users_config_path: str = "configs/users.json"
|
|
|
|
|
|
# CORS配置
|
|
cors_origins: List[str] = ["*"]
|
|
|
|
# 日志配置
|
|
log_level: str = "INFO"
|
|
log_file: str = "logs/app.log"
|
|
|
|
# 安全配置
|
|
allowed_ips: List[str] = ["*"]
|
|
|
|
|
|
class SoftwareConfig:
|
|
"""软件配置管理类"""
|
|
|
|
def __init__(self, config_path: str):
|
|
self.config_path = config_path
|
|
self._config = None
|
|
|
|
def load_config(self) -> dict:
|
|
"""加载软件配置"""
|
|
try:
|
|
with open(self.config_path, 'r', encoding='utf-8') as f:
|
|
self._config = yaml.safe_load(f)
|
|
return self._config
|
|
except FileNotFoundError:
|
|
raise FileNotFoundError(f"软件配置文件未找到: {self.config_path}")
|
|
except yaml.YAMLError as e:
|
|
raise ValueError(f"软件配置文件格式错误: {e}")
|
|
|
|
def get_software_list(self) -> List[str]:
|
|
"""获取可用软件列表"""
|
|
if not self._config:
|
|
self.load_config()
|
|
|
|
return list(self._config.get('software', {}).keys())
|
|
|
|
def get_software_config(self, software_id: str) -> Optional[dict]:
|
|
"""获取特定软件配置"""
|
|
if not self._config:
|
|
self.load_config()
|
|
|
|
return self._config.get('software', {}).get(software_id)
|
|
|
|
def validate_software_exists(self, software_id: str) -> bool:
|
|
"""验证软件是否存在于配置中"""
|
|
return software_id in self.get_software_list()
|
|
|
|
|
|
# 创建全局配置实例
|
|
settings = Settings()
|
|
software_config = SoftwareConfig(settings.software_config_path) |