静态资源加修改时间版本号,修复部署后浏览器缓存旧 JS 的问题

页面 JS/CSS 引用统一改为 asset_url()(附加 ?v=filemtime):
部署更新文件后浏览器自动拉取新版本,避免出现"新按钮点击无反应"等旧缓存现象。
This commit is contained in:
canglan committed 2026-10-10 16:13:22 +08:00
1 parent 3a13656cfb
commit dbf70f602e
24 files changed
+53 -42

No files matched your search

+11
View File
@@ -153,5 +153,16 @@ function current_group_name() {
return $_SESSION['role'] ?? '';
}
/**
* 静态资源版本号:按文件修改时间附加 ?v=,部署更新后浏览器自动拉取新文件,避免旧 JS/CSS 缓存
*/
function asset_url($path) {
$file = __DIR__ . $path;
if (is_file($file)) {
return $path . '?v=' . filemtime($file);
}
return $path;
}
// 管理员页面自动同步权限(权限组变更后自动生效)
refresh_admin_permissions();