Replace barcode with QR code + large ID on printed labels
Deploy to LXC / deploy (push) Successful in 18s
Deploy to LXC / deploy (push) Successful in 18s
- QR code on left encodes the short ID (not URL) - Text centred on right: title, brand/model, serial, large bold ID - ID displayed at 11pt bold with letter-spacing for readability - Removed barcode dependency from print pages Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,7 @@ import { db } from '$lib/server/db/index.js';
|
|||||||
import { components } from '$lib/server/db/schema.js';
|
import { components } from '$lib/server/db/schema.js';
|
||||||
import { eq } from 'drizzle-orm';
|
import { eq } from 'drizzle-orm';
|
||||||
import { error } from '@sveltejs/kit';
|
import { error } from '@sveltejs/kit';
|
||||||
import { generateBarcodeSvg } from '$lib/server/barcode.js';
|
import { generateQrSvg } from '$lib/server/qr.js';
|
||||||
|
|
||||||
export const load: PageServerLoad = async ({ params }) => {
|
export const load: PageServerLoad = async ({ params }) => {
|
||||||
const [component] = await db
|
const [component] = await db
|
||||||
@@ -20,7 +20,7 @@ export const load: PageServerLoad = async ({ params }) => {
|
|||||||
if (!component) error(404, 'Component not found');
|
if (!component) error(404, 'Component not found');
|
||||||
|
|
||||||
const shortId = component.id.slice(0, 8).toUpperCase();
|
const shortId = component.id.slice(0, 8).toUpperCase();
|
||||||
const barcodeDataUrl = await generateBarcodeSvg(shortId);
|
const qrSvg = await generateQrSvg(shortId);
|
||||||
|
|
||||||
return { component, barcodeDataUrl, shortId };
|
return { component, qrSvg, shortId };
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -36,19 +36,27 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#each Array(copies) as _}
|
{#each Array(copies) as _}
|
||||||
<div class="label" style="width: 70mm; height: 29mm; background: white; color: black; box-sizing: border-box; padding: 1mm 2mm; margin: 0 auto 8px auto; border: 1px dashed #ccc; overflow: hidden;">
|
<div class="label" style="width: 70mm; height: 29mm; background: white; color: black; box-sizing: border-box; padding: 1mm; margin: 0 auto 8px auto; border: 1px dashed #ccc; overflow: hidden;">
|
||||||
<div style="display: flex; flex-direction: column; justify-content: center; height: 100%; font-family: Arial, Helvetica, sans-serif;">
|
<div style="display: flex; align-items: center; gap: 2mm; height: 100%; font-family: Arial, Helvetica, sans-serif;">
|
||||||
<div style="font-size: 9pt; font-weight: bold; color: #000; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
|
<div style="width: 22mm; height: 22mm; flex-shrink: 0;">
|
||||||
{data.component.title}
|
{@html data.qrSvg}
|
||||||
</div>
|
</div>
|
||||||
<div style="font-size: 6pt; color: #444; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
|
<div style="flex: 1; min-width: 0; text-align: center;">
|
||||||
{data.component.componentType}
|
<div style="font-size: 9pt; font-weight: bold; color: #000; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
|
||||||
{#if data.component.brand}· {data.component.brand}{/if}
|
{data.component.title}
|
||||||
{#if data.component.partNumber} · P/N: {data.component.partNumber}{/if}
|
</div>
|
||||||
</div>
|
<div style="font-size: 6pt; color: #444; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
|
||||||
<div style="margin-top: 0.5mm;">
|
{data.component.componentType}
|
||||||
<img src={data.barcodeDataUrl} alt={data.shortId}
|
{#if data.component.brand}· {data.component.brand}{/if}
|
||||||
style="height: 6mm; width: auto; max-width: 65mm; display: block;" />
|
</div>
|
||||||
|
{#if data.component.partNumber}
|
||||||
|
<div style="font-size: 6pt; color: #666; margin-top: 0.3mm;">
|
||||||
|
P/N: {data.component.partNumber}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
<div style="font-size: 11pt; font-weight: bold; color: #000; margin-top: 0.5mm; letter-spacing: 1px;">
|
||||||
|
{data.shortId}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { db } from '$lib/server/db/index.js';
|
|||||||
import { devices } from '$lib/server/db/schema.js';
|
import { devices } from '$lib/server/db/schema.js';
|
||||||
import { eq } from 'drizzle-orm';
|
import { eq } from 'drizzle-orm';
|
||||||
import { error } from '@sveltejs/kit';
|
import { error } from '@sveltejs/kit';
|
||||||
import { generateBarcodeSvg } from '$lib/server/barcode.js';
|
import { generateQrSvg } from '$lib/server/qr.js';
|
||||||
|
|
||||||
export const load: PageServerLoad = async ({ params }) => {
|
export const load: PageServerLoad = async ({ params }) => {
|
||||||
const [device] = await db
|
const [device] = await db
|
||||||
@@ -23,7 +23,7 @@ export const load: PageServerLoad = async ({ params }) => {
|
|||||||
if (!device) error(404, 'Device not found');
|
if (!device) error(404, 'Device not found');
|
||||||
|
|
||||||
const shortId = device.id.slice(0, 8).toUpperCase();
|
const shortId = device.id.slice(0, 8).toUpperCase();
|
||||||
const barcodeDataUrl = await generateBarcodeSvg(shortId);
|
const qrSvg = await generateQrSvg(shortId);
|
||||||
|
|
||||||
return { device, barcodeDataUrl, shortId };
|
return { device, qrSvg, shortId };
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -36,31 +36,29 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#each Array(copies) as _}
|
{#each Array(copies) as _}
|
||||||
<div class="label" style="width: 70mm; height: 29mm; background: white; color: black; box-sizing: border-box; padding: 1mm 2mm; margin: 0 auto 8px auto; border: 1px dashed #ccc; overflow: hidden;">
|
<div class="label" style="width: 70mm; height: 29mm; background: white; color: black; box-sizing: border-box; padding: 1mm; margin: 0 auto 8px auto; border: 1px dashed #ccc; overflow: hidden;">
|
||||||
<div style="display: flex; flex-direction: column; justify-content: center; height: 100%; font-family: Arial, Helvetica, sans-serif;">
|
<div style="display: flex; align-items: center; gap: 2mm; height: 100%; font-family: Arial, Helvetica, sans-serif;">
|
||||||
<div style="font-size: 9pt; font-weight: bold; color: #000; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
|
<div style="width: 22mm; height: 22mm; flex-shrink: 0;">
|
||||||
{data.device.title}
|
{@html data.qrSvg}
|
||||||
</div>
|
</div>
|
||||||
{#if data.device.brand || data.device.model}
|
<div style="flex: 1; min-width: 0; text-align: center;">
|
||||||
<div style="font-size: 6pt; color: #444; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
|
<div style="font-size: 9pt; font-weight: bold; color: #000; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
|
||||||
{[data.device.brand, data.device.model].filter(Boolean).join(' ')}
|
{data.device.title}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{#if data.device.brand || data.device.model}
|
||||||
{#if data.device.serialNumber}
|
<div style="font-size: 6pt; color: #444; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
|
||||||
<div style="font-size: 5pt; color: #666;">
|
{[data.device.brand, data.device.model].filter(Boolean).join(' ')}
|
||||||
S/N: {data.device.serialNumber}
|
</div>
|
||||||
{#if data.device.voltage} · {data.device.voltage}{/if}
|
{/if}
|
||||||
{#if data.device.frequency} · {data.device.frequency}{/if}
|
{#if data.device.serialNumber}
|
||||||
</div>
|
<div style="font-size: 6pt; color: #666; margin-top: 0.3mm;">
|
||||||
{:else if data.device.voltage || data.device.frequency}
|
S/N: {data.device.serialNumber}
|
||||||
<div style="font-size: 5pt; color: #666;">
|
</div>
|
||||||
{[data.device.voltage, data.device.frequency].filter(Boolean).join(' · ')}
|
{/if}
|
||||||
</div>
|
<div style="font-size: 11pt; font-weight: bold; color: #000; margin-top: 0.5mm; letter-spacing: 1px;">
|
||||||
{/if}
|
{data.shortId}
|
||||||
<div style="margin-top: 0.5mm;">
|
|
||||||
<img src={data.barcodeDataUrl} alt={data.shortId}
|
|
||||||
style="height: 6mm; width: auto; max-width: 65mm; display: block;" />
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
|
|||||||
Reference in New Issue
Block a user