fix: 静态HTML添加no-cache头 + app.js→app_v2.js

This commit is contained in:
qinglong
2026-06-14 11:55:06 +08:00
parent ae553b564d
commit b708c210c7
+9 -8
View File
@@ -63,12 +63,7 @@ class WebPanelManager:
# URL 前缀: /SenSu/static/ -> 物理路径: .../static/web_panel/
static_dir = self.project_root / "static" / "web_panel"
if static_dir.exists():
# 静态文件添加 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))
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}")
@@ -108,11 +103,17 @@ class WebPanelManager:
async def _serve_index(self, req):
"""提供登录页"""
path = req.app['panel_config']['index_path']
if path.exists(): return web.FileResponse(path)
if path.exists():
resp = web.FileResponse(path)
resp.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate'
return resp
return web.Response(text=f"❌ 找不到 index.html\n路径: {path}", status=404)
async def _serve_home(self, req):
"""提供面板主页"""
path = req.app['panel_config']['home_path']
if path.exists(): return web.FileResponse(path)
if path.exists():
resp = web.FileResponse(path)
resp.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate'
return resp
return web.Response(text=f"❌ 找不到 home.html\n路径: {path}", status=404)