eCourt-note/components/DebugConsole.tsx
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 b33af7d7f2
All checks were successful
Deploy eCourt Note Web to Server / Validate Database Schema (Drizzle) (push) Successful in 3s
Deploy eCourt Note Web to Server / Build Web Docker Image (push) Successful in 41s
Deploy eCourt Note Web to Server / Deploy eCourt Note Web to Server (push) Successful in 13s
Deploy eCourt Note Web to Server / Notify Deployment Status (push) Successful in 1s
fix(debug): DebugConsole
2026-09-15 16:18:53 +07:00

35 lines
1.8 KiB
TypeScript

"use client";
import { useEffect } from "react";
/** TEMP-DEBUG: เปิด Eruda (devtools ลอยบนหน้าจอ — ปุ่ม gear มุมขวาล่าง) เมื่อเปิด
* หน้าพร้อม ?debug ไว้อ่าน console.warn ของ log [debug] บน iPad จริง (ไม่มี Mac
* ต่อ Safari Web Inspector) — โหลดสคริปต์จาก CDN เท่านั้น ไม่แตะ dependencies
* ของ project — เคลียร์ debug เสร็จ = ลบไฟล์นี้ + บรรทัด import/render ใน
* app/annotate/[id]/page.tsx */
export default function DebugConsole() {
useEffect(() => {
if (!new URLSearchParams(window.location.search).has("debug")) return;
// React strict mode รัน effect สองรอบ — กัน append script ซ้ำ
if (document.getElementById("eruda-loader")) return;
const s = document.createElement("script");
s.id = "eruda-loader";
s.src = "https://cdn.jsdelivr.net/npm/eruda@3";
s.async = true;
s.onload = () => {
const w = window as unknown as { eruda?: { init: () => void; show: () => void } };
w.eruda?.init();
w.eruda?.show();
};
s.onerror = () => {
const b = document.createElement("div");
b.textContent =
"โหลด Eruda จาก CDN ไม่ได้ (iPad ต้องต่ออินเทอร์เน็ต) — แจ้งเพื่อเปลี่ยนเป็น bundle ใน project แทน";
b.style.cssText =
"position:fixed;top:0;left:0;right:0;z-index:99999;background:#dc2626;color:#fff;padding:8px;font-size:14px";
document.body.appendChild(b);
};
document.head.appendChild(s);
}, []);
return null;
}