优化调整bug与加密

This commit is contained in:
24kycj
2026-01-11 01:06:02 +08:00
parent f4aef8abaa
commit c26c4fa66e
19 changed files with 124 additions and 966 deletions
+15 -14
View File
@@ -16,7 +16,7 @@ window.display_func = function display_func(img1, img2, img3) {
$('#component_type').text(language_str('bg')) //"背景"
canvas1.discardActiveObject().renderAll()
canvas2.discardActiveObject().renderAll()
// 保存所有对象的 selectable 和 evented 状态,确保预览后能恢复
const objStates1 = [];
const objStates2 = [];
@@ -36,7 +36,7 @@ window.display_func = function display_func(img1, img2, img3) {
};
}
});
// 过滤掉辅助线
let _objs1 = canvas1.getObjects().filter(obj => !obj.isGuideLine)
let g1 = []
@@ -362,7 +362,7 @@ window.display_func = function display_func(img1, img2, img3) {
// 打印背面(两面都有时,btn3 对应 btns[2] = '打印背面'
printJS({ printable: printPath4, type: 'image', style: 'img { width: 100%; height: auto; }' })
},
end: function() {
end: function () {
// 预览窗口关闭后,恢复所有对象的 selectable 和 evented 状态
canvas1.getObjects().forEach((obj, index) => {
if (!obj.isGuideLine && objStates1[index]) {
@@ -981,8 +981,9 @@ window.regenerateQrCodesAndBarcodes = function regenerateQrCodesAndBarcodes(canv
margin: 0,
lineColor: objMeta.color || '#000000',
fontSize: objMeta.fontSize || 18,
font: objMeta.font || 'Arial'
})
font: objMeta.font || 'Arial',
displayValue: !objMeta.show
});
const barcode = document.getElementById('barcode')
const bar = barcode.toDataURL("image/png")
obj.setSrc(bar, function (img) {
@@ -1255,7 +1256,7 @@ window.openFile = function open(file) {
recordJson2 = []
recordObjs1 = []
recordObjs2 = []
// 同步更新 window 变量
window.objs1 = objs1
window.objs2 = objs2
@@ -1265,7 +1266,7 @@ window.openFile = function open(file) {
window.recordJson2 = recordJson2
window.recordObjs1 = recordObjs1
window.recordObjs2 = recordObjs2
if ($('#front_side').hasClass('ui-button-active')) {
objs = objs1
recordObjs = recordObjs1
@@ -1291,11 +1292,11 @@ window.openFile = function open(file) {
// 使用 Promise 确保两个画布都加载完成后再保存初始状态
let canvas1Loaded = false
let canvas2Loaded = false
function saveInitialState() {
// 两个画布都加载完成后才保存初始状态
if (!canvas1Loaded || !canvas2Loaded) return
// 确保使用正确的 objs1 和 objs2(从文件加载的 fo 和 bo
// 注意:必须使用 fo 和 bo,因为它们是直接从文件 JSON 中读取的
// 同时确保 objs1 和 objs2 也被正确设置
@@ -1303,13 +1304,13 @@ window.openFile = function open(file) {
objs2 = bo || []
window.objs1 = objs1
window.objs2 = objs2
// 更新背景图引用
background_image1 = canvas1.getObjects()[0]
background_image2 = canvas2.getObjects()[0]
window.background_image1 = background_image1
window.background_image2 = background_image2
if ($('#front_side').hasClass('ui-button-active')) {
background_image = background_image1
window.background_image = background_image1
@@ -1321,7 +1322,7 @@ window.openFile = function open(file) {
objs = objs2
window.objs = objs2
}
// 保存初始状态(使用从文件加载的 objs 数组)
recordObjs1.push(JSON.stringify(objs1))
const props = window.TO_JSON_PROPERTIES || ['selectable', 'hoverable', 'hoverCursor', 'text', 'fontStyle', 'fontWeight', 'underline', 'evented', 'linethrough', 'textBackgroundColor', 'diameter', 'flipped'];
@@ -1333,7 +1334,7 @@ window.openFile = function open(file) {
let j2 = canvas2.toJSON(props)
j2.objects[0].hoverCursor = 'default'
recordJson2.push(j2)
// 同步更新 window 变量和局部变量
window.recordObjs1 = recordObjs1
window.recordJson1 = recordJson1
@@ -1350,7 +1351,7 @@ window.openFile = function open(file) {
step = step2
}
}
canvas1.loadFromJSON(j.f, function () {
// 加载后解锁所有对象(背景除外)
if (typeof window.unlockAllObjects === 'function') {