Files
xl-root/src/router/index.js
2025-05-27 19:15:55 +08:00

25 lines
676 B
JavaScript

import {createMemoryHistory, createRouter} 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: createMemoryHistory(),
routes,
})
router.beforeEach((to, from, next) => {
const {isLogin} = useUserStore();
const SystemStore = useSystemStore();
if (!isLogin && !to.path.includes('loginSYS')) {
next({path: '/loginSYS'});
} else {
SystemStore.NOW_ROUTER = to.path;
Object.assign(SystemStore.NOW_ROUTER_QUERY, to.query);
next();
}
});
export default router;