Files
xl-root/src/router/index.js

23 lines
575 B
JavaScript
Raw Normal View History

2025-02-27 14:38:47 +08:00
import {createRouter, createWebHashHistory} from 'vue-router';
import routes from "./routes.js";
import {useUserStore} from "../pinia/UserStore/index.js";
2025-03-10 19:01:21 +08:00
import {useSystemStore} from "../pinia/SystemStore/index.js";
2025-02-27 14:38:47 +08:00
const router = createRouter({
history: createWebHashHistory(),
routes,
})
router.beforeEach((to, from, next) => {
const {isLogin} = useUserStore();
2025-03-10 19:01:21 +08:00
const SystemStore = useSystemStore();
2025-02-28 09:56:01 +08:00
if (!isLogin && !to.path.includes('loginSYS')) {
next({ path: '/loginSYS' });
2025-02-27 14:38:47 +08:00
} else {
next();
}
});
export default router;