优化
This commit is contained in:
12
src/utils.ts
12
src/utils.ts
@@ -524,7 +524,7 @@ export function extractTemplateVariables(template: {
|
||||
vars.add(v);
|
||||
}
|
||||
for (const rule of resolveVisibilityRules(elem)) {
|
||||
const name = rule.variable.trim();
|
||||
const name = (rule.variable ?? '').trim();
|
||||
if (name) vars.add(name);
|
||||
}
|
||||
}
|
||||
@@ -539,7 +539,7 @@ export function getUsedTemplateVariables(template: { elements: TemplateElement[]
|
||||
vars.add(v);
|
||||
}
|
||||
for (const rule of resolveVisibilityRules(elem)) {
|
||||
const name = rule.variable.trim();
|
||||
const name = (rule.variable ?? '').trim();
|
||||
if (name) vars.add(name);
|
||||
}
|
||||
}
|
||||
@@ -613,7 +613,7 @@ export function resolveVisibilityRules(elem: TemplateElement): VisibilityRule[]
|
||||
return elem.visibilityRules
|
||||
.map((r) => ({
|
||||
target: r.target ?? 'variable',
|
||||
variable: r.variable.trim(),
|
||||
variable: (r.variable ?? '').trim(),
|
||||
operator: r.operator,
|
||||
value: r.value,
|
||||
}))
|
||||
@@ -1021,7 +1021,7 @@ export function resolveElementValue(
|
||||
return applyTextDisplayAffix(core, elem);
|
||||
}
|
||||
|
||||
/** 输出模式下条码/二维码/图片内容为空时不渲染 */
|
||||
/** 输出模式下条码/二维码/图片内容为空时不渲染(除非 showWhenContentEmpty 为 true) */
|
||||
export function isGraphicContentEmpty(
|
||||
elem: TemplateElement,
|
||||
value: string,
|
||||
@@ -1029,7 +1029,9 @@ export function isGraphicContentEmpty(
|
||||
): boolean {
|
||||
if (mode === 'design') return false;
|
||||
if (elem.type !== 'barcode' && elem.type !== 'qrcode' && elem.type !== 'image') return false;
|
||||
return !value || !String(value).trim();
|
||||
const empty = !value || !String(value).trim();
|
||||
if (!empty) return false;
|
||||
return !elem.showWhenContentEmpty;
|
||||
}
|
||||
|
||||
// Generate columns and rows based on paper dimensions, label dimensions, gaps, and margins
|
||||
|
||||
Reference in New Issue
Block a user