export function renderTemplate(model, template) {
  // 使用正则表达式匹配模板中的占位符
  return template.replace(/\{\{(\w+(\.\w+)?)}}/g, (match, key) => {
    // 根据点分隔符分割键名，逐步访问对象属性
    const keys = key.split('.');
    let value = model;
    for (let k of keys) {
      if (value) { value = value[k]; } else { return match; }
    }
    return value == null ? '' : value;
  });
}

export function appendLocatingPoint(width, height, size, preview = process.env.VUE_APP_C_LODOP_POINT_PREVIEW) {
  this.SET_PRINT_STYLE('PreviewOnly', preview || 1);
  this.ADD_PRINT_SHAPE(4, 0, 0, size, size, 0, 1, '#000000');
  this.ADD_PRINT_SHAPE(4, 0, width - size, size, size, 0, 1, '#000000');
  this.ADD_PRINT_SHAPE(4, height - size, 0, size, size, 0, 1, '#000000');
  this.ADD_PRINT_SHAPE(4, height - size, width - size, size, size, 0, 1, '#000000');
  this.SET_PRINT_STYLE('PreviewOnly', 0);
}
