优化预览

This commit is contained in:
iqudoo
2026-06-13 05:51:48 +08:00
parent 2a43df00c6
commit a08fbd1eb6
3 changed files with 30 additions and 12 deletions

View File

@@ -8,6 +8,8 @@ import {
buildPrintablePages,
collectGridCutLinePositions,
getCutLineChannel,
formatCutLineSvgDashArray,
getCutLineStrokeWidthMm,
loadAutoLayoutMinPageMarginMm,
saveAutoLayoutMinPageMarginMm,
type PrintableLabel,
@@ -578,15 +580,12 @@ export const LayoutPreview: React.FC<LayoutPreviewProps> = ({
const rowGapPx = Math.max(0, paper.rowGap * previewScale);
const labelWPx = template.width * previewScale;
const labelHPx = template.height * previewScale;
const cutStrokeWidth = Math.max(0.5, cutLine.width * previewScale);
const cutStrokeWidth = getCutLineStrokeWidthMm(cutLine) * previewScale;
const cutHalfStroke = cutStrokeWidth / 2;
const cutChannel = getCutLineChannel(paper.columnGap, paper.rowGap, cutLine);
const cutChannelXPx = cutChannel.x * previewScale;
const cutChannelYPx = cutChannel.y * previewScale;
const cutDash =
cutLine.style === 'dashed'
? `${Math.max(2, cutStrokeWidth * 4)} ${Math.max(2, cutStrokeWidth * 4)}`
: undefined;
const cutDash = formatCutLineSvgDashArray(cutLine, previewScale);
const pageCutLines = useMemo(
() =>
collectGridCutLinePositions(
@@ -770,7 +769,6 @@ export const LayoutPreview: React.FC<LayoutPreviewProps> = ({
strokeWidth={cutStrokeWidth}
strokeDasharray={cutDash}
strokeLinecap="butt"
shapeRendering="crispEdges"
/>
))}
{pageCutLines.xs.map((x) => (
@@ -784,7 +782,6 @@ export const LayoutPreview: React.FC<LayoutPreviewProps> = ({
strokeWidth={cutStrokeWidth}
strokeDasharray={cutDash}
strokeLinecap="butt"
shapeRendering="crispEdges"
/>
))}
</svg>
@@ -794,7 +791,7 @@ export const LayoutPreview: React.FC<LayoutPreviewProps> = ({
return (
<div
key={cellIdx}
className="bg-white border border-dashed border-gray-200 flex items-center justify-center text-gray-300 font-mono text-[9px] box-border"
className="bg-white flex items-center justify-center text-gray-300 font-mono text-[9px]"
style={{
width: `${template.width * previewScale}px`,
height: `${template.height * previewScale}px`,