Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

白板信息保存0k问题修改 #13

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions src/common/whiteboard-wrapper/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,17 @@ export const mergeCanvasImage = async (scenes: (() => Promise<HTMLCanvasElement
const canvasArray = [];

for (const canvasPromise of scenes) {
const canvas = await canvasPromise();

let canvas = await canvasPromise();
if("data:," === canvas?.toDataURL()){
canvas = getDefaultCanvas()
}
if (canvas) {
width = Math.max(canvas.width, width);
height = Math.max(canvas.height, height);
canvasArray.push(canvas);
}
}

bigCanvas.setAttribute('width', `${width}`);
bigCanvas.setAttribute('height', `${height * canvasArray.length}`);

Expand All @@ -154,3 +157,16 @@ export const mergeCanvasImage = async (scenes: (() => Promise<HTMLCanvasElement

return bigCanvas;
};

function getDefaultCanvas():HTMLCanvasElement{
// 创建新的 canvas 元素
const canvas = document.createElement('canvas');
// 设置 canvas 尺寸为图像尺寸
canvas.width = 100;
canvas.height = 100;
const ctx = canvas.getContext('2d')!;
// 设置填充颜色为白色,并填充整个 canvas
ctx.fillStyle = 'white';
ctx.fillRect(0, 0, canvas.width, canvas.height);
return canvas;
}