HEL-580: version asset URLs to bust stale browser caches

Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
美术师
2026-09-18 19:52:34 +08:00
co-authored by multica-agent
parent b4fdc41256
commit 0e2e5f02de
3 changed files with 12 additions and 4 deletions
+8
View File
@@ -6,6 +6,14 @@ function e(string $v): string
return htmlspecialchars($v, ENT_QUOTES, 'UTF-8');
}
/** 静态资源引用统一加版本号(文件 mtime):文件一变 URL 即变,老用户浏览器无需清缓存 */
function assetUrl(string $path): string
{
$file = __DIR__ . '/../public/' . ltrim($path, '/');
$v = is_file($file) ? filemtime($file) : 0;
return $path . '?v=' . $v;
}
function now(): string
{
return date('Y-m-d H:i:s');
+2 -2
View File
@@ -21,8 +21,8 @@
<html lang="zh-CN"><head><meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>金牛集团贷款档案管理系统 - 登录</title>
<link rel="stylesheet" href="assets/fusion.css">
<script src="assets/fusion.js" defer></script>
<link rel="stylesheet" href="<?= assetUrl('assets/fusion.css') ?>">
<script src="<?= assetUrl('assets/fusion.js') ?>" defer></script>
</head><body>
<div class="v-fusion" data-variant-root>
<script>(function(){try{if(localStorage.getItem('jn_theme')==='night'){document.currentScript.parentElement.setAttribute('data-theme','night');}}catch(e){}})();</script>