صفحهٔ ۵۰۲
پیشنمایش تمامصفحهخطای سرور با همان تابلوی آویزانِ صفحهٔ ۴۰۴ که یک بندش پاره شده، دکمهٔ تلاشِ دوباره و پیوندِ وضعیت سرویسها.
۱. نصب کامپوننتها
این بلاک از ۴ آیتم دیگ استفاده میکند: buttoncontrol-sizeiconslink
npx digdesign@latest add https://docs.digdesign.ir/r/button.json https://docs.digdesign.ir/r/control-size.json https://docs.digdesign.ir/r/icons.json https://docs.digdesign.ir/r/link.jsonpnpm dlx digdesign@latest add https://docs.digdesign.ir/r/button.json https://docs.digdesign.ir/r/control-size.json https://docs.digdesign.ir/r/icons.json https://docs.digdesign.ir/r/link.jsonyarn dlx digdesign@latest add https://docs.digdesign.ir/r/button.json https://docs.digdesign.ir/r/control-size.json https://docs.digdesign.ir/r/icons.json https://docs.digdesign.ir/r/link.jsonbunx --bun digdesign@latest add https://docs.digdesign.ir/r/button.json https://docs.digdesign.ir/r/control-size.json https://docs.digdesign.ir/r/icons.json https://docs.digdesign.ir/r/link.jsonnpx digdesign@latest add button control-size link --framework vuepnpm dlx digdesign@latest add button control-size link --framework vueyarn dlx digdesign@latest add button control-size link --framework vuebunx --bun digdesign@latest add button control-size link --framework vuenpx digdesign@latest add button --framework sveltepnpm dlx digdesign@latest add button --framework svelteyarn dlx digdesign@latest add button --framework sveltebunx --bun digdesign@latest add button --framework sveltenpx digdesign@latest add button control-size icons link --framework angularpnpm dlx digdesign@latest add button control-size icons link --framework angularyarn dlx digdesign@latest add button control-size icons link --framework angularbunx --bun digdesign@latest add button control-size icons link --framework angularnpx digdesign@latest add button control-size link --framework androidpnpm dlx digdesign@latest add button control-size link --framework androidyarn dlx digdesign@latest add button control-size link --framework androidbunx --bun digdesign@latest add button control-size link --framework android۲. کد صفحه
کد را در صفحهٔ پروژهتان بگذارید (React: app/<route>/page.tsx) و متنها، داده و هندلرها را با محصول خودتان عوض کنید. با سوییچر فریمورک کدِ همین صفحه در فریمورک دیگر را ببینید.
"use client"
import * as React from "react"
import NextLink from "next/link"
import { RefreshIcon } from "@/components/icons"
import { Button } from "@/components/ui/button"
import { ControlSizeProvider } from "@/components/ui/control-size"
import { Link } from "@/components/ui/link"
/**
* تصویرِ خطی تابلوی آویزان؛ فقط رنگِ متن و پسزمینهٔ تم، پس در حالتِ تیره هم درست است.
*/
function BrokenSign({ className }: { className?: string }) {
return (
<svg viewBox="-10 0 320 290" role="img" aria-label="تابلوی ۵۰۲ که یک بندش پاره شده" className={className}>
{/* میخ؛ بندِ چپ پاره شده و تابلو از بندِ راست کج آویزان است */}
<circle cx="150" cy="26" r="6" fill="var(--background)" stroke="currentColor" strokeWidth="2" />
<path d="M150 20v-8" stroke="currentColor" strokeWidth="2" strokeLinecap="round" />
<path d="M150 30l-26 40" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" />
<path d="m124 70-5 6m5-6 1 8m-1-8-7 2" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
<g transform="rotate(14 150 30)">
<path d="M150 30l62 79" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" />
<path d="m96 109-4-8m4 8 3-7" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
{/* عمقِ تابلو: لایهٔ پشتی با فاصله، مثلِ برشهای خطی نمونه */}
<path d="M58 114h200v122H58z" transform="translate(8 7)" fill="var(--background)" stroke="currentColor" strokeWidth="2" strokeLinejoin="round" />
<path d="M258 114l8 7v122l-8-7M58 236l8 7h200" fill="none" stroke="currentColor" strokeWidth="2" strokeLinejoin="round" />
{/* بدنهٔ پنجره */}
<rect x="50" y="108" width="208" height="126" fill="var(--background)" stroke="currentColor" strokeWidth="2" />
<path d="M50 128h208" stroke="currentColor" strokeWidth="2" />
{/* سربرگ: منو و دو دایره، و حلقههای بند */}
<path d="M60 114h10M60 118h10M60 122h10" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" />
<circle cx="236" cy="118" r="2.6" fill="none" stroke="currentColor" strokeWidth="1.6" />
<circle cx="246" cy="118" r="2.6" fill="none" stroke="currentColor" strokeWidth="1.6" />
<circle cx="96" cy="112" r="3.2" fill="var(--background)" stroke="currentColor" strokeWidth="1.75" />
<circle cx="212" cy="112" r="3.2" fill="var(--background)" stroke="currentColor" strokeWidth="1.75" />
<rect x="56" y="134" width="196" height="94" fill="currentColor" />
<text x="154" y="198" textAnchor="middle" fontSize="54" fontWeight="800" fill="var(--background)">۵۰۲</text>
</g>
</svg>
)
}
/** صفحهٔ ۵۰۲ (سرورِ میانی پاسخ نداد)؛ همان سبکِ صفحهٔ ۴۰۴ با دکمهٔ تلاشِ دوباره. */
export default function ServerErrorBlock() {
const [retrying, setRetrying] = React.useState(false)
return (
<ControlSizeProvider size="xl" asChild>
<main className="flex min-h-svh flex-col items-center justify-center gap-8 p-6 text-center">
<BrokenSign className="w-64 max-w-full text-foreground sm:w-80" />
<div className="flex max-w-md flex-col items-center gap-3">
<h1 className="text-3xl leading-snug font-bold">اِ… سیمش در رفته!</h1>
<p className="leading-7 text-muted-foreground">
سرورمون الان جواب نمیده. یه لحظه دیگه دوباره امتحان کن؛ اطلاعاتت سر جاشه، نگران نباش.
</p>
</div>
<div className="flex flex-wrap justify-center gap-3">
<Button
loading={retrying}
onClick={() => {
setRetrying(true)
window.setTimeout(() => window.location.reload(), 600)
}}
>
<RefreshIcon />
دوباره امتحان کن
</Button>
<Button asChild variant="outline">
<NextLink href="/">برگردیم خونه</NextLink>
</Button>
</div>
<p className="text-sm text-muted-foreground">
اگه درست نشد، <Link href="/status">وضعیت سرویسها</Link> رو ببین.
</p>
</main>
</ControlSizeProvider>
)
}
<script setup lang="ts">
import { ref } from "vue"
import Button from "@/components/ui/Button.vue"
import ControlSize from "@/components/ui/ControlSize.vue"
import Link from "@/components/ui/Link.vue"
import { DigIcon } from "@/lib/icons"
/** صفحهٔ ۵۰۲ (سرورِ میانی پاسخ نداد)؛ همان سبکِ صفحهٔ ۴۰۴ با دکمهٔ تلاشِ دوباره. */
const retrying = ref(false)
function retry() {
retrying.value = true
window.setTimeout(() => window.location.reload(), 600)
}
</script>
<template>
<ControlSize size="xl" as-child>
<main class="flex min-h-svh flex-col items-center justify-center gap-8 p-6 text-center">
<svg viewBox="-10 0 320 290" role="img" aria-label="تابلوی ۵۰۲ که یک بندش پاره شده" class="w-64 max-w-full text-foreground sm:w-80">
<circle cx="150" cy="26" r="6" fill="var(--background)" stroke="currentColor" stroke-width="2" />
<path d="M150 20v-8" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
<path d="M150 30l-26 40" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" />
<path d="m124 70-5 6m5-6 1 8m-1-8-7 2" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" />
<g transform="rotate(14 150 30)">
<path d="M150 30l62 79" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" />
<path d="m96 109-4-8m4 8 3-7" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" />
<path d="M58 114h200v122H58z" transform="translate(8 7)" fill="var(--background)" stroke="currentColor" stroke-width="2" stroke-linejoin="round" />
<path d="M258 114l8 7v122l-8-7M58 236l8 7h200" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round" />
<rect x="50" y="108" width="208" height="126" fill="var(--background)" stroke="currentColor" stroke-width="2" />
<path d="M50 128h208" stroke="currentColor" stroke-width="2" />
<path d="M60 114h10M60 118h10M60 122h10" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" />
<circle cx="236" cy="118" r="2.6" fill="none" stroke="currentColor" stroke-width="1.6" />
<circle cx="246" cy="118" r="2.6" fill="none" stroke="currentColor" stroke-width="1.6" />
<circle cx="96" cy="112" r="3.2" fill="var(--background)" stroke="currentColor" stroke-width="1.75" />
<circle cx="212" cy="112" r="3.2" fill="var(--background)" stroke="currentColor" stroke-width="1.75" />
<rect x="56" y="134" width="196" height="94" fill="currentColor" />
<text x="154" y="198" text-anchor="middle" font-size="54" font-weight="800" fill="var(--background)">۵۰۲</text>
</g>
</svg>
<div class="flex max-w-md flex-col items-center gap-3">
<h1 class="text-3xl leading-snug font-bold">اِ… سیمش در رفته!</h1>
<p class="leading-7 text-muted-foreground">
سرورمون الان جواب نمیده. یه لحظه دیگه دوباره امتحان کن؛ اطلاعاتت سر جاشه، نگران نباش.
</p>
</div>
<div class="flex flex-wrap justify-center gap-3">
<Button :loading="retrying" @click="retry">
<DigIcon name="refresh" />
دوباره امتحان کن
</Button>
<Button as-child variant="outline">
<a href="/">برگردیم خونه</a>
</Button>
</div>
<p class="text-sm text-muted-foreground">
اگه درست نشد، <Link href="/status">وضعیت سرویسها</Link> رو ببین.
</p>
</main>
</ControlSize>
</template>
کدِ این بلاک هنوز برای Svelte نوشته نشده است.
این موارد هنوز برای Svelte آماده نیستند: control-sizelinkآیکون refresh
کدِ React همین بلاک مرجع است. با MCP دیگ و get_block با framework="svelte" ایجنت آن را با کامپوننتهای Svelte میسازد.
import {
ChangeDetectionStrategy,
Component,
DestroyRef,
inject,
signal,
} from "@angular/core"
import { DigButton } from "@/components/ui/button"
import { DigControlSize } from "@/components/ui/control-size"
import { DigIcon } from "@/lib/icons"
import { DigLink } from "@/components/ui/link"
@Component({
selector: "dig-block-server-error",
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [DigButton, DigControlSize, DigIcon, DigLink],
template: `
<main
digControlSize="xl"
class="flex min-h-svh flex-col items-center justify-center gap-8 p-6 text-center"
>
<svg
viewBox="-10 0 320 290"
role="img"
aria-label="تابلوی ۵۰۲ که یک بندش پاره شده"
class="w-64 max-w-full text-foreground sm:w-80"
>
<circle
cx="150"
cy="26"
r="6"
fill="var(--background)"
stroke="currentColor"
strokeWidth="2"
></circle>
<path
d="M150 20v-8"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
></path>
<path
d="M150 30l-26 40"
fill="none"
stroke="currentColor"
strokeWidth="1.75"
strokeLinecap="round"
></path>
<path
d="m124 70-5 6m5-6 1 8m-1-8-7 2"
fill="none"
stroke="currentColor"
strokeWidth="1.5"
strokeLinecap="round"
></path>
<g transform="rotate(14 150 30)">
<path
d="M150 30l62 79"
fill="none"
stroke="currentColor"
strokeWidth="1.75"
strokeLinecap="round"
></path>
<path
d="m96 109-4-8m4 8 3-7"
fill="none"
stroke="currentColor"
strokeWidth="1.5"
strokeLinecap="round"
></path>
<path
d="M58 114h200v122H58z"
transform="translate(8 7)"
fill="var(--background)"
stroke="currentColor"
strokeWidth="2"
strokeLinejoin="round"
></path>
<path
d="M258 114l8 7v122l-8-7M58 236l8 7h200"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinejoin="round"
></path>
<rect
x="50"
y="108"
width="208"
height="126"
fill="var(--background)"
stroke="currentColor"
strokeWidth="2"
></rect>
<path d="M50 128h208" stroke="currentColor" strokeWidth="2"></path>
<path
d="M60 114h10M60 118h10M60 122h10"
stroke="currentColor"
strokeWidth="1.75"
strokeLinecap="round"
></path>
<circle
cx="236"
cy="118"
r="2.6"
fill="none"
stroke="currentColor"
strokeWidth="1.6"
></circle>
<circle
cx="246"
cy="118"
r="2.6"
fill="none"
stroke="currentColor"
strokeWidth="1.6"
></circle>
<circle
cx="96"
cy="112"
r="3.2"
fill="var(--background)"
stroke="currentColor"
strokeWidth="1.75"
></circle>
<circle
cx="212"
cy="112"
r="3.2"
fill="var(--background)"
stroke="currentColor"
strokeWidth="1.75"
></circle>
<rect
x="56"
y="134"
width="196"
height="94"
fill="currentColor"
></rect>
<text
x="154"
y="198"
textAnchor="middle"
fontSize="54"
fontWeight="800"
fill="var(--background)"
>
۵۰۲
</text>
</g>
</svg>
<div class="flex max-w-md flex-col items-center gap-3">
<h1 class="text-3xl leading-snug font-bold">اِ… سیمش در رفته!</h1>
<p class="leading-7 text-muted-foreground">
سرورمون الان جواب نمیده. یه لحظه دیگه دوباره امتحان کن؛ اطلاعاتت سر
جاشه، نگران نباش.
</p>
</div>
<div class="flex flex-wrap justify-center gap-3">
<button
digButton
type="button"
[loading]="retrying()"
(click)="retry()"
>
<svg digIcon="refresh"></svg>
دوباره امتحان کن
</button>
<a digButton variant="outline" href="/">برگردیم خونه</a>
</div>
<p class="text-sm text-muted-foreground">
اگه درست نشد، <a digLink href="/status">وضعیت سرویسها</a> رو ببین.
</p>
</main>
`,
})
export class ServerErrorBlock {
readonly retrying = signal(false)
private timer?: ReturnType<typeof setTimeout>
constructor() {
inject(DestroyRef).onDestroy(() => clearTimeout(this.timer))
}
retry() {
if (this.retrying()) return
this.retrying.set(true)
this.timer = setTimeout(() => window.location.reload(), 600)
}
}
کدِ این بلاک هنوز برای Android نوشته نشده است.
همهٔ کامپوننتهای لازم برای Android آمادهاند؛ با MCP میتوانید همین صفحه را از روی نسخهٔ React بسازید.
کدِ React همین بلاک مرجع است. با MCP دیگ و get_block با framework="android" ایجنت آن را با کامپوننتهای Android میسازد.