add pwa config

This commit is contained in:
2026-04-15 11:50:15 +03:30
parent d163d2c23f
commit fee71ef99f
11 changed files with 146 additions and 3 deletions

4
messages/fa.json Normal file
View File

@@ -0,0 +1,4 @@
{
"loading": "درحال دریافت داده",
"error_fetch_data": "مشکلی در دریافت داده رخ داده است."
}

25
next.config.ts Normal file
View File

@@ -0,0 +1,25 @@
// next.config.ts
import type { NextConfig } from "next";
import createNextIntlPlugin from "next-intl/plugin";
// @ts-ignore no types for next-pwa
const withPWA = require("next-pwa")({
dest: "public",
disable: process.env.NODE_ENV === "development",
register: true,
skipWaiting: true,
navigateFallback: "/offline.html", // fallback page
});
const withNextIntl = createNextIntlPlugin();
const nextConfig: NextConfig = {
// output : "standalone",
images: {
remotePatterns: [],
},
};
const configWithIntl = withNextIntl(nextConfig);
export default withPWA(configWithIntl);

BIN
public/logo/144px.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

BIN
public/logo/152px.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

BIN
public/logo/192px.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

BIN
public/logo/384px.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
public/logo/512px.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

38
public/manifest.json Normal file
View File

@@ -0,0 +1,38 @@
{
"id": "/",
"name": "Theater of dreams",
"short_name": "Theater of dreams",
"description": "Theater of dreams",
"start_url": "/",
"display": "standalone",
"orientation": "portrait",
"theme_color": "#283618",
"background_color": "#ffffff",
"icons": [
{
"src": "logo/144px.png",
"sizes": "144x144",
"type": "image/png"
},
{
"src": "logo/152px.png",
"sizes": "152x152",
"type": "image/png"
},
{
"src": "logo/192px.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "logo/384px.png",
"sizes": "384x384",
"type": "image/png"
},
{
"src": "logo/512px.png",
"sizes": "512x512",
"type": "image/png"
}
]
}

View File

@@ -1,12 +1,35 @@
import { ClientAppProvider } from "@/providers/ClientAppProvider";
import "@/styles/globals.css";
import type { Metadata } from "next";
import { getLocale, getMessages } from "next-intl/server";
import { NextIntlClientProvider } from "next-intl";
export const metadata: Metadata = {
title: "Theater of dreams",
title: {
template: "%s | Theater of dreams",
default: "Theater of dreams",
},
description: "Theater of dreams",
authors: {
name: "شرکت دانش بنیان ویرا ارتباطات یکتا تلفن (وایتل)",
url: "https://witel.ir",
},
manifest: "/manifest.json",
icons: {
icon: "/logo/192px.png",
apple: "/logo/512px.png",
},
};
export const viewport = {
width: "device-width",
initialScale: 1,
maximumScale: 1,
};
export default function RootLayout({ children }: { children: React.ReactNode }) {
export default async function RootLayout({ children }: { children: React.ReactNode }) {
const locale = await getLocale();
const messages = await getMessages({ locale });
return (
<html lang="en" suppressHydrationWarning>
<head>
@@ -27,7 +50,9 @@ export default function RootLayout({ children }: { children: React.ReactNode })
</head>
<body className="bg-primary">
<ClientAppProvider>{children}</ClientAppProvider>
<NextIntlClientProvider locale={locale} messages={messages}>
<ClientAppProvider>{children}</ClientAppProvider>
</NextIntlClientProvider>
</body>
</html>
);

39
src/app/not-found.tsx Normal file
View File

@@ -0,0 +1,39 @@
import Link from "next/link";
export default function NotFound() {
return (
<div className="bg-pwa-primary text-text flex min-h-screen items-center justify-center">
<div className="bg-pwa-primary mx-4 w-full max-w-md rounded-xl p-8 text-center">
{/* آیکون خطا */}
{/*<div className="mb-4 flex justify-center">*/}
{/* <svg*/}
{/* xmlns="http://www.w3.org/2000/svg"*/}
{/* className="h-16 w-16 text-core-red"*/}
{/* fill="none"*/}
{/* viewBox="0 0 24 24"*/}
{/* stroke="currentColor"*/}
{/* >*/}
{/* <path*/}
{/* strokeLinecap="round"*/}
{/* strokeLinejoin="round"*/}
{/* strokeWidth={2}*/}
{/* d="M9.172 16.172a4 4 0 015.656 0M9 10h.01M15 10h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"*/}
{/* />*/}
{/* </svg>*/}
{/*</div>*/}
{/* متن خطا */}
<h2 className="text-text mb-2 text-2xl font-bold">صفحه مورد نظر یافت نشد</h2>
<p className="text-text mb-6 leading-relaxed">متاسفانه صفحهای مورد نظر وجود ندارد.</p>
{/* دکمه بازگشت با استفاده از کامپوننت Link */}
<Link
href="/"
className="bg-neo-aqua hover:bg-neo-aqua/70 inline-block rounded-lg px-6 py-3 font-medium text-white shadow-md transition-colors duration-200 hover:shadow-lg"
>
بازگشت به صفحه اصلی
</Link>
</div>
</div>
);
}

12
src/i18n/request.ts Normal file
View File

@@ -0,0 +1,12 @@
import { cookies } from "next/headers";
import { getRequestConfig } from "next-intl/server";
export default getRequestConfig(async () => {
const cookieStore = await cookies();
const locale = cookieStore.get("language")?.value || "fa";
return {
locale,
messages: (await import(`../../messages/${locale}.json`)).default,
};
});