feat:读取前端版本号

This commit is contained in:
jxxghp
2024-04-25 10:18:14 +08:00
parent 44cd5f52e0
commit 1714990e2e
3 changed files with 23 additions and 0 deletions

View File

@ -10,6 +10,7 @@ from fastapi.responses import StreamingResponse
from app import schemas
from app.chain.search import SearchChain
from app.chain.system import SystemChain
from app.core.config import settings
from app.core.module import ModuleManager
from app.core.security import verify_token
@ -50,10 +51,12 @@ def get_env_setting(_: schemas.TokenPayload = Depends(verify_token)):
info = settings.dict(
exclude={"SECRET_KEY", "SUPERUSER_PASSWORD"}
)
frontend_version = SystemChain().get_frontend_version()
info.update({
"VERSION": APP_VERSION,
"AUTH_VERSION": SitesHelper().auth_version,
"INDEXER_VERSION": SitesHelper().indexer_version,
"FRONTEND_VERSION": frontend_version
})
return schemas.Response(success=True,
data=info)

View File

@ -1,5 +1,6 @@
import json
import re
from pathlib import Path
from typing import Union
from app.chain import ChainBase
@ -117,3 +118,20 @@ class SystemChain(ChainBase, metaclass=Singleton):
return None
except Exception as err:
logger.error(f"加载版本文件 {version_file} 出错:{str(err)}")
@staticmethod
def get_frontend_version():
"""
获取前端版本
"""
version_file = Path(settings.FRONTEND_PATH) / "version.txt"
if version_file.exists():
try:
with open(version_file, 'r') as f:
version = str(f).strip()
return version
except Exception as err:
logger.error(f"加载版本文件 {version_file} 出错:{str(err)}")
else:
logger.warn("未找到前端版本文件,请正确设置 FRONTEND_PATH")
return None

View File

@ -13,6 +13,8 @@ class Settings(BaseSettings):
PROJECT_NAME = "MoviePilot"
# API路径
API_V1_STR: str = "/api/v1"
# 前端资源路径
FRONTEND_PATH: str = "/public"
# 密钥
SECRET_KEY: str = secrets.token_urlsafe(32)
# 允许的域名