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";
|
|
|
|
|
|
|
|
|
|
const router = createRouter({
|
|
|
|
|
history: createWebHashHistory(),
|
|
|
|
|
routes,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
router.beforeEach((to, from, next) => {
|
|
|
|
|
const {isLogin} = useUserStore();
|
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;
|