fix: Corregir configuración de estilos y componentes
- Agregar imports de Tailwind CSS v4 y Nuxt UI en main.css - Renombrar QueueActions.vue -> Actions.vue y QueueItem.vue -> Item.vue para evitar conflictos de nombres de componentes - Crear composable useMediaQuery para manejo de responsive - Corregir referencias a componentes en index.vue y PrintQueue.vue - Actualizar imports de servidor a rutas relativas - Instalar @iconify-json/heroicons y @iconify-json/lucide - Actualizar Jimp a sintaxis v1.x
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// Endpoint para cortar papel
|
||||
import { buildFromOperations } from '~/server/utils/eposBuilder'
|
||||
import { buildSoapEnvelope, sendToPrinter, parsePrinterResponse } from '~/server/utils/printer'
|
||||
import { buildFromOperations } from '../../utils/eposBuilder'
|
||||
import { buildSoapEnvelope, sendToPrinter, parsePrinterResponse } from '../../utils/printer'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
try {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Endpoint para imprimir imágenes usando Jimp
|
||||
import Jimp from 'jimp'
|
||||
import { EposMessageBuilder } from '~/server/utils/eposBuilder'
|
||||
import { buildSoapEnvelope, sendToPrinter, parsePrinterResponse } from '~/server/utils/printer'
|
||||
import { Jimp } from 'jimp'
|
||||
import { EposMessageBuilder } from '../../utils/eposBuilder'
|
||||
import { buildSoapEnvelope, sendToPrinter, parsePrinterResponse } from '../../utils/printer'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
try {
|
||||
@@ -29,14 +29,15 @@ export default defineEventHandler(async (event) => {
|
||||
|
||||
// Leer y procesar imagen
|
||||
const img = await Jimp.read(path)
|
||||
let targetWidth = width || img.bitmap.width
|
||||
if (targetWidth <= 0) targetWidth = img.bitmap.width
|
||||
let targetWidth = width || img.width
|
||||
if (targetWidth <= 0) targetWidth = img.width
|
||||
|
||||
const scale = targetWidth / img.bitmap.width
|
||||
const targetHeight = Math.max(1, Math.round(img.bitmap.height * scale))
|
||||
const scale = targetWidth / img.width
|
||||
const targetHeight = Math.max(1, Math.round(img.height * scale))
|
||||
|
||||
img.resize(targetWidth, targetHeight, Jimp.RESIZE_BILINEAR)
|
||||
img.grayscale()
|
||||
// Resize y convertir a escala de grises
|
||||
img.resize({ w: targetWidth, h: targetHeight })
|
||||
img.greyscale()
|
||||
|
||||
// Empaquetar bits MSB first por byte
|
||||
const bytesPerRow = Math.ceil(targetWidth / 8)
|
||||
@@ -49,13 +50,10 @@ export default defineEventHandler(async (event) => {
|
||||
let rowBytes = 0
|
||||
|
||||
for (let x = 0; x < targetWidth; x++) {
|
||||
const idx = (y * targetWidth + x) * 4
|
||||
const rgba = img.bitmap.data
|
||||
const r = rgba[idx]
|
||||
const g = rgba[idx + 1]
|
||||
const b = rgba[idx + 2]
|
||||
const lum = 0.299 * r + 0.587 * g + 0.114 * b
|
||||
const isBlack = lum < threshold
|
||||
const color = img.getPixelColor(x, y)
|
||||
// Extraer componente rojo (ya es greyscale, todos los canales son iguales)
|
||||
const r = (color >> 24) & 0xFF
|
||||
const isBlack = r < threshold
|
||||
|
||||
if (isBlack) byte |= (1 << bit)
|
||||
bit--
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Endpoint genérico de impresión que acepta una lista de operaciones
|
||||
import { buildFromOperations, type Operation } from '~/server/utils/eposBuilder'
|
||||
import { buildSoapEnvelope, sendToPrinter, parsePrinterResponse } from '~/server/utils/printer'
|
||||
import { buildFromOperations, type Operation } from '../../utils/eposBuilder'
|
||||
import { buildSoapEnvelope, sendToPrinter, parsePrinterResponse } from '../../utils/printer'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
try {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Endpoint para abrir cajón de dinero
|
||||
import { buildFromOperations } from '~/server/utils/eposBuilder'
|
||||
import { buildSoapEnvelope, sendToPrinter, parsePrinterResponse } from '~/server/utils/printer'
|
||||
import { buildFromOperations } from '../../utils/eposBuilder'
|
||||
import { buildSoapEnvelope, sendToPrinter, parsePrinterResponse } from '../../utils/printer'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
try {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Endpoint de conveniencia para imprimir texto con opciones
|
||||
import { buildFromOperations, type Operation } from '~/server/utils/eposBuilder'
|
||||
import { buildSoapEnvelope, sendToPrinter, parsePrinterResponse } from '~/server/utils/printer'
|
||||
import { buildFromOperations, type Operation } from '../../utils/eposBuilder'
|
||||
import { buildSoapEnvelope, sendToPrinter, parsePrinterResponse } from '../../utils/printer'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user