fix: 修复表格底部多余空白
- 去掉高度计算中多余的 borderWidth * 2 - 调整边框绘制,向内偏移半个线宽 - 边框紧贴表格内容,无额外空白
This commit is contained in:
@@ -694,7 +694,7 @@ function generateTableImage(params) {
|
|||||||
const headerHeight = fontSize * 2.5;
|
const headerHeight = fontSize * 2.5;
|
||||||
const rowHeight = fontSize * 2.2;
|
const rowHeight = fontSize * 2.2;
|
||||||
const titleHeight = title ? fontSize * 3 : 0;
|
const titleHeight = title ? fontSize * 3 : 0;
|
||||||
const tableHeight = headerHeight + rows.length * rowHeight + borderWidth * 2;
|
const tableHeight = headerHeight + rows.length * rowHeight;
|
||||||
const finalHeight = tableHeight + titleHeight;
|
const finalHeight = tableHeight + titleHeight;
|
||||||
|
|
||||||
// 创建正式 canvas
|
// 创建正式 canvas
|
||||||
@@ -763,8 +763,9 @@ function generateTableImage(params) {
|
|||||||
ctx.strokeStyle = themeConfig.borderColor;
|
ctx.strokeStyle = themeConfig.borderColor;
|
||||||
ctx.lineWidth = borderWidth;
|
ctx.lineWidth = borderWidth;
|
||||||
|
|
||||||
// 外边框
|
// 外边框(向内偏移半个线宽,确保边框完全在画布内)
|
||||||
ctx.strokeRect(0, startY, finalWidth, tableHeight);
|
const offset = borderWidth / 2;
|
||||||
|
ctx.strokeRect(offset, startY + offset, finalWidth - borderWidth, tableHeight - borderWidth);
|
||||||
|
|
||||||
// 横线
|
// 横线
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
|
|||||||
Reference in New Issue
Block a user