Skip to content

Commit f610e54

Browse files
authored
Merge pull request #144 from ezcode-my/feat/non-desktop-block
feat: 모바일 디바이스 감지 및 모바일 전용 UI 추가
2 parents 0242d8d + 7d41a22 commit f610e54

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

src/app/layout.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import AuthProvider from '@/lib/AuthProvider';
66
import { getServerSession } from 'next-auth';
77
import { authOptions } from '@/lib/authOptions';
88
import { 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

1013
export 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">
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
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+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export function detectDeviceType(ua: string) {
2+
const agent = ua.toLowerCase();
3+
const isMobile = /iphone|ipad|ipod|android|blackberry|mini|windows\sce|palm/i.test(agent);
4+
return isMobile ? 'mobile' : 'desktop';
5+
}

0 commit comments

Comments
 (0)