Revert " 启用压缩并兼容统一主题资源路径"

This reverts commit f093a8ac6d.
This commit is contained in:
Orion
2026-07-21 17:33:11 +08:00
parent f093a8ac6d
commit 6bed5fb76d
+1 -7
View File
@@ -10,7 +10,6 @@ from contextlib import asynccontextmanager
from fastapi import FastAPI from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import FileResponse, HTMLResponse, PlainTextResponse from fastapi.responses import FileResponse, HTMLResponse, PlainTextResponse
from starlette.middleware.gzip import GZipMiddleware
from tortoise import Tortoise from tortoise import Tortoise
from tortoise.contrib.fastapi import register_tortoise from tortoise.contrib.fastapi import register_tortoise
@@ -121,8 +120,6 @@ async def migrate_password_to_hash():
app = FastAPI(lifespan=lifespan) app = FastAPI(lifespan=lifespan)
app.add_middleware(GZipMiddleware, minimum_size=1024, compresslevel=6)
@app.middleware("http") @app.middleware("http")
async def refresh_settings_middleware(request, call_next): async def refresh_settings_middleware(request, call_next):
await refresh_settings() await refresh_settings()
@@ -154,11 +151,8 @@ app.include_router(admin_api)
@app.get("/theme-assets/{asset_path:path}") @app.get("/theme-assets/{asset_path:path}")
@app.get("/assets/{asset_path:path}") @app.get("/assets/{asset_path:path}")
async def theme_asset(asset_path: str): async def theme_asset(asset_path: str):
# Vite with base=/theme-assets/ emits /theme-assets/assets/<file> while
# legacy themes use /theme-assets/<file>. Keep both forms compatible.
normalized_asset_path = asset_path.removeprefix("assets/")
theme_assets = (BASE_DIR / settings.themesSelect / "assets").resolve() theme_assets = (BASE_DIR / settings.themesSelect / "assets").resolve()
target = (theme_assets / normalized_asset_path).resolve() target = (theme_assets / asset_path).resolve()
try: try:
target.relative_to(theme_assets) target.relative_to(theme_assets)
except ValueError: except ValueError: