11
This commit is contained in:
11
src/utils/publicAsset.js
Normal file
11
src/utils/publicAsset.js
Normal 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}`;
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
/** 字幕模板预览样式(对齐 Electron SubtitlePreviewCard) */
|
||||
|
||||
import { publicAssetUrl } from "./publicAsset.js";
|
||||
|
||||
const ACCENT_KEYWORDS = [
|
||||
"自己",
|
||||
"节奏",
|
||||
@@ -240,11 +242,14 @@ export function resolveSubtitlePreviewImage(path) {
|
||||
const normalized = path.replace(/\\/g, "/");
|
||||
if (normalized.includes("subtitle-preview-")) {
|
||||
const name = normalized.split("/").pop();
|
||||
return `/subtitle-templates/previews/${name}`;
|
||||
return publicAssetUrl(`subtitle-templates/previews/${name}`);
|
||||
}
|
||||
if (normalized.startsWith("extra/common/cover-templates/")) {
|
||||
const name = normalized.split("/").pop();
|
||||
return `/subtitle-templates/previews/${name}`;
|
||||
return publicAssetUrl(`subtitle-templates/previews/${name}`);
|
||||
}
|
||||
if (normalized.startsWith("subtitle-templates/")) {
|
||||
return publicAssetUrl(normalized);
|
||||
}
|
||||
return normalized;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user