오류페이지 noLayout 설정 추가

This commit is contained in:
nevermoregb 2025-03-15 00:56:52 +09:00
parent 34bef477f9
commit 985351c8f0

View File

@ -1,4 +1,4 @@
import { createRouter, createWebHistory } from 'vue-router'
import { createRouter, createWebHistory } from 'vue-router';
import { useAuthStore } from '@s/useAuthStore';
import { useUserInfoStore } from '@s/useUserInfoStore';
@ -6,7 +6,7 @@ import { useUserInfoStore } from '@s/useUserInfoStore';
const routes = [
{
path: '/',
name: "Home",
name: 'Home',
component: () => import('@v/MainView.vue'),
// meta: { requiresAuth: true }
},
@ -17,23 +17,23 @@ const routes = [
{
path: '',
name: 'BoardList',
component: () => import('@v/board/BoardList.vue')
component: () => import('@v/board/BoardList.vue'),
},
{
path: 'write',
component: () => import('@v/board/BoardWrite.vue')
component: () => import('@v/board/BoardWrite.vue'),
},
{
path: ':id',
name: 'BoardDetail',
component: () => import('@v/board/BoardView.vue')
component: () => import('@v/board/BoardView.vue'),
},
{
path: 'edit/:id',
name: 'BoardEdit',
component: () => import('@v/board/BoardEdit.vue')
}
]
component: () => import('@v/board/BoardEdit.vue'),
},
],
},
{
path: '/wordDict',
@ -67,14 +67,13 @@ const routes = [
children: [
{
path: '',
component: () => import('@v/voteboard/voteBoardList.vue')
component: () => import('@v/voteboard/voteBoardList.vue'),
},
{
path: 'write',
component: () => import('@v/voteboard/voteboardWrite.vue')
component: () => import('@v/voteboard/voteboardWrite.vue'),
},
]
],
},
{
path: '/projectlist',
@ -87,25 +86,37 @@ const routes = [
{
path: '/authorization',
component: () => import('@v/admin/TheAuthorization.vue'),
meta: { requiresAuth: true }
meta: { requiresAuth: true },
},
{ path: "/error/400", name: "Error400", component: () => import('@v/error/Error400.vue') },
{ path: "/error/500", name: "Error500", component: () => import('@v/error/Error500.vue') },
{
path: "/:anything(.*)",
name: "Error404", component: () => import('@v/error/Error404.vue')
path: '/error/400',
name: 'Error400',
component: () => import('@v/error/Error400.vue'),
meta: { layout: 'NoLayout' },
},
{
path: '/error/500',
name: 'Error500',
component: () => import('@v/error/Error500.vue'),
meta: { layout: 'NoLayout' },
},
{
path: '/:anything(.*)',
name: 'Error404',
component: () => import('@v/error/Error404.vue'),
meta: { layout: 'NoLayout' },
},
];
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: routes,
})
});
router.beforeEach(async (to, from, next) => {
const authStore = useAuthStore();
await authStore.checkAuthStatus(); // 로그인 상태 확인
const allowedUserId = 26; // 특정 ID (변경필요!!)
const allowedUserId = 26; // 특정 ID (변경필요!!)
const userStore = useUserInfoStore();
const userId = userStore.user?.id ?? null;
@ -115,8 +126,8 @@ router.beforeEach(async (to, from, next) => {
}
// Authorization 페이지는 ID가 26이 아니면 접근 차단
if (to.path === "/authorization" && userId !== allowedUserId) {
return next("/");
if (to.path === '/authorization' && userId !== allowedUserId) {
return next('/');
}
// 비로그인 사용자만 접근 가능한 페이지인데 로그인된 경우 → 홈으로 이동
@ -142,7 +153,7 @@ axios.interceptors.response.use(
}
return Promise.reject(error);
}
},
);
export default router
export default router;