This commit is contained in:
2025-02-27 14:38:47 +08:00
parent 05cf93033f
commit 3118d0c397
18 changed files with 2955 additions and 113 deletions

19
src/router/index.js Normal file
View File

@@ -0,0 +1,19 @@
import {createRouter, createWebHashHistory} from 'vue-router';
import routes from "./routes.js";
import {useUserStore} from "../pinia/UserStore/index.js";
const router = createRouter({
history: createWebHashHistory(),
routes,
})
router.beforeEach((to, from, next) => {
const {isLogin} = useUserStore();
if (to.name !== 'login' && !isLogin) {
next({name: 'login'});
} else {
next();
}
});
export default router;

18
src/router/routes.js Normal file
View File

@@ -0,0 +1,18 @@
const routes = [
{
path: '/',
redirect: '/home',
},
{
path: '/home',
name: 'home',
component: () => import('../pages/layout/index.vue'),
},
{
path: '/login',
name: 'login',
component: () => import('../pages/login/index.vue'),
},
]
export default routes;