once load splash

This commit is contained in:
hamid zarghami
2026-06-06 10:04:47 +03:30
parent e948b00f55
commit 2ae99faca9
12 changed files with 201 additions and 64 deletions
+2 -1
View File
@@ -1,5 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { fetchWithTimeout } from "@/lib/helpers/fetchWithTimeout";
import { PWA_ICON_192 } from "@/lib/helpers/pwaIcons";
import { NextRequest, NextResponse } from "next/server";
import sharp from "sharp";
@@ -7,7 +8,7 @@ export const dynamic = "force-dynamic";
export const revalidate = 0;
const FETCH_TIMEOUT_MS = 5000;
const DEFAULT_ICON = "/icons/web-app-manifest-192x192.png";
const DEFAULT_ICON = PWA_ICON_192;
export async function GET(
request: NextRequest,
+8 -7
View File
@@ -5,6 +5,7 @@ import { getRestaurant } from './lib/getRestaurant'
import { notFound } from 'next/navigation'
import CartChecker from '@/components/CartChecker'
import ActiveChecker from '@/components/ActiveChecker'
import { PWA_ICON_192, PWA_ICON_512 } from '@/lib/helpers/pwaIcons'
export const dynamic = 'force-dynamic'
export const revalidate = 0
@@ -17,8 +18,8 @@ export async function generateMetadata({
params: Promise<LayoutParams>
}): Promise<Metadata> {
const { name } = await params
const defaultIcon = "/icons/web-app-manifest-192x192.png"
const defaultIcon512 = "/icons/web-app-manifest-512x512.png"
const defaultIcon = PWA_ICON_192
const defaultIcon512 = PWA_ICON_512
try {
const restaurant = await getRestaurant(name)
@@ -56,12 +57,12 @@ export async function generateMetadata({
manifest: `/${name}/manifest.webmanifest`,
icons: {
icon: [
{ url: "/icons/web-app-manifest-192x192.png" },
{ url: "/icons/web-app-manifest-192x192.png", sizes: "192x192", type: "image/png" },
{ url: "/icons/web-app-manifest-512x512.png", sizes: "512x512", type: "image/png" },
{ url: PWA_ICON_192 },
{ url: PWA_ICON_192, sizes: "192x192", type: "image/png" },
{ url: PWA_ICON_512, sizes: "512x512", type: "image/png" },
],
shortcut: "/icons/web-app-manifest-192x192.png",
apple: "/icons/web-app-manifest-192x192.png",
shortcut: PWA_ICON_192,
apple: PWA_ICON_192,
},
}
}
+3 -32
View File
@@ -1,47 +1,18 @@
import { NextResponse } from "next/server";
import { buildPwaManifestIcons } from "@/lib/helpers/pwaIcons";
import { getRestaurant } from "../lib/getRestaurant";
export const dynamic = "force-dynamic";
export const revalidate = 0;
function buildManifestIcons(name: string, logo?: string | null) {
const default192 = "/icons/web-app-manifest-192x192.png";
const default512 = "/icons/web-app-manifest-512x512.png";
if (logo && logo.trim() !== "") {
const logo192 = `/${name}/api/logo?url=${encodeURIComponent(logo)}&size=192`;
const logo512 = `/${name}/api/logo?url=${encodeURIComponent(logo)}&size=512`;
return [
{
src: logo192,
sizes: "192x192",
type: "image/png",
purpose: "any",
},
{
src: logo512,
sizes: "512x512",
type: "image/png",
purpose: "any",
},
];
return buildPwaManifestIcons(logo192, logo512);
}
return [
{
src: default192,
sizes: "192x192",
type: "image/png",
purpose: "any",
},
{
src: default512,
sizes: "512x512",
type: "image/png",
purpose: "any",
},
];
return buildPwaManifestIcons();
}
export async function GET(