feat: 支持通过配置独立控制 JS/CSS 资源缓存版本号#27
Merged
Merged
Conversation
新增 `admin.assets_version` 配置项(对应 `ADMIN_ASSETS_VERSION` 环境变量), 允许用户自定义附加在 JS/CSS URL 上的缓存破坏版本参数,不再强制跟随框架版本。 设为空值时不添加任何版本查询参数。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
原有实现中,JS/CSS URL 的缓存破坏版本参数(
?v2.3.10-beta)强制使用框架版本号(Admin::VERSION),用户无法单独控制,导致升级框架时才能让浏览器重新加载资源,反之亦然。相关上游 issue:jqhph/dcat-admin#2177
改动
src/Layout/Asset.php—withVersionQuery()优先读取config('admin.assets_version'),为空时 fallback 到Admin::VERSION;值为空字符串/null时不附加任何版本查询参数config/admin.php— 新增assets_version配置项,支持ADMIN_ASSETS_VERSION环境变量src/Console/stubs/config.stub— 同步更新 stub,新安装项目自动带上该配置README.md— 在新增功能列表中注明此特性使用方式
在
.env中设置:或在
config/admin.php中直接写值。留空(默认)则沿用框架版本号;显式设为空字符串则不添加任何版本查询参数。