หน้าตัวอย่าง
ปิดปรับปรุงระบบ
ใช้เมื่อปิดระบบตามแผน เช่น ปรับปรุงประจำเดือนหรือย้ายข้อมูล ทุกหน้าแสดงหน้านี้แทน ด้วยสถานะ HTTP 503 ถ้าระบบล่มโดยไม่ได้วางแผน ใช้หน้าระบบขัดข้อง 5xx
คอมโพเนนต์ที่ใช้
- StatusPageA page for an outcome instead of the content: the page wasn't found, the person may not open it, the server failed, or the system is closed for maintenance.
- ButtonA button, or a link that looks like one with href.
import { StatusPage, Button } from "@bsru/ui";กฎของหน้านี้
ถ้อยคำ
- บอกว่าปิดตามแผน ไม่ใช่ขัดข้อง และบอกว่าข้อมูลที่บันทึกไว้แล้วไม่สูญหาย
- บอกเวลาที่คาดว่าจะกลับมาด้วย expectedBack เป็นวันที่และเวลาแบบไทย พร้อมปีพุทธศักราช ถ้าไม่รู้เวลาแน่ชัด อย่าเดา ให้เว้นไว้
- บอกผลต่อผู้ใช้ เช่น คำขอที่รออนุมัติยังอยู่ หรือระบบอื่นยังใช้ได้
ปุ่มและทางไปต่อ
- ปุ่มเดียว: ลองเปิดอีกครั้ง ซึ่งโหลดหน้าแรกใหม่ ไม่ต้องมีปุ่มอื่น
- อย่าให้ลิงก์ไปหน้าที่ต้องเข้าสู่ระบบหรือเรียก API ระหว่างปิดปรับปรุง
ห้ามแสดง
- รายละเอียดงานปรับปรุง เวอร์ชัน ชื่อเซิร์ฟเวอร์ หรือขั้นตอนการ deploy
- ข้อมูลของผู้ใช้ หน้านี้ไม่อ่าน session และไม่เรียก API หลัก
ในแอป
- เป็นหน้าคงที่ เปิดได้แม้ระบบหลักปิดอยู่ ตอบด้วย 503 และ Retry-After ส่วน /healthz ยังตอบตามจริง
- ใช้แบบเต็มหน้าจอเสมอ พร้อม brand และ notice ในระบบจำลอง
ตัวอย่างทั้งหน้า
แต่ละตัวอย่างเป็นหน้าเต็ม แสดงในกรอบจอคอมพิวเตอร์ เลือกโทรศัพท์หรือแท็บเล็ตที่แถบบนเพื่อดูบนจอนั้น ข้อมูลทั้งหมดเป็นข้อมูลสมมติ
ERP: ปิดปรับปรุงพร้อมเวลากลับมา
ทุกหน้าแสดงหน้านี้ด้วยสถานะ 503 expectedBack บอกเวลาที่คาดว่าจะกลับมา ไม่มีรหัสแสดง เพราะการปิดปรับปรุงไม่ใช่ข้อผิดพลาด
// 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" } });
}| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| kind* จำเป็น | "maintenance" | StatusKind ค่าที่ใช้ได้: "notFound""forbidden""serverError""maintenance" | notFound for 404, forbidden for 403, serverError for 500 and the other 5xx, maintenance for a planned closure. |
| brand | ออบเจกต์ 4 ฟิลด์{
name: "BSRU ERP",
caption: "มหาวิทยาลัยราชภัฏบ้านสมเด็จเจ้าพระยา",
logo: "/bsru-logo.png",
alt: "ตรามหาวิทยาลัยราชภัฏบ้านสมเด็จเจ้าพระยา",
} | PageBrand | The logo and system name at the top of a whole page. Leave it out inside AppShell, which shows its own. |
| notice | "ระบบจำลอง ใช้ข้อมูลทดสอบเท่านั้น" | string | The gold strip across the top of a whole page, for demo and test systems, such as ระบบจำลอง. |
| description | "ระบบปิดเพื่อปรับปรุงประจำเดือน ข้อมูลที่บันทึกไว้แล้วไม่สูญหาย และคำขอที่รออนุมัติยังอยู่ครบ" | string | What to do next, in a sentence or two. Defaults to a sentence for the kind in the screen language. |
| expectedBack | "23 พ.ย. 2569 เวลา 18:00 น." | string | For maintenance: when the system is expected back, as text, such as 23 พ.ย. 2569 เวลา 18:00 น. |
| actions | <Button tone="primary" icon={RotateCw} label="ลองเปิดอีกครั้ง" href="#" /> | ReactNode | The ways forward, as Button components, with the primary one first, such as Back to the home page. |
คอนโซล: ปิดเฉพาะคอนโซล
คอนโซลปิดแต่ ERP ยังเปิด หัวข้อและคำอธิบายบอกผลต่อผู้ใช้ code แสดง 503 สำหรับทีมที่ต้องการเห็นรหัส ไม่รู้เวลาแน่ชัด จึงไม่มี expectedBack
<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="/" />}
/>| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| kind* จำเป็น | "maintenance" | StatusKind ค่าที่ใช้ได้: "notFound""forbidden""serverError""maintenance" | notFound for 404, forbidden for 403, serverError for 500 and the other 5xx, maintenance for a planned closure. |
| code | "503" | string | null | The code shown above the title. Defaults to 404, 403 or 500 for the kind, and none for maintenance. Pass 503, say, to change it, or null to hide it. |
| brand | ออบเจกต์ 4 ฟิลด์{
name: "BSRU ERP คอนโซลผู้ดูแลระบบ",
caption: "มหาวิทยาลัยราชภัฏบ้านสมเด็จเจ้าพระยา",
logo: "/bsru-logo.png",
alt: "ตรามหาวิทยาลัยราชภัฏบ้านสมเด็จเจ้าพระยา",
} | PageBrand | The logo and system name at the top of a whole page. Leave it out inside AppShell, which shows its own. |
| notice | "ระบบจำลอง ใช้ข้อมูลทดสอบเท่านั้น" | string | The gold strip across the top of a whole page, for demo and test systems, such as ระบบจำลอง. |
| title | "คอนโซลปิดปรับปรุงชั่วคราว" | string | What happened, the page's level 1 heading. Defaults to a title for the kind in the screen language. |
| description | "ระหว่างนี้ยังไม่สามารถแก้ไขบัญชีผู้ใช้หรือสิทธิ์ได้ ผู้ใช้ BSRU ERP ยังใช้งานได้ตามปกติ" | string | What to do next, in a sentence or two. Defaults to a sentence for the kind in the screen language. |
| actions | <Button tone="primary" icon={RotateCw} label="ลองเปิดอีกครั้ง" href="#" /> | ReactNode | The ways forward, as Button components, with the primary one first, such as Back to the home page. |