This commit is contained in:
lzp
2026-03-20 13:59:53 +08:00
parent e00fe21e95
commit 8390d79e5f
2 changed files with 6 additions and 16 deletions

View File

@@ -29,17 +29,6 @@ fabric.Object.prototype.toObject = function () {
return object
}
fabric.Image.fromURL = (function (originalFromURL) {
return function (url, callback, imgOptions) {
// 为所有图片请求添加 crossOrigin
const options = {
crossOrigin: 'anonymous', // 关键设置
...imgOptions
};
return originalFromURL.call(this, url, callback, options);
};
})(fabric.Image.fromURL);
interface CanvasInitOptions {
canvasRef: any
canvasViewWidth?: number
@@ -317,6 +306,7 @@ export class CanvasManager {
}
if (object.src) {
object.src = create(object.src)
object.crossOrigin = 'anonymous'
}
if (object.fill?.source) {
object.fill.source = create(object.fill.source)

View File

@@ -156,10 +156,10 @@ export class LayerManager {
const child = options?.child || []
delete options.child
const groupObject = new fabric.Group(child, {
subTargetCheck: true, // 关键:检测子对象
interactive: true, // 启用交互
hasControls: true,
hasBorders: true,
// subTargetCheck: true, // 关键:检测子对象
// interactive: true, // 启用交互
// hasControls: true,
// hasBorders: true,
// // 子对象样式
// cornerColor: 'blue',
@@ -368,7 +368,7 @@ export class LayerManager {
}
})
resolve(img)
})
}, { crossOrigin: 'anonymous' })
})
// console.log(mergedImage)
const index = this.canvasManager.getObjects().indexOf(targetLayer);