From c5dc3c63126d6aafe0b1d33bd9a1aaca8475170a Mon Sep 17 00:00:00 2001 From: personal82555 Date: Thu, 15 Oct 2026 11:36:30 +0800 Subject: [PATCH] =?UTF-8?q?feat(label-designer):=20=E9=9D=A2=E5=8D=95?= =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E6=96=B0=E5=A2=9E=E5=9B=BD=E5=86=85/?= =?UTF-8?q?=E5=9B=BD=E5=A4=96=E5=BF=AB=E9=80=92=E6=A8=A1=E6=9D=BF=EF=BC=8C?= =?UTF-8?q?=E6=8C=89=E4=B8=89=E7=BB=84=E5=BD=92=E7=B1=BB=EF=BC=88=E5=85=B1?= =?UTF-8?q?20=E4=B8=AA=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 14 ++ src/pages/About.vue | 2 +- src/tools/label-designer/label-designer.vue | 135 ++++++++++- src/tools/label-designer/templates.ts | 253 ++++++++++++++++++++ 4 files changed, 396 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fdb5556..c137dba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,20 @@ All notable changes to this project will be documented in this file. See [standa ## Version 2026.10.14-it-tools-pro +### 📦 面单设计新增国内/国外快递模板(共 20 个,按三组归类) +- **新增模板分组**,模板栏从平铺改为**三个分组按钮 + 展开式下拉**(原来 6 个模板平铺;加到 20 个会把工具栏挤爆): + - **国内快递(8)**:顺丰速运、中通快递、圆通速递、韵达快递、申通快递、京东物流、极兔速递、邮政 EMS + - **国外快递(6)**:DHL、FedEx、UPS、USPS、TNT、亚马逊 FBA + - **通用面单(6)**:原快递面单 100×180 / 100×150、标准小面单 76×130、物流标签 100×60、价格标签 60×40、空白画布(保留原有 6 个,未删) +- **模板版式**:国内快递统一为 100×180mm 标准电子面单版式(品牌名 + 收件人/寄件人分区 + 运单号 + 二维码 + 底部条码 + 客服热线/签收栏),各快递只换品牌名、运单号、客服热线;国外快递为 100×150mm 国际面单版式(SHIP FROM / SHIP TO 双语 + TRACKING NUMBER + Service/Customs 字段 + CONTENTS 内件申报 + HS Code / 申报价值 + 条码) +- **交互**:点分组按钮展开该组模板 → 点模板即应用并**自动收起下拉**(把画布让出来);当前模板高亮显示;下拉面板在工具栏下方占自身高度,**不遮挡画布** +- **验证(20/20 全通过)**:逐个点击每个模板,实测画布尺寸、元素数、条码/二维码渲染 + - 尺寸全部正确(100×180 / 100×150 / 76×130 / 100×60 / 60×40) + - 元素数正确(国内 20、国外 21、FBA 18、通用 11/10/8/5/3/0) + - **条码与二维码全部渲染成功**(`img.bar` data:image/png,空白画布除外) + - 选后下拉自动收起 ✓,无失败项 + - 视觉核验顺丰面单:收件人/寄件人/运单号/二维码/条码齐全,无重叠、无截断 + ### 🦶 功能页页脚改为独立底栏:显示在功能区外、且不产生滚动条 - **上一版遗留的两个问题**: 1. **页脚压住内容**:`/json-prettify` 的底部工具行(中文转Unicode / 添加转义 / Dict转Json…)在 828–877,页脚在 869–888 → **实际被压住** diff --git a/src/pages/About.vue b/src/pages/About.vue index 235815c..c1b4a5f 100644 --- a/src/pages/About.vue +++ b/src/pages/About.vue @@ -39,7 +39,7 @@ const groups: { title: string; items: Item[] }[] = [ { name: '二维码条码识别', icon: '扫', desc: '上传/拖拽/粘贴图片一键识别,支持多码混合批量输出,本地 WASM 解码,图片不上传', tag: '全新' }, { name: '在线翻译', icon: '译', desc: '中英日韩等 16 种语言互译,自动识别源语言,支持导入 Word/PDF/TXT 等文档整篇翻译、并发处理大文档、译文可下载 TXT/DOCX', tag: '全新' }, { name: '图片OCR / PDF文字识别', icon: '识', desc: '本地 OCR 引擎,截图扫描件文字提取(准确率 99%+);PDF 逐页识别、预览、导出 TXT', tag: '全新' }, - { name: '面单设计', icon: '单', desc: '快递面单模板开箱即用;上传 PDF 自动把**文字、条码、二维码、图片**全部提取成可编辑元素(可改内容、移动、删除)并**擦除底图原内容**,不产生重影;新增**实线/虚线 × 横线/竖线**线条组件可调粗度长度;300dpi 高清导出', tag: '全新' }, + { name: '面单设计', icon: '单', desc: '内置 **20 个面单模板**并按「国内快递 / 国外快递 / 通用面单」三组归类——顺丰、中通、圆通、韵达、申通、京东、极兔、EMS,DHL、FedEx、UPS、USPS、TNT、亚马逊 FBA 等开箱即用;上传 PDF 自动把**文字、条码、二维码、图片**全部提取成可编辑元素(可改内容、移动、删除)并**擦除底图原内容**,不产生重影;新增**实线/虚线 × 横线/竖线**线条组件可调粗度长度;300dpi 高清导出', tag: '全新' }, { name: 'IT网站收藏', icon: '藏', desc: '内置 91 个精选开发站点(社区/文档/工具/AI/设计/视频/媒体平台),数据存用户本地,可自选目录', tag: '全新' }, { name: '文档格式转换', icon: '转', desc: 'Word/PDF/TXT/RTF/ODT/EPUB/MOBI/AZW3/HTML 九格式互转,自建 calibre 引擎,批量打包下载', tag: '全新' }, { name: '视频工具', icon: '视', desc: '格式转换、压缩、裁剪、旋转、变速、消音、提取音频、截图、GIF 互转、加水印/去水印等 13 个工具 + AI 字幕生成,服务端 ffmpeg 高速处理,最大 2GB', tag: '全新' }, diff --git a/src/tools/label-designer/label-designer.vue b/src/tools/label-designer/label-designer.vue index 1f9c37e..9696a67 100644 --- a/src/tools/label-designer/label-designer.vue +++ b/src/tools/label-designer/label-designer.vue @@ -8,7 +8,7 @@ import bwipjs from 'bwip-js'; import { PDFDocument } from 'pdf-lib'; import { getDocument, GlobalWorkerOptions, OPS } from 'pdfjs-dist'; import pdfWorkerUrl from 'pdfjs-dist/build/pdf.worker.min.js?url'; -import { defaultDoc, newId, templates } from './templates'; +import { defaultDoc, newId, templates, templatesByGroup } from './templates'; import { prepareZXingModule, readBarcodes } from 'zxing-wasm/reader'; import wasmUrl from 'zxing-wasm/reader/zxing_reader.wasm?url'; @@ -60,6 +60,11 @@ const pxPerMM = computed(() => { const selected = computed(() => doc.value.elements.find(e => e.id === selectedId.value) ?? null); const tplOptions = templates; +// 模板按分组展示:国内快递 / 国外快递 / 通用面单 +const tplGroups = templatesByGroup(); +const openGroup = ref(''); +const currentGroupItems = computed(() => tplGroups.find(g => g.group === openGroup.value)?.items ?? []); +const activeTplKey = ref(''); // ---------- persistence ---------- const STORAGE_KEY = 'it-tools-label-designer'; @@ -313,6 +318,8 @@ function applyTemplate(tpl: typeof templates[number]) { doc.value = tpl.make(); selectedId.value = null; zoom.value = 1; + activeTplKey.value = tpl.key; + openGroup.value = ''; // 选完收起下拉,把画布让出来 } const showCustom = ref(false); @@ -1012,13 +1019,15 @@ onUnmounted(() => { + +
+ +
+ +
{ } } +/* 模板分组下拉:展开在工具栏下方,不遮挡画布(占自身高度) */ +.tpl-drawer { + flex-shrink: 0; + margin-bottom: 10px; + padding: 10px 12px; + border: 1px solid rgba(24, 160, 88, 0.35); + border-radius: 10px; + background: rgba(24, 160, 88, 0.05); + + .tpl-drawer-head { + display: flex; + align-items: center; + gap: 8px; + margin-bottom: 8px; + } + + .tpl-drawer-title { + font-size: 14px; + font-weight: 600; + color: #18a058; + } + + .tpl-drawer-count { + font-size: 12px; + opacity: 0.6; + } + + .tpl-drawer-close { + margin-left: auto; + width: 22px; + height: 22px; + border: none; + border-radius: 50%; + background: rgba(128, 128, 128, 0.14); + color: #666; + font-size: 12px; + line-height: 1; + cursor: pointer; + + &:hover { + background: rgba(208, 48, 80, 0.16); + color: #d03050; + } + } + + .tpl-drawer-list { + display: flex; + flex-wrap: wrap; + gap: 8px; + } + + .tpl-card { + padding: 6px 16px; + border: 1px solid rgba(128, 128, 128, 0.32); + border-radius: 8px; + background: #fff; + color: #444; + font-size: 13px; + cursor: pointer; + transition: all 0.15s; + + &:hover { + border-color: #18a058; + color: #18a058; + background: rgba(24, 160, 88, 0.08); + transform: translateY(-1px); + } + + &.active { + border-color: #18a058; + color: #fff; + background: #18a058; + } + } +} + .toolbar { display: flex; align-items: center; @@ -1370,6 +1476,21 @@ onUnmounted(() => { padding-bottom: 10px; flex-shrink: 0; + .tpl-group { + font-weight: 600; + + .tpl-caret { + margin-left: 3px; + font-size: 10px; + opacity: 0.7; + } + + &.active { + border-color: #18a058; + color: #fff; + background: #18a058; + } + } .stats { margin-right: 4px; font-size: 13px; diff --git a/src/tools/label-designer/templates.ts b/src/tools/label-designer/templates.ts index 5716583..277cb40 100644 --- a/src/tools/label-designer/templates.ts +++ b/src/tools/label-designer/templates.ts @@ -37,6 +37,8 @@ export interface LabelDoc { export interface LabelTemplate { key: string; name: string; + /** 分组名,见 TEMPLATE_GROUPS */ + group: string; make: () => LabelDoc; } @@ -72,10 +74,240 @@ function build(width: number, height: number, parts: Part[]): LabelDoc { return { widthMM: width, heightMM: height, bg: null, elements }; } +/** 横向分隔线(实线) */ +const HR = (x: number, y: number, w: number): Part => ['r', x, y, w, 0.3, '#000000', '#000000', 0]; + +// 100×180 标准电子面单的公共版式(各快递只换品牌名/运单号/客服电话) +function express100x180(opts: { brand: string; sub: string; noLabel: string; no: string; hotline: string; track: string }): LabelDoc { + return build(100, 180, [ + ['t', 5, 3, 90, 9, opts.brand, 15, true, 'center'], + ['t', 5, 12, 90, 4, opts.sub, 7, false, 'center'], + HR(5, 17, 90), + ['t', 6, 20, 88, 5, '收件人', 7, false, 'left', '#666666'], + ['t', 6, 25, 88, 20, '张三\n138 0013 8000\n浙江省杭州市余杭区文一西路 969 号 5 幢 301 室', 11, true], + HR(5, 46, 90), + ['t', 6, 49, 88, 5, '寄件人', 7, false, 'left', '#666666'], + ['t', 6, 54, 88, 16, '李四\n139 0013 9000\n广东省深圳市南山区科技园示例电商仓库', 8], + HR(5, 71, 90), + ['t', 6, 74, 55, 5, opts.noLabel, 6.5, false, 'left', '#666666'], + ['t', 6, 79, 55, 7, opts.no, 12, true], + ['t', 6, 87, 55, 5, '订单号:DD20261010001', 7.5], + ['t', 6, 92, 55, 5, '件数:1 重量:1.2kg', 7.5], + ['t', 6, 97, 55, 5, '代收货款:¥0.00', 7.5], + ['t', 6, 102, 55, 5, '签收人:____________', 7.5], + ['q', 68, 74, 27, opts.track], + HR(5, 148, 90), + ['b', 5, 152, 90, 20, opts.no, true], + HR(5, 173, 90), + ['t', 5, 175, 90, 4, opts.hotline, 7, false, 'center'], + ]); +} + +// 100×150 国际面单公共版式 +function intl100x150(opts: { brand: string; sub: string; noLabel: string; no: string; service: string; customs: string; track: string }): LabelDoc { + return build(100, 150, [ + ['t', 5, 3, 90, 9, opts.brand, 16, true, 'center'], + ['t', 5, 12, 90, 4, opts.sub, 7, false, 'center'], + HR(5, 17, 90), + ['t', 6, 20, 44, 5, 'SHIP FROM / 寄件人', 6.5, false, 'left', '#666666'], + ['t', 6, 25, 44, 18, 'Li Si\nSample Trading Co., Ltd.\nShenzhen, Guangdong, CN\n+86 139 0013 9000', 7.5], + ['t', 52, 20, 44, 5, 'SHIP TO / 收件人', 6.5, false, 'left', '#666666'], + ['t', 52, 25, 44, 18, 'John Smith\nSample Inc.\n350 Fifth Ave, New York\nNY 10118, United States\n+1 212 555 0100', 7.5, true], + HR(5, 44, 90), + ['t', 6, 47, 55, 5, opts.noLabel, 6.5, false, 'left', '#666666'], + ['t', 6, 52, 55, 7, opts.no, 11, true], + ['t', 6, 60, 55, 5, 'Ship Date: 2026-10-15', 7.5], + ['t', 6, 65, 55, 5, 'Weight: 1.2 kg Pieces: 1', 7.5], + ['t', 6, 70, 55, 5, `Service: ${opts.service}`, 7.5], + ['t', 6, 75, 55, 5, `Customs: ${opts.customs}`, 7.5], + ['q', 68, 47, 27, opts.track], + HR(5, 90, 90), + ['t', 6, 93, 88, 5, 'CONTENTS / 内件申报', 6.5, false, 'left', '#666666'], + ['t', 6, 98, 88, 14, '1. Sample goods × 1 HS Code: 8471.30 Qty: 1 Value: USD 50.00', 7.5], + ['t', 6, 113, 88, 5, 'Declared Value: USD 50.00 Country of Origin: CN', 7.5], + HR(5, 128, 90), + ['b', 5, 131, 90, 15, opts.no, true], + ]); +} + export const templates: LabelTemplate[] = [ + // ==================== 国内快递 ==================== + { + key: 'dom-sf', + name: '顺丰速运', + group: '国内快递', + make: () => express100x180({ + brand: '顺丰速运 SF EXPRESS', sub: '标准快递 SF Standard Express', + noLabel: '运单号 / Waybill No.', no: 'SF1234567890123', + hotline: '上门取件 95338 签收人:____________ 日期:____', + track: 'https://example.com/track/SF1234567890123', + }), + }, + { + key: 'dom-zto', + name: '中通快递', + group: '国内快递', + make: () => express100x180({ + brand: '中通快递 ZTO EXPRESS', sub: '标准快递', + noLabel: '运单号 / Waybill No.', no: '78123456789012', + hotline: '客服热线 95311 签收人:____________ 日期:____', + track: 'https://example.com/track/78123456789012', + }), + }, + { + key: 'dom-yto', + name: '圆通速递', + group: '国内快递', + make: () => express100x180({ + brand: '圆通速递 YTO EXPRESS', sub: '标准快递', + noLabel: '运单号 / Waybill No.', no: 'YT1234567890123', + hotline: '客服热线 95554 签收人:____________ 日期:____', + track: 'https://example.com/track/YT1234567890123', + }), + }, + { + key: 'dom-yunda', + name: '韵达快递', + group: '国内快递', + make: () => express100x180({ + brand: '韵达快递 YUNDA EXPRESS', sub: '标准快递', + noLabel: '运单号 / Waybill No.', no: '3123456789012', + hotline: '客服热线 95546 签收人:____________ 日期:____', + track: 'https://example.com/track/3123456789012', + }), + }, + { + key: 'dom-sto', + name: '申通快递', + group: '国内快递', + make: () => express100x180({ + brand: '申通快递 STO EXPRESS', sub: '标准快递', + noLabel: '运单号 / Waybill No.', no: '773123456789012', + hotline: '客服热线 95543 签收人:____________ 日期:____', + track: 'https://example.com/track/773123456789012', + }), + }, + { + key: 'dom-jd', + name: '京东物流', + group: '国内快递', + make: () => express100x180({ + brand: '京东物流 JD LOGISTICS', sub: '京东快递 · 特快送', + noLabel: '运单号 / Waybill No.', no: 'JD1234567890123', + hotline: '客服热线 950616 签收人:____________ 日期:____', + track: 'https://example.com/track/JD1234567890123', + }), + }, + { + key: 'dom-jt', + name: '极兔速递', + group: '国内快递', + make: () => express100x180({ + brand: '极兔速递 J&T EXPRESS', sub: '标准快递', + noLabel: '运单号 / Waybill No.', no: 'JT1234567890123', + hotline: '客服热线 400-820-0888 签收人:______ 日期:____', + track: 'https://example.com/track/JT1234567890123', + }), + }, + { + key: 'dom-ems', + name: '邮政 EMS', + group: '国内快递', + make: () => express100x180({ + brand: '中国邮政 EMS', sub: '国内特快专递', + noLabel: '邮件号 / Track No.', no: 'EA123456789CN', + hotline: '客服热线 11183 签收人:____________ 日期:____', + track: 'https://example.com/track/EA123456789CN', + }), + }, + + // ==================== 国外快递 ==================== + { + key: 'intl-dhl', + name: 'DHL', + group: '国外快递', + make: () => intl100x150({ + brand: 'DHL EXPRESS', sub: 'Express Worldwide', + noLabel: 'TRACKING NUMBER', no: 'JJD0099999999', + service: 'Express Worldwide', customs: 'Bill to Sender', + track: 'https://example.com/track/JJD0099999999', + }), + }, + { + key: 'intl-fedex', + name: 'FedEx', + group: '国外快递', + make: () => intl100x150({ + brand: 'FedEx Express', sub: 'International Priority', + noLabel: 'TRACKING NUMBER', no: '9612345678901234', + service: 'Intl Priority', customs: 'Bill to Sender', + track: 'https://example.com/track/9612345678901234', + }), + }, + { + key: 'intl-ups', + name: 'UPS', + group: '国外快递', + make: () => intl100x150({ + brand: 'UPS', sub: 'Worldwide Express Saver', + noLabel: 'TRACKING NUMBER', no: '1Z999AA10123456784', + service: 'WW Express Saver', customs: 'Bill to Sender', + track: 'https://example.com/track/1Z999AA10123456784', + }), + }, + { + key: 'intl-usps', + name: 'USPS', + group: '国外快递', + make: () => intl100x150({ + brand: 'UNITED STATES POSTAL SERVICE', sub: 'Priority Mail International', + noLabel: 'TRACKING NUMBER', no: '9400100000000000000000', + service: 'Priority Mail Intl', customs: 'CN 22 / PS 2976', + track: 'https://example.com/track/9400100000000000000000', + }), + }, + { + key: 'intl-tnt', + name: 'TNT', + group: '国外快递', + make: () => intl100x150({ + brand: 'TNT', sub: 'Global Express', + noLabel: 'CONSIGNMENT NUMBER', no: 'GE123456789WW', + service: 'Global Express', customs: 'Bill to Sender', + track: 'https://example.com/track/GE123456789WW', + }), + }, + { + key: 'intl-fba', + name: '亚马逊 FBA', + group: '国外快递', + make: () => build(100, 150, [ + ['t', 5, 3, 90, 9, 'FBA SHIPMENT / 亚马逊入仓', 13, true, 'center'], + ['t', 5, 12, 90, 4, 'Fulfillment Center Label', 7, false, 'center'], + HR(5, 17, 90), + ['t', 6, 20, 88, 5, 'SHIP TO / 送至亚马逊仓库', 6.5, false, 'left', '#666666'], + ['t', 6, 25, 88, 16, 'Amazon.com Services LLC\nFBA: ONT8\n1910 E Central Ave, San Bernardino, CA 92408\nUnited States', 8, true], + HR(5, 44, 90), + ['t', 6, 47, 55, 5, 'FBA SHIPMENT ID / 货件编号', 6.5, false, 'left', '#666666'], + ['t', 6, 52, 55, 7, 'FBA15ABCDEFGH', 12, true], + ['t', 6, 60, 55, 5, 'Box: 1 of 3 Weight: 12.5 kg', 7.5], + ['t', 6, 65, 55, 5, 'Dimensions: 60×40×40 cm', 7.5], + ['t', 6, 70, 55, 5, 'Carrier: DHL / UPS / FedEx', 7.5], + ['t', 6, 75, 55, 5, 'Ship Date: 2026-10-15', 7.5], + ['q', 68, 47, 27, 'https://example.com/fba/FBA15ABCDEFGH'], + HR(5, 90, 90), + ['t', 6, 93, 88, 5, '箱内明细 / Box Contents', 6.5, false, 'left', '#666666'], + ['t', 6, 98, 88, 14, 'SKU: SAMPLE-001 ASIN: B00EXAMPLE Qty: 20\nSKU: SAMPLE-002 ASIN: B00EXAMPLE2 Qty: 10', 7.5], + HR(5, 128, 90), + ['b', 5, 131, 90, 15, 'FBA15ABCDEFGH', true], + ]), + }, + + // ==================== 通用面单 ==================== { key: 'tpl-express-100x180', name: '快递面单 100×180mm', + group: '通用面单', make: () => build(100, 180, [ ['t', 5, 4, 90, 9, '示例快递 · 电子面单', 15, true, 'center'], ['r', 5, 15, 90, 0.4, '#000000', '#000000', 0], @@ -93,6 +325,7 @@ export const templates: LabelTemplate[] = [ { key: 'tpl-express-100x150', name: '快递面单 100×150mm', + group: '通用面单', make: () => build(100, 150, [ ['t', 5, 4, 90, 8, '示例快递 · 电子面单', 13, true, 'center'], ['r', 5, 13, 90, 0.4, '#000000', '#000000', 0], @@ -109,6 +342,7 @@ export const templates: LabelTemplate[] = [ { key: 'tpl-small-76x130', name: '标准小面单 76×130mm', + group: '通用面单', make: () => build(76, 130, [ ['t', 4, 3, 68, 7, '示例快递 · 电子面单', 11, true, 'center'], ['r', 4, 11, 68, 0.4, '#000000', '#000000', 0], @@ -123,6 +357,7 @@ export const templates: LabelTemplate[] = [ { key: 'tpl-logistics-100x60', name: '物流标签 100×60mm', + group: '通用面单', make: () => build(100, 60, [ ['t', 4, 4, 66, 9, '货物名称:示例商品 × 2', 13, true], ['t', 4, 15, 66, 8, '目的地:浙江省杭州市余杭区', 11], @@ -134,6 +369,7 @@ export const templates: LabelTemplate[] = [ { key: 'tpl-price-60x40', name: '价格标签 60×40mm', + group: '通用面单', make: () => build(60, 40, [ ['t', 3, 3, 54, 9, '商品名称(点击修改)', 12, true, 'center'], ['t', 3, 12, 54, 13, '¥ 19.90', 19, true, 'center'], @@ -143,10 +379,27 @@ export const templates: LabelTemplate[] = [ { key: 'tpl-blank-100x150', name: '空白画布 100×150mm', + group: '通用面单', make: () => build(100, 150, []), }, ]; +/** 模板栏的分组顺序 */ +export const TEMPLATE_GROUPS = ['国内快递', '国外快递', '通用面单']; + +/** 按分组切分模板(保持 TEMPLATE_GROUPS 顺序,未知分组追加在后) */ +export function templatesByGroup(): { group: string; items: LabelTemplate[] }[] { + const groups = [...TEMPLATE_GROUPS]; + for (const t of templates) { + if (!groups.includes(t.group)) { + groups.push(t.group); + } + } + return groups + .map(group => ({ group, items: templates.filter(t => t.group === group) })) + .filter(g => g.items.length > 0); +} + export function defaultDoc(): LabelDoc { return templates[0].make(); }