fix: 静态文件no-cache + app.js重命名防缓存

This commit is contained in:
qinglong
2026-06-14 11:54:18 +08:00
parent a79af7484d
commit ae553b564d
3 changed files with 367 additions and 2 deletions
+6 -1
View File
@@ -63,7 +63,12 @@ class WebPanelManager:
# URL 前缀: /SenSu/static/ -> 物理路径: .../static/web_panel/
static_dir = self.project_root / "static" / "web_panel"
if static_dir.exists():
app.router.add_static(f'{self.base_path}/static/', path=str(static_dir))
# 静态文件添加 no-cache
async def _static_handler(request):
resp = await static_handler(request)
resp.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate'
return resp
app.router.add_static(f'{self.base_path}/static/', path=str(static_dir))
logger.info(f"📂 静态资源已挂载: {self.base_path}/static/")
else:
logger.warning(f"⚠️ 静态目录缺失: {static_dir}")