处理Safari 不支持requestIdleCallback方法

This commit is contained in:
李志鹏
2026-04-24 17:11:48 +08:00
parent 743fc762d6
commit 7bb38bf2e5
4 changed files with 5 additions and 6 deletions

View File

@@ -409,7 +409,7 @@ export class BrushIndicator {
// this.show(e.e);
this._mouseEnterHandler && this._mouseEnterHandler(e)
} else {
// requestIdleCallback(() => {
// setTimeout(() => {
// this.updatePosition(e.e);
// });

View File

@@ -133,11 +133,12 @@ export class RedGreenModeManager {
this.canvas.on("mouse:up", (event) => {
// 可以在这里添加更多逻辑,比如生成图片或更新状态
nextTick(() => {
requestIdleCallback(async () => {
setTimeout(async () => {
if (!this.isInitialized) {
console.warn("红绿图模式未初始化,无法处理鼠标事件");
return;
}
console.log("鼠标抬起事件触发", this.onImageGenerated);
if (this.onImageGenerated) {
const imageData = await this.canvasManager.exportImage({
restoreOpacityInRedGreen: true, // 恢复红绿图模式下的透明度

View File

@@ -37,7 +37,6 @@ export class ThumbnailManager {
// 延迟执行避免阻塞UI
fabricObjects.length > 0 &&
requestIdleCallback(() => {
setTimeout(async () => {
const base64 = await this._generateLayerThumbnailNow(fabricObjects, layer);
// this.layerThumbnails.set(layerId, base64);
@@ -55,7 +54,6 @@ export class ThumbnailManager {
console.error("生成图层缩略图时出错:", error);
}
});
});
}
/**
@@ -65,7 +63,7 @@ export class ThumbnailManager {
generateAllLayerThumbnails(layers) {
if (!layers || !Array.isArray(layers)) return;
requestIdleCallback(() => {
setTimeout(() => {
setTimeout(() => {
layers.forEach((layer) => {
if (layer && layer.id) {

View File

@@ -155,7 +155,7 @@ export class LiquifyRealTimeUpdater {
// 使用requestAnimationFrame进行批量渲染优化
// if (!this.renderingScheduled && !this.config.skipRenderDuringDrag) {
// this.renderingScheduled = true;
// requestIdleCallback(() => {
// setTimeout(() => {
// this.canvas.renderAll();
// this.renderingScheduled = false;
// });