From c593f6423c1ce0231fed94a1dc70406b9f762df3 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Sat, 26 Aug 2023 19:58:05 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E9=87=8D=E5=91=BD=E5=90=8D=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/endpoints/filebrowser.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/api/endpoints/filebrowser.py b/app/api/endpoints/filebrowser.py index 36073446..18480fc4 100644 --- a/app/api/endpoints/filebrowser.py +++ b/app/api/endpoints/filebrowser.py @@ -13,6 +13,8 @@ from app.utils.system import SystemUtils router = APIRouter() +IMAGE_TYPES = [".jpg", ".png", ".gif", ".bmp", ".jpeg", ".webp"] + @router.get("/list", summary="所有插件", response_model=List[schemas.FileItem]) def list_path(path: str, _: schemas.TokenPayload = Depends(verify_token)) -> Any: @@ -50,7 +52,8 @@ def list_path(path: str, _: schemas.TokenPayload = Depends(verify_token)) -> Any for item in SystemUtils.list_sub_files(path_obj, settings.RMT_MEDIAEXT + settings.RMT_SUBEXT - + [".jpg", ".png", ".nfo"]): + + IMAGE_TYPES + + [".nfo"]): ret_items.append(schemas.FileItem( type="file", path=str(item), @@ -148,6 +151,6 @@ def image(path: str, token: str) -> Any: if not path_obj.is_file(): return None # 判断是否图片文件 - if path_obj.suffix.lower() not in [".jpg", ".png", ".gif", ".bmp", ".jpeg", ".webp"]: + if path_obj.suffix.lower() not in IMAGE_TYPES: return None return Response(content=path_obj.read_bytes(), media_type="image/jpeg")