From 7a578fac47422bd295771a8bc536ef02e417ef7c Mon Sep 17 00:00:00 2001 From: Yongquan Date: Sun, 1 Nov 2026 12:47:41 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9D=99=E6=80=81=E8=B5=84=E6=BA=90=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E6=94=B6=E6=95=9B=E5=88=B0=20FB=5FASSET=5FV=20?= =?UTF-8?q?=E5=B8=B8=E9=87=8F=20(#1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原先 layout.php 与 install.php 各写一份 style.css?v=N,改样式时只改一处, 另一处会漂移 —— 实际就发生了:首页 v=10、安装页还是 v=7,两页样式不一致。 现在统一在 lib/bootstrap.php 定义 FB_ASSET_V,两处都引用它。 以后改 assets 下的 css/js,只改这一个数字。 --- install.php | 2 +- lib/bootstrap.php | 3 +++ lib/layout.php | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/install.php b/install.php index ea98d99..95532a3 100644 --- a/install.php +++ b/install.php @@ -245,7 +245,7 @@ if (isset($_POST['do_install'])) { - +
diff --git a/lib/bootstrap.php b/lib/bootstrap.php index e098922..7fdf26a 100644 --- a/lib/bootstrap.php +++ b/lib/bootstrap.php @@ -6,6 +6,9 @@ if (!defined('FB_ROOT')) { define('FB_ROOT', dirname(__DIR__)); + // 静态资源版本号:改 assets/ 下的 css/js 后把这个数字 +1, + // 让浏览器与 CDN 缓存失效。全站只此一处,别再往页面里写死数字。 + if (!defined('FB_ASSET_V')) { define('FB_ASSET_V', 10); } } /* ------------------------------------------------------------------ diff --git a/lib/layout.php b/lib/layout.php index 393ce86..5798e8a 100644 --- a/lib/layout.php +++ b/lib/layout.php @@ -27,7 +27,7 @@ function fb_layout_head($title, array $opt = []) { - +