ข้ามไปยังเนื้อหา

หน้าตัวอย่าง

ปิดปรับปรุงระบบ

ใช้เมื่อปิดระบบตามแผน เช่น ปรับปรุงประจำเดือนหรือย้ายข้อมูล ทุกหน้าแสดงหน้านี้แทน ด้วยสถานะ HTTP 503 ถ้าระบบล่มโดยไม่ได้วางแผน ใช้หน้าระบบขัดข้อง 5xx

คอมโพเนนต์ที่ใช้

import { StatusPage, Button } from "@bsru/ui";

กฎของหน้านี้

ถ้อยคำ

  • บอกว่าปิดตามแผน ไม่ใช่ขัดข้อง และบอกว่าข้อมูลที่บันทึกไว้แล้วไม่สูญหาย
  • บอกเวลาที่คาดว่าจะกลับมาด้วย expectedBack เป็นวันที่และเวลาแบบไทย พร้อมปีพุทธศักราช ถ้าไม่รู้เวลาแน่ชัด อย่าเดา ให้เว้นไว้
  • บอกผลต่อผู้ใช้ เช่น คำขอที่รออนุมัติยังอยู่ หรือระบบอื่นยังใช้ได้

ปุ่มและทางไปต่อ

  • ปุ่มเดียว: ลองเปิดอีกครั้ง ซึ่งโหลดหน้าแรกใหม่ ไม่ต้องมีปุ่มอื่น
  • อย่าให้ลิงก์ไปหน้าที่ต้องเข้าสู่ระบบหรือเรียก API ระหว่างปิดปรับปรุง

ห้ามแสดง

  • รายละเอียดงานปรับปรุง เวอร์ชัน ชื่อเซิร์ฟเวอร์ หรือขั้นตอนการ deploy
  • ข้อมูลของผู้ใช้ หน้านี้ไม่อ่าน session และไม่เรียก API หลัก

ในแอป

  • เป็นหน้าคงที่ เปิดได้แม้ระบบหลักปิดอยู่ ตอบด้วย 503 และ Retry-After ส่วน /healthz ยังตอบตามจริง
  • ใช้แบบเต็มหน้าจอเสมอ พร้อม brand และ notice ในระบบจำลอง

ตัวอย่างทั้งหน้า

แต่ละตัวอย่างเป็นหน้าเต็ม แสดงในกรอบจอคอมพิวเตอร์ เลือกโทรศัพท์หรือแท็บเล็ตที่แถบบนเพื่อดูบนจอนั้น ข้อมูลทั้งหมดเป็นข้อมูลสมมติ

ERP: ปิดปรับปรุงพร้อมเวลากลับมา

ทุกหน้าแสดงหน้านี้ด้วยสถานะ 503 expectedBack บอกเวลาที่คาดว่าจะกลับมา ไม่มีรหัสแสดง เพราะการปิดปรับปรุงไม่ใช่ข้อผิดพลาด

จอคอมพิวเตอร์ 1280 × 800 px
// app/maintenance/page.tsx: a static page, with no call to the core API or the session.
import { Button, StatusPage } from "@bsru/ui";
import { RotateCw } from "lucide-react";
import { getTranslations } from "next-intl/server";
import { isDemo, maintenanceUntil } from "@/server/env";

export default async function Maintenance() {
  const t = await getTranslations();
  const until = maintenanceUntil(); // A Date from the deploy's settings, or null when unknown
  return (
    <StatusPage
      kind="maintenance"
      brand={{ name: "BSRU ERP", caption: t("brand.university"), logo: "/bsru-logo.png", alt: t("brand.seal") }}
      notice={isDemo() ? t("shell.demo") : undefined}
      description={t("maintenance.body")}
      expectedBack={until ? t("maintenance.until", { until }) : undefined}
      actions={<Button tone="primary" icon={RotateCw} label={t("maintenance.retry")} href="/" />}
    />
  );
}

// proxy.ts: while maintenance is on, every page shows it, with HTTP status 503 and Retry-After.
export function proxy(request: NextRequest) {
  if (!maintenanceOn() || request.nextUrl.pathname.startsWith("/healthz")) return NextResponse.next();
  return NextResponse.rewrite(new URL("/maintenance", request.url), { status: 503, headers: { "Retry-After": "3600" } });
}

คอนโซล: ปิดเฉพาะคอนโซล

คอนโซลปิดแต่ ERP ยังเปิด หัวข้อและคำอธิบายบอกผลต่อผู้ใช้ code แสดง 503 สำหรับทีมที่ต้องการเห็นรหัส ไม่รู้เวลาแน่ชัด จึงไม่มี expectedBack

จอคอมพิวเตอร์ 1280 × 800 px
<StatusPage
  kind="maintenance"
  code="503"
  brand={{ name: t("brand.console"), caption: t("brand.university"), logo: "/bsru-logo.png", alt: t("brand.seal") }}
  notice={isDemo() ? t("shell.demo") : undefined}
  title={t("maintenance.consoleTitle")}
  description={t("maintenance.consoleBody")}
  actions={<Button tone="primary" icon={RotateCw} label={t("maintenance.retry")} href="/" />}
/>