nativeTemplateElementSupport.ts
980 Bytes
/**
* Android NativeTemplateCommandBuilder 仅处理:TEXT_*、QRCODE、BARCODE、IMAGE、
* 以及 border=line 的 BLANK;其余类型在原生路径下会被静默跳过(与画布预览不一致)。
*/
import type { SystemLabelTemplate, SystemTemplateElementBase } from './types/printer'
function isElementHandledByNativeFastPrinter (el: SystemTemplateElementBase): boolean {
const type = String(el.type || '').toUpperCase()
if (type.startsWith('TEXT_')) return true
if (type === 'QRCODE' || type === 'BARCODE' || type === 'IMAGE') return true
if (type === 'BLANK') return true
return false
}
/** 存在任一原生不支持的元素时,预览打印应走光栅,避免「成功但缺内容/不出纸」与画布不一致 */
export function templateHasUnsupportedNativeFastElements (template: SystemLabelTemplate): boolean {
for (const el of template.elements || []) {
if (!isElementHandledByNativeFastPrinter(el)) return true
}
return false
}