优化调整辅助线等

This commit is contained in:
24kycj
2025-12-10 01:40:03 +08:00
parent 378593047d
commit 026d564c92
8 changed files with 1591 additions and 965 deletions
+60
View File
@@ -2576,10 +2576,22 @@ function handleObjectSelected() {
$('#component_type').text(language_str('bg')) //comfirm
return
}
// 如果是辅助线,直接返回,不处理
if (select_obj.isGuideLine) {
return
}
let i = getIndex(select_obj)
if (i != 0) {
//不是背景
--i
// 安全检查:确保 objs[i] 存在且有 type 属性
if (!objs[i] || typeof objs[i].type === 'undefined') {
return
}
switch (objs[i].type) {
case 1:
//console.log("图片");
@@ -2721,10 +2733,22 @@ canvas1.on('mouse:down', (e) => {
canvas = canvas1;
objs = objs1;
let select_obj = canvas.getActiveObject()
// 如果是辅助线,直接返回,不处理
if (select_obj && select_obj.isGuideLine) {
return
}
let i = getIndex(select_obj, canvas)
if (i != 0) {
//不是背景
--i
// 安全检查:确保 objs[i] 存在且有 type 属性
if (!objs[i] || typeof objs[i].type === 'undefined') {
return
}
switch (objs[i].type) {
case 1:
$('#component_type').text(language_str('img'))
@@ -2811,8 +2835,20 @@ canvas1.on('object:modified', function (event) {
if (canvas1.getActiveObjects().length > 1) {
return
}
// 跳过辅助线
if (event.target.isGuideLine) {
return
}
let idx = getIndex(event.target, canvas1);
if (idx <= 0) return;
// 安全检查:确保 objs[idx - 1] 存在且有 type 属性
if (!objs[idx - 1] || typeof objs[idx - 1].type === 'undefined') {
return
}
if (objs[idx - 1].type == 3) {
event.target.fontSize *= event.target.scaleX
event.target.fontSize = event.target.fontSize.toFixed(0)
@@ -3011,10 +3047,22 @@ canvas2.on('mouse:down', (e) => {
canvas = canvas2;
objs = objs2;
let select_obj = canvas.getActiveObject()
// 如果是辅助线,直接返回,不处理
if (select_obj && select_obj.isGuideLine) {
return
}
let i = getIndex(select_obj, canvas)
if (i != 0) {
//不是背景
--i
// 安全检查:确保 objs[i] 存在且有 type 属性
if (!objs[i] || typeof objs[i].type === 'undefined') {
return
}
switch (objs[i].type) {
case 1:
$('#component_type').text(language_str('img'))
@@ -3097,8 +3145,20 @@ canvas2.on('object:modified', function (event) {
if (canvas.getActiveObjects().length > 1) {
return
}
// 跳过辅助线
if (event.target.isGuideLine) {
return
}
let idx = getIndex(event.target, canvas2);
if (idx <= 0) return;
// 安全检查:确保 objs[idx - 1] 存在且有 type 属性
if (!objs[idx - 1] || typeof objs[idx - 1].type === 'undefined') {
return
}
if (objs[idx - 1].type == 3) {
event.target.fontSize *= event.target.scaleX
event.target.fontSize = event.target.fontSize.toFixed(0)