페이지 선택 오류 및 잘못된 api 설정
This commit is contained in:
@@ -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 (
|
||||
<NoFooterLayout>{children}</NoFooterLayout>
|
||||
<NoFooterLayout currentPath={pathname ?? ""} handleMenuClick={changeMenu}>
|
||||
{children}
|
||||
</NoFooterLayout>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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,6 +57,8 @@ export const getFetch = async (type: string, url: string) => {
|
||||
window.URL.revokeObjectURL(blobUrl);
|
||||
|
||||
return null; // 다운로드이므로 반환값 없음
|
||||
}else{
|
||||
throw Error('오류 발생')
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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,6 +109,8 @@ export const getFetchWithCount = async (type: string, url: string) => {
|
||||
window.URL.revokeObjectURL(blobUrl);
|
||||
|
||||
return null; // 다운로드이므로 반환값 없음
|
||||
}else{
|
||||
throw Error('오류 발생')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user