调整优化

This commit is contained in:
24kycj
2025-12-15 02:55:54 +08:00
parent 50ff0d347a
commit 3c4080f3f1
8 changed files with 3048 additions and 3407 deletions
+25 -13
View File
@@ -346,8 +346,6 @@ window.display_func = function display_func(img1, img2, img3) {
// 只处理导出(保存PDF
if (typeof window.savePdf === 'function') {
window.savePdf(Buffer.from(pdfBuffer));
} else {
console.error('savePdf 函数未定义!');
}
},
btn2: function () {
@@ -1045,8 +1043,9 @@ function saveAs(op1, callback) {
}
})
let j = canvas1.toJSON(['selectable', 'hoverable', 'hoverCursor', 'text', 'fontStyle', 'fontWeight', 'underline'])
let b = canvas2.toJSON(['selectable', 'hoverable', 'hoverCursor', 'text', 'fontStyle', 'fontWeight', 'underline'])
const props = window.TO_JSON_PROPERTIES || ['selectable', 'hoverable', 'hoverCursor', 'text', 'fontStyle', 'fontWeight', 'underline', 'evented'];
let j = canvas1.toJSON(props)
let b = canvas2.toJSON(props)
// 恢复辅助线
guideLines1.forEach(obj => canvas1.add(obj))
@@ -1112,8 +1111,9 @@ function save(op1, callback) {
}
})
let j = canvas1.toJSON(['selectable', 'hoverable', 'hoverCursor', 'text', 'fontStyle', 'fontWeight', 'underline'])
let b = canvas2.toJSON(['selectable', 'hoverable', 'hoverCursor', 'text', 'fontStyle', 'fontWeight', 'underline'])
const props = window.TO_JSON_PROPERTIES || ['selectable', 'hoverable', 'hoverCursor', 'text', 'fontStyle', 'fontWeight', 'underline', 'evented'];
let j = canvas1.toJSON(props)
let b = canvas2.toJSON(props)
// 恢复辅助线
guideLines1.forEach(obj => canvas1.add(obj))
@@ -1248,15 +1248,31 @@ window.openFile = function open(file) {
// 加载 JSON,并在回调中重新生成二维码和条形码
canvas1.loadFromJSON(j.f, function () {
// 加载后解锁所有对象(背景除外)
if (typeof window.unlockAllObjects === 'function') {
window.unlockAllObjects(canvas1);
}
if (typeof window.regenerateQrCodesAndBarcodes === 'function') {
window.regenerateQrCodesAndBarcodes(canvas1, fo);
}
// 加载后更新列表和图标显示
if (typeof window.updateList === 'function') {
window.updateList();
}
canvas1.renderAll()
})
canvas2.loadFromJSON(j.b, function () {
// 加载后解锁所有对象(背景除外)
if (typeof window.unlockAllObjects === 'function') {
window.unlockAllObjects(canvas2);
}
if (typeof window.regenerateQrCodesAndBarcodes === 'function') {
window.regenerateQrCodesAndBarcodes(canvas2, bo);
}
// 加载后更新列表和图标显示
if (typeof window.updateList === 'function') {
window.updateList();
}
canvas2.renderAll()
})
background_image1 = canvas1.getObjects()[0]
@@ -1296,19 +1312,18 @@ window.openFile = function open(file) {
setTimeout(() => {
if (typeof window.updateList === 'function') {
window.updateList();
} else {
console.error('[open函数] ❌ updateList 函数未定义!');
}
}, 100);
}
setTimeout(() => {
recordObjs1.push(JSON.stringify(objs1))
let j1 = canvas1.toJSON(['selectable', 'hoverable', 'hoverCursor', 'text', 'fontStyle', 'fontWeight', 'underline'])
const props = window.TO_JSON_PROPERTIES || ['selectable', 'hoverable', 'hoverCursor', 'text', 'fontStyle', 'fontWeight', 'underline', 'evented'];
let j1 = canvas1.toJSON(props)
j1.objects[0].hoverCursor = 'default'
recordJson1.push(j1)
recordObjs2.push(JSON.stringify(objs2))
let j2 = canvas2.toJSON(['selectable', 'hoverable', 'hoverCursor', 'text', 'fontStyle', 'fontWeight', 'underline'])
let j2 = canvas2.toJSON(props)
j2.objects[0].hoverCursor = 'default'
recordJson2.push(j2)
}, 0)
@@ -1359,12 +1374,9 @@ function clearAll() {
setTimeout(() => {
if (typeof window.updateList === 'function') {
window.updateList();
} else {
console.error('[clearAll] ❌ updateList 函数未定义!');
}
}, 100);
}
console.log()
}
// 将 clearAll 附加到 window 对象,确保全局可访问