diff --git a/Dockerfile b/Dockerfile index cd18c50..14171d7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,11 +7,11 @@ RUN apt-get update && apt-get install -y openssl libc6 WORKDIR /app # کپی فایل‌های نصب پکیج -COPY package.json package-lock.json* ./ +COPY package.json ./ COPY prisma ./prisma/ -# نصب پکیج‌ها و جنریت کردن کلاینت Prisma -RUN npm install +# نصب پکیج‌ها و دریافت باینری‌های مناسب لینوکس +RUN rm -rf package-lock.json && npm install RUN npx prisma generate # مرحله ۲: بیلد پروژه diff --git a/src/app/page.js b/src/app/page.js index 917d804..d9d897f 100644 --- a/src/app/page.js +++ b/src/app/page.js @@ -1,6 +1,6 @@ 'use client'; import { useState, useEffect } from 'react'; -import { Fingerprint } from 'lucide-react'; +import { Fingerprint, Download, Share } from 'lucide-react'; import { useRouter } from 'next/navigation'; import { motion, AnimatePresence } from 'framer-motion'; @@ -10,21 +10,45 @@ export default function EntryPage() { const [error, setError] = useState(''); const [loading, setLoading] = useState(false); const [showSplash, setShowSplash] = useState(true); + const [showInstall, setShowInstall] = useState(false); const [isFocused, setIsFocused] = useState(false); + const [deferredPrompt, setDeferredPrompt] = useState(null); + const [isIOS, setIsIOS] = useState(false); const router = useRouter(); useEffect(() => { + const handleBeforeInstallPrompt = (e) => { + e.preventDefault(); + setDeferredPrompt(e); + }; + window.addEventListener('beforeinstallprompt', handleBeforeInstallPrompt); + + const ua = window.navigator.userAgent; + const isIOSDevice = /iPad|iPhone|iPod/.test(ua) && !window.MSStream; + setIsIOS(isIOSDevice); + const checkAuth = async () => { const token = localStorage.getItem('token'); await new Promise(resolve => setTimeout(resolve, 2500)); - if (token) { - router.push('/dashboard'); - } else { + + const isStandalone = window.matchMedia('(display-mode: standalone)').matches || window.navigator.standalone; + + if (!isStandalone && process.env.NODE_ENV !== 'development') { setShowSplash(false); + setShowInstall(true); + } else { + if (token) { + router.push('/dashboard'); + } else { + setShowSplash(false); + setShowInstall(false); + } } }; checkAuth(); + + return () => window.removeEventListener('beforeinstallprompt', handleBeforeInstallPrompt); }, [router]); const handleLogin = async (e) => { @@ -123,6 +147,75 @@ export default function EntryPage() { className="absolute bottom-6 h-1 bg-gradient-to-r from-purple-500 to-blue-500 rounded-full" /> + ) : showInstall ? ( + +
+ پردیس رایانه +
+ +

+ تجربه بهتر در اپلیکیشن +

+ +

+ برای تجربه سریع‌تر، دسترسی آفلاین و استفاده از ورود امن با اثر انگشت، پیشنهاد می‌کنیم اپلیکیشن انبارگردانی را روی دستگاه خود نصب کنید. +

+ +
+ {isIOS ? ( +
+

راهنمای نصب در آیفون (iOS):

+
+ ۱. لمس + ۲. انتخاب Add to Home Screen +
+
+ ) : ( + { + if (deferredPrompt) { + deferredPrompt.prompt(); + const { outcome } = await deferredPrompt.userChoice; + if (outcome === 'accepted') { + setDeferredPrompt(null); + } + } else { + alert('مرورگر شما از نصب مستقیم پشتیبانی نمی‌کند. از منوی مرورگر Add to Home screen را انتخاب کنید.'); + } + }} + className="w-full py-4 bg-gray-900 text-white text-sm font-extrabold rounded-[20px] transition-all flex items-center justify-center shadow-sm gap-2" + > + + نصب مستقیم اپلیکیشن + + )} + + +
+ +
+ + H U K A + + طراحی توسط هوکا +
+
) : (