File tree Expand file tree Collapse file tree 3 files changed +25
-0
lines changed
Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,9 @@ import AuthProvider from '@/lib/AuthProvider';
66import { getServerSession } from 'next-auth' ;
77import { authOptions } from '@/lib/authOptions' ;
88import { Metadata } from 'next' ;
9+ import { headers } from 'next/headers' ;
10+ import { detectDeviceType } from '@/shared/util/detectDeviceType' ;
11+ import MobileBlockUI from '@/shared/ui/moblieBlockUI/MoblieBlockUI' ;
912
1013export const metadata : Metadata = {
1114 title : 'EZ-CODE - 코딩 테스트' ,
@@ -20,6 +23,16 @@ export default async function RootLayout({
2023} : Readonly < {
2124 children : React . ReactNode ;
2225} > ) {
26+ const ua = ( await headers ( ) ) . get ( 'user-agent' ) ?? '' ;
27+ const device = detectDeviceType ( ua ) ;
28+ if ( device === 'mobile' )
29+ return (
30+ < html >
31+ < body >
32+ < MobileBlockUI />
33+ </ body >
34+ </ html >
35+ ) ;
2336 const session = await getServerSession ( authOptions ) ;
2437 return (
2538 < html lang = "ko" >
Original file line number Diff line number Diff line change 1+ export default function MobileBlockUI ( ) {
2+ return (
3+ < div className = "flex flex-col justify-center items-center w-full h-screen bg-background text-white px-4 text-center" >
4+ < h1 className = "text-3xl font-bold mb-4" > 아직 데스크탑을 제외한 환경은 지원하지 않습니다</ h1 >
5+ </ div >
6+ ) ;
7+ }
Original file line number Diff line number Diff line change 1+ export function detectDeviceType ( ua : string ) {
2+ const agent = ua . toLowerCase ( ) ;
3+ const isMobile = / i p h o n e | i p a d | i p o d | a n d r o i d | b l a c k b e r r y | m i n i | w i n d o w s \s c e | p a l m / i. test ( agent ) ;
4+ return isMobile ? 'mobile' : 'desktop' ;
5+ }
You can’t perform that action at this time.
0 commit comments