1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- import {
- createRouter,
- createWebHistory,
- createWebHashHistory,
- } from "vue-router";
- const constantRouterMap = [
- {
- path: "/login",
- name: "Login",
- component: () => import("@/views/login/LoginView.vue"),
- meta: {
- title: "登录",
- },
- },
- {
- path: "/",
- name: "theBaseLayout",
- component: () => import("@/components/Layout/ThePublicLayout.vue"),
- children: [
- {
- path: "/",
- name: "AnalyseView",
- component: () => import("@/views/xlht/AnalyseView.vue"),
- meta: {
- title: "智能国标化验室数据",
- },
- },
- {
- path: "medicinal",
- name: "MedicinalView",
- component: () => import("@/views/control/MedicinalView.vue"),
- meta: {
- title: "智适应碳源投加",
- },
- },
- ],
- },
- {
- path: '/',
- name: 'userLayout',
- component: () => import('@/components/Layout/ThePublicLayout.vue'),
- children: [
- {
- path: 'user',
- name: 'User',
- component: () => import('@/views/user/index.vue'),
- meta: {
- title: '系统设置'
- }
- },
- ]
- },
- ];
- const router = createRouter({
- history: createWebHashHistory(import.meta.env.BASE_URL),
- routes: constantRouterMap,
- scrollBehavior: () => ({ left: 0, top: 0 }),
- });
- router.beforeEach((to, from, next) => {
- if ( localStorage.getItem('isLogin') ) {
- next();
- } else {
- if (to.path === '/login') {
- next();
- } else {
- next('/login');
- }
- }
- });
- export default router;
|