111
This commit is contained in:
@@ -29,17 +29,6 @@ fabric.Object.prototype.toObject = function () {
|
|||||||
return object
|
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 {
|
interface CanvasInitOptions {
|
||||||
canvasRef: any
|
canvasRef: any
|
||||||
canvasViewWidth?: number
|
canvasViewWidth?: number
|
||||||
@@ -317,6 +306,7 @@ export class CanvasManager {
|
|||||||
}
|
}
|
||||||
if (object.src) {
|
if (object.src) {
|
||||||
object.src = create(object.src)
|
object.src = create(object.src)
|
||||||
|
object.crossOrigin = 'anonymous'
|
||||||
}
|
}
|
||||||
if (object.fill?.source) {
|
if (object.fill?.source) {
|
||||||
object.fill.source = create(object.fill.source)
|
object.fill.source = create(object.fill.source)
|
||||||
|
|||||||
@@ -156,10 +156,10 @@ export class LayerManager {
|
|||||||
const child = options?.child || []
|
const child = options?.child || []
|
||||||
delete options.child
|
delete options.child
|
||||||
const groupObject = new fabric.Group(child, {
|
const groupObject = new fabric.Group(child, {
|
||||||
subTargetCheck: true, // 关键:检测子对象
|
// subTargetCheck: true, // 关键:检测子对象
|
||||||
interactive: true, // 启用交互
|
// interactive: true, // 启用交互
|
||||||
hasControls: true,
|
// hasControls: true,
|
||||||
hasBorders: true,
|
// hasBorders: true,
|
||||||
|
|
||||||
// // 子对象样式
|
// // 子对象样式
|
||||||
// cornerColor: 'blue',
|
// cornerColor: 'blue',
|
||||||
@@ -368,7 +368,7 @@ export class LayerManager {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
resolve(img)
|
resolve(img)
|
||||||
})
|
}, { crossOrigin: 'anonymous' })
|
||||||
})
|
})
|
||||||
// console.log(mergedImage)
|
// console.log(mergedImage)
|
||||||
const index = this.canvasManager.getObjects().indexOf(targetLayer);
|
const index = this.canvasManager.getObjects().indexOf(targetLayer);
|
||||||
|
|||||||
Reference in New Issue
Block a user