From b708c210c77bf28645ab308adee56665a2471ddd Mon Sep 17 00:00:00 2001 From: qinglong Date: Sun, 14 Jun 2026 11:55:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=9D=99=E6=80=81HTML=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?no-cache=E5=A4=B4=20+=20app.js=E2=86=92app=5Fv2.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/web_panel/manager.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/services/web_panel/manager.py b/services/web_panel/manager.py index 530886d..540fce5 100644 --- a/services/web_panel/manager.py +++ b/services/web_panel/manager.py @@ -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)