This commit is contained in:
949036910@qq.com
2026-06-01 00:03:56 +08:00
parent 6e1f34ac62
commit e827e9425e
3 changed files with 21 additions and 3 deletions

11
src/utils/publicAsset.js Normal file
View File

@@ -0,0 +1,11 @@
/**
* 解析 public/ 目录下的静态资源 URL。
* 开发环境 base 为 `/`,发行部署 base 为 `/images/newyaoyan/`(见 vite.config.js
*
* @param {string} path - 相对 public 的路径,如 subtitle-templates/system-templates.json
*/
export function publicAssetUrl(path) {
const base = import.meta.env.BASE_URL || "/";
const normalized = String(path || "").replace(/^\/+/, "");
return `${base}${normalized}`;
}