Files
xl-root/src/router/index.js
2025-03-10 19:01:21 +08:00

23 lines
575 B
JavaScript

import {createRouter, createWebHashHistory} from 'vue-router';
import routes from "./routes.js";
import {useUserStore} from "../pinia/UserStore/index.js";
import {useSystemStore} from "../pinia/SystemStore/index.js";
const router = createRouter({
history: createWebHashHistory(),
routes,
})
router.beforeEach((to, from, next) => {
const {isLogin} = useUserStore();
const SystemStore = useSystemStore();
if (!isLogin && !to.path.includes('loginSYS')) {
next({ path: '/loginSYS' });
} else {
next();
}
});
export default router;