fix: offline.html离线页面路径增加 BASE_URL 前缀,适配子目录部署

之前路径硬编码为绝对路径,导致应用部署在非根目录时出现 404 错误。
现改为动态拼接 process.env.BASE_URL 以支持不同环境的部署路径。
This commit is contained in:
lkj 2026-01-14 22:42:58 +08:00
parent a8c13d740b
commit ec7efb9ebf

View file

@ -41,7 +41,7 @@ workbox.core.skipWaiting();
workbox.core.clientsClaim();
// 预缓存离线页面
const OFFLINE_URL = '/offline.html';
const OFFLINE_URL = process.env.BASE_URL + 'offline.html';
workbox.precaching.precacheAndRoute([
{ url: OFFLINE_URL, revision: null }
]);