|
@@ -36,15 +36,27 @@ export function generateAdConfig(input: GenerateInput): string {
|
|
|
lines.push(`import specialUrl from "/assets/user/${files.special}?url";`);
|
|
lines.push(`import specialUrl from "/assets/user/${files.special}?url";`);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // == 模板自有素材 ==
|
|
|
|
|
|
|
+ // == 模板自有素材(用户上传则优先使用)==
|
|
|
lines.push("");
|
|
lines.push("");
|
|
|
lines.push("// ==== 模板自有素材 ====");
|
|
lines.push("// ==== 模板自有素材 ====");
|
|
|
lines.push(`import numberFontUrl from "/assets/fonts/numbers_roboto_500.png?url";`);
|
|
lines.push(`import numberFontUrl from "/assets/fonts/numbers_roboto_500.png?url";`);
|
|
|
lines.push(`import fingerUrl from "/assets/img/finger.png?url";`);
|
|
lines.push(`import fingerUrl from "/assets/img/finger.png?url";`);
|
|
|
- lines.push(`import logoUrl from "/assets/img/logo.png?url";`);
|
|
|
|
|
- lines.push(`import logoTxtUrl from "/assets/img/logo-txt.png?url";`);
|
|
|
|
|
- lines.push(`import coloringPagesUrl from "/assets/img/coloring-pages.png?url";`);
|
|
|
|
|
- lines.push(`import slogonUrl from "/assets/img/slogon.png?url";`);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 可替换素材:优先用用户上传的,否则用模板默认
|
|
|
|
|
+ const replaceableAssets = [
|
|
|
|
|
+ { key: "logo", file: "logo.png", var: "logoUrl", defaultPath: "/assets/img/logo.png" },
|
|
|
|
|
+ { key: "logoTxt", file: "logo-txt.png", var: "logoTxtUrl", defaultPath: "/assets/img/logo-txt.png" },
|
|
|
|
|
+ { key: "slogon", file: "slogon.png", var: "slogonUrl", defaultPath: "/assets/img/slogon.png" },
|
|
|
|
|
+ { key: "coloringPages", file: "coloring-pages.png", var: "coloringPagesUrl", defaultPath: "/assets/img/coloring-pages.png" },
|
|
|
|
|
+ ];
|
|
|
|
|
+ for (const a of replaceableAssets) {
|
|
|
|
|
+ const userFile = (files as unknown as Record<string, string | null>)[a.key];
|
|
|
|
|
+ if (userFile) {
|
|
|
|
|
+ lines.push(`import ${a.var} from "/assets/user/${userFile}?url";`);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ lines.push(`import ${a.var} from "${a.defaultPath}?url";`);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// == adAssets 导出 ==
|
|
// == adAssets 导出 ==
|
|
|
lines.push("");
|
|
lines.push("");
|