로그인 화면

This commit is contained in:
jieun committed 2026-11-18 16:53:07 +09:00
1 parent 6adcb5b43d
commit f551671394
13 files changed
+152 -30

No files matched your search

+9
View File
@@ -1,5 +1,6 @@
import VueRouter from "vue-router";
import routes from "./routes";
import { isAuthenticated, safeDestination } from '@/auth';
// configure router
const router = new VueRouter({
@@ -14,4 +15,12 @@ const router = new VueRouter({
}
});
router.beforeEach((to, from, next) => {
if (to.matched.some(record => record.meta.requiresAuth) && !isAuthenticated()) {
next({ path: '/login', query: { redirect: to.fullPath }, replace: true });
} else if (to.name === 'login' && isAuthenticated()) {
next({ path: safeDestination(to.query.redirect), replace: true });
} else next();
});
export default router;
+3 -1
View File
@@ -1,6 +1,8 @@
import Dashboard from '@/pages/Dashboard.vue';
import Login from '@/pages/Login.vue';
export default [
{ path: '/', redirect: '/dashboard' },
{ path: '/dashboard', name: 'dashboard', component: Dashboard },
{ path: '/login', name: 'login', component: Login },
{ path: '/dashboard', name: 'dashboard', component: Dashboard, meta: { requiresAuth: true } },
{ path: '*', redirect: '/dashboard' }
];