From 986e7a5c3bbc13553aedd579e57a59edb516cc59 Mon Sep 17 00:00:00 2001 From: leedj312 Date: Fri, 8 Aug 2025 17:30:22 +0900 Subject: [PATCH] =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=84=A0?= =?UTF-8?q?=ED=83=9D=20=EC=98=A4=EB=A5=98=20=EB=B0=8F=20=EC=9E=98=EB=AA=BB?= =?UTF-8?q?=EB=90=9C=20api=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/wr/app/(map-layout)/layout.tsx | 15 ++++++++++++++- apps/wr/components/lib/api/index.ts | 17 +++++++++++++---- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/apps/wr/app/(map-layout)/layout.tsx b/apps/wr/app/(map-layout)/layout.tsx index d11fafb72..a44714aa2 100644 --- a/apps/wr/app/(map-layout)/layout.tsx +++ b/apps/wr/app/(map-layout)/layout.tsx @@ -1,12 +1,25 @@ "use client"; +import type { MenuItem } from "@common/components/api"; import { NoFooterLayout } from "@common/components/ui"; +import { usePathname,useRouter } from "next/navigation"; +import { useWrStore } from "../store"; export default function RootLayout({ children, }: Readonly<{ children: React.ReactNode; }>) { + const { getMenuAuthrts } = useWrStore((state) => state); + const router = useRouter(); + const pathname = usePathname(); + + const changeMenu = (path: MenuItem) => { + getMenuAuthrts(path.menuCd); + router.push(path.urlPath); + }; return ( - {children} + + {children} + ); } diff --git a/apps/wr/components/lib/api/index.ts b/apps/wr/components/lib/api/index.ts index fd1287793..6b1f4292c 100644 --- a/apps/wr/components/lib/api/index.ts +++ b/apps/wr/components/lib/api/index.ts @@ -41,7 +41,10 @@ export const getFetch = async (type: string, url: string) => { // JSON 응답 처리 const res = await response.json(); return res.data; - } else { + } else if(contentType.includes('application/octet-stream')) { + // 파일 응답 처리 (ex. PDF, Excel 등) + + console.log('contentType ' ,contentType) // 파일 응답 처리 (ex. PDF, Excel 등) const blob = await response.blob(); const blobUrl = window.URL.createObjectURL(blob); @@ -54,7 +57,9 @@ export const getFetch = async (type: string, url: string) => { window.URL.revokeObjectURL(blobUrl); return null; // 다운로드이므로 반환값 없음 - } + }else{ + throw Error('오류 발생') + } }; export const getFetchWithCount = async (type: string, url: string) => { @@ -89,8 +94,10 @@ export const getFetchWithCount = async (type: string, url: string) => { const res = await response.json(); return res; - } else { + } else if(contentType.includes('application/octet-stream')) { // 파일 응답 처리 (ex. PDF, Excel 등) + + console.log('contentType ' ,contentType) const blob = await response.blob(); const blobUrl = window.URL.createObjectURL(blob); const a = document.createElement("a"); @@ -102,7 +109,9 @@ export const getFetchWithCount = async (type: string, url: string) => { window.URL.revokeObjectURL(blobUrl); return null; // 다운로드이므로 반환값 없음 - } + }else{ + throw Error('오류 발생') + } }; export const postFectch = async (url: string, params: any, type?: string) => {