优化布局和交互

This commit is contained in:
iqudoo
2026-06-14 12:03:05 +08:00
parent 55867ae12d
commit 4955b1f2e2
9 changed files with 454 additions and 15 deletions

View File

@@ -27,6 +27,26 @@ export const VARIABLE_MAPPING_USE_ROW_INDEX = '__use_row_index__';
export const VARIABLE_MAPPING_ROW_INDEX_LABEL = '数据序号';
/** 粘贴副本时相对原位置的偏移 (mm) */
export const PASTE_ELEMENT_OFFSET_MM = 2;
/** 深拷贝元素并生成新 id用于复制/粘贴 */
export function cloneTemplateElementsForPaste(
elements: TemplateElement[],
pasteRepeat: number
): TemplateElement[] {
const offset = PASTE_ELEMENT_OFFSET_MM * Math.max(1, pasteRepeat);
const stamp = Date.now();
return elements.map((element, index) => {
const cloned = JSON.parse(JSON.stringify(element)) as TemplateElement;
cloned.id = `${element.type}_${stamp}_${index}`;
cloned.name = `${element.name} 副本`;
cloned.x = Math.round((element.x + offset) * 10) / 10;
cloned.y = Math.round((element.y + offset) * 10) / 10;
return cloned;
});
}
export function toDataSourceMeta(data: ImportData): DataSourceMeta {
return {
fileName: data.fileName,