화면 해상도 설정 기능 구현

This commit is contained in:
kjs
2025-09-04 17:01:07 +09:00
parent 9bf879e29d
commit 1c2249ee42
7 changed files with 498 additions and 129 deletions

View File

@@ -1,7 +1,7 @@
"use client";
import { useState } from "react";
import { useRouter, usePathname } from "next/navigation";
import { useRouter, usePathname, useSearchParams } from "next/navigation";
import { Button } from "@/components/ui/button";
import {
Shield,
@@ -194,6 +194,7 @@ const convertSingleMenu = (menu: MenuItem, allMenus: MenuItem[], userInfo: Exten
export function AppLayout({ children }: AppLayoutProps) {
const router = useRouter();
const pathname = usePathname();
const searchParams = useSearchParams();
const { user, logout, refreshUserData } = useAuth();
const { userMenus, adminMenus, loading, refreshMenus } = useMenu();
const [sidebarOpen, setSidebarOpen] = useState(false);
@@ -216,8 +217,8 @@ export function AppLayout({ children }: AppLayoutProps) {
saveProfile,
} = useProfile(user, refreshUserData, refreshMenus);
// 현재 경로에 따라 어드민 모드인지 판단
const isAdminMode = pathname.startsWith("/admin");
// 현재 경로에 따라 어드민 모드인지 판단 (쿼리 파라미터도 고려)
const isAdminMode = pathname.startsWith("/admin") || searchParams.get("mode") === "admin";
// 현재 모드에 따라 표시할 메뉴 결정
const currentMenus = isAdminMode ? adminMenus : userMenus;
@@ -246,7 +247,20 @@ export function AppLayout({ children }: AppLayoutProps) {
if (assignedScreens.length > 0) {
// 할당된 화면이 있으면 첫 번째 화면으로 이동
const firstScreen = assignedScreens[0];
router.push(`/screens/${firstScreen.screenId}`);
// 관리자 모드 상태를 쿼리 파라미터로 전달
const screenPath = isAdminMode
? `/screens/${firstScreen.screenId}?mode=admin`
: `/screens/${firstScreen.screenId}`;
console.log("🎯 메뉴에서 화면으로 이동:", {
menuName: menu.name,
screenId: firstScreen.screenId,
isAdminMode,
targetPath: screenPath,
});
router.push(screenPath);
setSidebarOpen(false);
return;
}