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