From fff6cb98ae72ae107bc596f000d043c6732cdb14 Mon Sep 17 00:00:00 2001 From: iqudoo Date: Sun, 14 Jun 2026 02:52:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/LabelDesigner.tsx | 18 +- src/components/PropSidebar.tsx | 79 +++++- src/components/TableCellTextFields.tsx | 12 +- src/components/TablePropertyFields.tsx | 12 +- src/labelRenderer.ts | 319 +++++++++---------------- src/tableUtils.ts | 125 +++++++--- src/types.ts | 4 + src/utils.ts | 12 +- 8 files changed, 325 insertions(+), 256 deletions(-) diff --git a/src/components/LabelDesigner.tsx b/src/components/LabelDesigner.tsx index f0ebeda..bb53188 100644 --- a/src/components/LabelDesigner.tsx +++ b/src/components/LabelDesigner.tsx @@ -7,10 +7,10 @@ import { getTableColWidths, getTableRowHeights, iterTableCells, - getCellRectMm, toggleTableCellSelection, scaleTableTracks, getCellAnchor, + getCellRectPx, type TableCellCoord, } from '../tableUtils'; import { useIsNarrowScreen } from '../hooks/useIsMobile'; @@ -1860,11 +1860,8 @@ export const LabelDesigner: React.FC = ({ onSelectTableCells && (
{iterTableCells(overlayElement).map(({ row, col }) => { - const rect = getCellRectMm(overlayElement, row, col); - const cellX = mmToPx(rect.x, displayZoom); - const cellY = mmToPx(rect.y, displayZoom); - const cellW = mmToPx(rect.width, displayZoom); - const cellH = mmToPx(rect.height, displayZoom); + const { x: cellX, y: cellY, width: cellW, height: cellH } = + getCellRectPx(overlayElement, row, col, canvasRenderScale); const isCellSelected = selectedTableCells.some((c) => { const anchor = getCellAnchor(overlayElement, c.row, c.col); return anchor.row === row && anchor.col === col; @@ -1872,16 +1869,19 @@ export const LabelDesigner: React.FC = ({ return (
handleTableCellPointerDown(e, overlayElement, row, col) diff --git a/src/components/PropSidebar.tsx b/src/components/PropSidebar.tsx index fc2ecec..69f2ddb 100644 --- a/src/components/PropSidebar.tsx +++ b/src/components/PropSidebar.tsx @@ -482,7 +482,7 @@ export const PropSidebar: React.FC = ({
变量列表

- 可编辑变量默认值,未被内容或显示条件引用的变量可删除。 + 可编辑变量预览值,未被内容或显示条件引用的变量可删除。

{templateVariables.map((v) => { const inUse = isTemplateVariableInUse(template, v); @@ -501,7 +501,7 @@ export const PropSidebar: React.FC = ({ type="text" value={template.variableDefaults?.[v] ?? ''} onChange={(e) => setVariableDefault(v, e.target.value)} - placeholder="预览默认值" + placeholder="预览值" className="ps-field font-mono text-[10px] w-full min-w-0" />
@@ -661,6 +661,17 @@ export const PropSidebar: React.FC = ({ )} {selectedElem.type !== 'table' && ( <> +
+ + +
handleElemChange({ ...selectedElem, content: val })} @@ -691,6 +702,31 @@ export const PropSidebar: React.FC = ({ )} )} + {(selectedElem.type === 'barcode' || + selectedElem.type === 'qrcode' || + selectedElem.type === 'image') && ( + + )} {selectedElem.type === 'table' && (

表格各单元格内容独立设置,默认为空。点击画布上的单元格后在属性面板编辑。 @@ -1407,6 +1443,45 @@ export const PropSidebar: React.FC = ({

+
+ +

+ 主图地址加载失败时使用;需同时开启「内容为空仍显示」才能在绑定数据为空时展示 +

+ + + handleElemChange({ + ...selectedElem, + defaultImage: val.trim() || undefined, + }) + } + rows={2} + className="ps-field resize-none" + placeholder="默认图片 URL 或 data URI" + /> +
)} diff --git a/src/components/TableCellTextFields.tsx b/src/components/TableCellTextFields.tsx index ac962f6..05d98d8 100644 --- a/src/components/TableCellTextFields.tsx +++ b/src/components/TableCellTextFields.tsx @@ -58,7 +58,17 @@ export const TableCellTextFields: React.FC = ({ )}
- +
+ + +