修改分模块

This commit is contained in:
2021-12-22 16:13:55 +08:00
parent bb6925f3a2
commit 14bf2bd17e
8 changed files with 81 additions and 173 deletions

View File

@@ -2,7 +2,6 @@ import Vue from 'vue'
import Router from 'vue-router'
import i18n from '@/lang/i18n'
import Cookies from 'js-cookie'
import store from '@/store'
const routerTitle = i18n.routerTitle
const language = Cookies.get('language')
@@ -60,11 +59,24 @@ export const constantRoutes = [
},
{
path: '/',
component: () => import('@/views/ChoicePart'),
hidden: true,
meta: { requireToken: true }
component: Layout,
redirect: '/dashboard',
children: [
{
path: 'dashboard',
component: () => import('@/views/dashboard/index'),
name: 'Dashboard',
meta: { title: routerTitle.dashboard?.[language] || routerTitle.dashboard.en, icon: 'form', iconPart: 'dashboard', affix: true, required: true, requireToken: true }
}
]
},
// {
// path: '/',
// component: () => import('@/views/ChoicePart'),
// hidden: true,
// meta: { requireToken: true }
// },
// {
// path: '/auth-redirect',
// component: () => import('@/views/login/auth-redirect'),
// hidden: true
@@ -78,28 +90,7 @@ export const constantRoutes = [
path: '/401',
component: () => import('@/views/error-page/401'),
hidden: true
}
// 工单管理、厂务管理、包装管理、接口管理、数据采集、报表、质量管理、SPC
/** when your routing map is too long, you can split it into small modules **/
// 404 page must be placed at the end !!!
// { path: '*', redirect: '/404', hidden: true }
]
export const dynamicRoutes = [
// {
// path: '/dashboard',
// component: Layout,
// redirect: '/dashboard',
// name: 'dashboard',
// children: [
// {
// path: 'dashboard',
// component: () => import('@/views/dashboard/index'),
// name: 'Dashboard',
// meta: { title: routerTitle.dashboard.dashboard?.[language] || routerTitle.dashboard.dashboard.en, icon: 'dashboard', affix: true }
// }
// ]
// },
},
{
path: '/basicData',
component: Layout,
@@ -511,7 +502,7 @@ export const dynamicRoutes = [
path: 'recipe',
component: () => import('@/views/EquipmentManager/RecipeManager'),
name: 'RecipeManage',
meta: { title: routerTitle.equipment.recipe?.[language] || routerTitle.equipment.recipe?.en, icon: 'form', affix: true }
meta: { title: routerTitle.equipment.recipe?.[language] || routerTitle.equipment.recipe.en, icon: 'form', affix: true }
}, {
path: 'sparepart',
component: () => import('@/views/EquipmentManager/sqarepart'),
@@ -529,7 +520,7 @@ export const dynamicRoutes = [
component: () => import('@/views/EquipmentManager/RecipeManager/subpage/detail'),
name: 'RecipeParamManage',
hidden: true,
meta: { title: routerTitle.equipment.recipeform?.[language] || routerTitle.equipment.recipeform?.en, icon: 'form', affix: true }
meta: { title: routerTitle.equipment.recipeform?.[language] || routerTitle.equipment.recipeform.en, icon: 'form', affix: true }
}, {
path: 'statussetting',
component: () => import('@/views/EquipmentManager/StatusSetting'),
@@ -1187,18 +1178,18 @@ export const dynamicRoutes = [
path: 'plan',
component: () => import('@/views/QualityManager/plan'),
name: 'PlanManage',
meta: { title: routerTitle.quality.plan?.[language] || routerTitle.quality.plan?.en, icon: 'form', affix: true }
meta: { title: routerTitle.quality.plan?.[language] || routerTitle.quality.plan.en, icon: 'form', affix: true }
}, {
path: 'planparam',
component: () => import('@/views/QualityManager/plan/subpage/detail'),
name: 'PlanParamManage',
hidden: true,
meta: { title: routerTitle.quality.planform?.[language] || routerTitle.quality.planform?.en, icon: 'form', affix: true }
meta: { title: routerTitle.quality.planform?.[language] || routerTitle.quality.planform.en, icon: 'form', affix: true }
}, {
path: 'issue',
component: () => import('@/views/QualityManager/plan/issuedplan'),
name: 'PlanIssuedManage',
meta: { title: routerTitle.quality.issuedplan?.[language] || routerTitle.quality.issuedplan?.en, icon: 'form', affix: true }
meta: { title: routerTitle.quality.issuedplan?.[language] || routerTitle.quality.issuedplan.en, icon: 'form', affix: true }
},
{
path: '/offlineDetec',
@@ -1296,49 +1287,23 @@ export const dynamicRoutes = [
},
{ path: '*', redirect: '/404', hidden: true }
]
export const asyncRoutes = [
// 404 page must be placed at the end !!!
{ path: '*', redirect: '/404', hidden: true }
]
const createRouter = (r) =>
const createRouter = () =>
new Router({
// mode: 'history', // require service support
scrollBehavior: () => ({ y: 0 }),
routes: r
routes: constantRoutes
})
const router = createRouter(constantRoutes)
router.beforeEach((to, from, next) => {
console.log('route.index', to, to.meta.routeIndex)
if (to.meta.routeIndex >= 0) {
store.dispatch('app/setChoicepart', to.meta.routeIndex)
}
// 拦截器
console.log('route,to.path:', to.path)
if (to.meta.requireToken) {
if (Cookies.get('Admin-Token')) {
if (to.meta.required) {
if (Cookies.get('choicepart') === 'undefined' || !Cookies.get('choicepart')) {
next({
path: '/'
})
} else {
next()
}
} else {
next()
}
} else {
next({
path: '/login'
})
}
} else {
next()
}
})
const router = createRouter()
// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
const newRouter = createRouter(constantRoutes)
const newRouter = createRouter()
router.matcher = newRouter.matcher // reset router
}