From df91d458ba3048f59dffdb1198ccf2a7f7814b1d Mon Sep 17 00:00:00 2001 From: "DESKTOP-064TTA1\\Fai LUK" Date: Fri, 27 Mar 2026 11:23:04 +0800 Subject: [PATCH] no message --- src/app/api/laserPrint/actions.ts | 6 +++++- src/components/LaserPrint/LaserPrintSearch.tsx | 10 +++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/app/api/laserPrint/actions.ts b/src/app/api/laserPrint/actions.ts index 5d149e1..4255c3c 100644 --- a/src/app/api/laserPrint/actions.ts +++ b/src/app/api/laserPrint/actions.ts @@ -114,7 +114,11 @@ export interface PrinterStatusResponse { } export async function checkPrinterStatus(request: PrinterStatusRequest): Promise { - const url = `${NEXT_PUBLIC_API_URL}/plastic/check-printer`; + const base = (NEXT_PUBLIC_API_URL ?? "").replace(/\/$/, ""); + if (!base) { + throw new Error("NEXT_PUBLIC_API_URL is not set."); + } + const url = `${base}/plastic/check-printer`; const res = await clientAuthFetch(url, { method: "POST", headers: { "Content-Type": "application/json" }, diff --git a/src/components/LaserPrint/LaserPrintSearch.tsx b/src/components/LaserPrint/LaserPrintSearch.tsx index a0d62b7..873f57b 100644 --- a/src/components/LaserPrint/LaserPrintSearch.tsx +++ b/src/components/LaserPrint/LaserPrintSearch.tsx @@ -143,21 +143,17 @@ const LaserPrintSearch: React.FC = () => { return () => clearInterval(id); }, [connected, loadJobOrders]); + /** Server uses DB LASER_PRINT.host/port (omit body) so UI matches /plastic/print-laser-bag2. */ const checkLaser = useCallback(async () => { - const portNum = Number(laserPort || 45678); try { - const result = await checkPrinterStatus({ - printerType: "laser", - printerIp: laserHost.trim(), - printerPort: Number.isFinite(portNum) ? portNum : 45678, - }); + const result = await checkPrinterStatus({ printerType: "laser" }); setPrinterConnected(result.connected); setPrinterMessage(result.message); } catch (e) { setPrinterConnected(false); setPrinterMessage(e instanceof Error ? e.message : "檸檬機(激光機)狀態檢查失敗"); } - }, [laserHost, laserPort]); + }, []); useEffect(() => { if (!settingsLoaded) return;