qx
2025-03-26 155a30a172e4cf04838dcf7c8bb73ce6b200e574
src/router/index.js
@@ -1,6 +1,6 @@
import Vue from 'vue'
import Router from 'vue-router'
import Cookies from "js-cookie";
Vue.use(Router)
/* Layout */
@@ -38,7 +38,7 @@
    children: [
      {
        path: '/redirect/:path(.*)',
        component: () => import('@/views/redirect')
        component: () => import('@/views/redirect'),
      },
      {
        path: '/emer',
@@ -203,7 +203,8 @@
        path: 'index',
        component: () => import('@/views/index'),
        name: 'Index',
        meta: { title: '首页', icon: 'dashboard', affix: true }
        meta: { title: '首页', icon: 'dashboard', affix: true ,}
        // routerType:"xamjyy",
      }
    ]
  },
@@ -404,8 +405,26 @@
  return routerPush.call(this, location).catch(err => err)
}
export default new Router({
const router = new Router({
  mode: 'history', // 去掉url中的#
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})
router.beforeEach((to, from, next) => {
  if (from.path === '/login') {
    // 获取当前环境
    const env = process.env.VUE_APP_ENV
    // 生产环境处理
    if (env === 'production') {
      // 防止用户通过地址栏直接输入URL访问
      if (from.name === null && to.path !== window.location.pathname) {
        next(false)
        return
      }
    }
  }
  next()
})
export default router