| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283 |
- import Vue from 'vue'
- import VueRouter from 'vue-router'
- import { Message } from 'element-ui'
- Vue.use(VueRouter)
- // 2.创建路由对象
- const router = new VueRouter({
- routes: [
- {
- name: 'default',
- path: '/',
- redirect: { name: 'layout' }
- },
- // 4.配置单个路由
- {
- name: 'login',
- path: '/login',
- component: () => import('@/views/login/index.vue')
- },
- {
- name: 'layout',
- path: '/layout',
- component: () => import('@/views/layout/index.vue'),
- redirect: { name: 'home' },
- // 首页添加子路由
- children: [
- {
- name: 'home',
- path: 'home',
- meta: { myInd: 0 },
- component: () => import('@/views/home/index.vue')
- },
- {
- name: 'homeNews',
- path: 'homeNews/:id',
- meta: { myInd: 0 },
- component: () => import('@/views/home/News.vue')
- },
- // 馆藏管理
- {
- name: 'holding0',
- path: 'holding0',
- meta: { myInd: 1 },
- component: () => import('@/views/holding/holding0.vue')
- },
- {
- name: 'holding0_add',
- path: 'holding0_add',
- meta: { myInd: 1 },
- component: () => import('@/views/holding/holding0_add.vue')
- },
- {
- name: 'holding0_audit',
- path: 'holding0_audit',
- meta: { myInd: 1 },
- component: () => import('@/views/holding/holding0_audit.vue')
- },
- {
- name: 'holding0_result',
- path: 'holding0_result',
- meta: { myInd: 1 },
- component: () => import('@/views/holding/holding0_result.vue')
- },
- {
- name: 'holding1',
- path: 'holding1',
- meta: { myInd: 1 },
- component: () => import('@/views/holding/holding1.vue')
- },
- {
- name: 'holding1_look',
- path: 'holding1_look',
- meta: { myInd: 1 },
- component: () => import('@/views/holding/holding1_look.vue')
- },
- {
- name: 'holding1_audit',
- path: 'holding1_audit',
- meta: { myInd: 1 },
- component: () => import('@/views/holding/holding1_audit.vue')
- },
- {
- name: 'holding1_add',
- path: 'holding1_add',
- meta: { myInd: 1 },
- component: () => import('@/views/holding/holding1_add.vue')
- },
- {
- name: 'holding2',
- path: 'holding2',
- meta: { myInd: 1 },
- component: () => import('@/views/holding/holding2.vue')
- },
- {
- name: 'holding2_add',
- path: 'holding2_add',
- meta: { myInd: 1 },
- component: () => import('@/views/holding/holding2_add.vue')
- },
- {
- name: 'holding2_audit',
- path: 'holding2_audit',
- meta: { myInd: 1 },
- component: () => import('@/views/holding/holding2_audit.vue')
- },
- {
- name: 'holding2_look',
- path: 'holding2_look',
- meta: { myInd: 1 },
- component: () => import('@/views/holding/holding2_look.vue')
- },
- {
- name: 'holding3',
- path: 'holding3',
- meta: { myInd: 1, keepAlive: true },
- component: () => import('@/views/holding/holding3.vue')
- },
- {
- name: 'holding3_look',
- path: 'holding3_look',
- meta: { myInd: 1 },
- component: () => import('@/views/holding/holding3_look.vue')
- },
- {
- name: 'holding4',
- path: 'holding4',
- meta: { myInd: 1 },
- component: () => import('@/views/holding/holding4.vue')
- },
- {
- name: 'holding4_audit',
- path: 'holding4_audit',
- meta: { myInd: 1 },
- component: () => import('@/views/holding/holding4_audit.vue')
- },
- {
- name: 'holding4_look',
- path: 'holding4_look',
- meta: { myInd: 1 },
- component: () => import('@/views/holding/holding4_look.vue')
- },
- {
- name: 'holding5',
- path: 'holding5',
- meta: { myInd: 1 },
- component: () => import('@/views/holding/holding5.vue')
- },
- {
- name: 'holding5_add',
- path: 'holding5_add',
- meta: { myInd: 1 },
- component: () => import('@/views/holding/holding5_add.vue')
- },
- {
- name: 'holding5_audit',
- path: 'holding5_audit',
- meta: { myInd: 1 },
- component: () => import('@/views/holding/holding5_audit.vue')
- },
- {
- name: 'holding5_look',
- path: 'holding5_look',
- meta: { myInd: 1 },
- component: () => import('@/views/holding/holding5_look.vue')
- },
- {
- name: 'holding0_DiaEdit',
- path: 'holding0_DiaEdit',
- meta: { myInd: 1 },
- component: () => import('@/views/holding/holding0_DiaEdit.vue')
- },
- // 征集品管理
- {
- name: 'collect0',
- path: 'collect0',
- meta: { myInd: 2, keepAlive: true },
- component: () => import('@/views/collect/collect0.vue')
- },
- {
- name: 'collect0_look',
- path: 'collect0_look',
- meta: { myInd: 2 },
- component: () => import('@/views/collect/collect0_look.vue')
- },
- {
- name: 'collect1',
- path: 'collect1',
- meta: { myInd: 2 },
- component: () => import('@/views/collect/collect1.vue')
- },
- {
- name: 'collect1_add',
- path: 'collect1_add',
- meta: { myInd: 2 },
- component: () => import('@/views/collect/collect1_add.vue')
- },
- {
- name: 'collect1_audit',
- path: 'collect1_audit',
- meta: { myInd: 2 },
- component: () => import('@/views/collect/collect1_audit.vue')
- },
- {
- name: 'collect1_look',
- path: 'collect1_look',
- meta: { myInd: 2 },
- component: () => import('@/views/collect/collect1_look.vue')
- },
- {
- name: 'collect2',
- path: 'collect2',
- meta: { myInd: 2 },
- component: () => import('@/views/collect/collect2.vue')
- },
- {
- name: 'collect2_add',
- path: 'collect2_add',
- meta: { myInd: 2 },
- component: () => import('@/views/collect/collect2_add.vue')
- },
- {
- name: 'collect2_audit',
- path: 'collect2_audit',
- meta: { myInd: 2 },
- component: () => import('@/views/collect/collect2_audit.vue')
- },
- {
- name: 'collect2_look',
- path: 'collect2_look',
- meta: { myInd: 2 },
- component: () => import('@/views/collect/collect2_look.vue')
- },
- // 库房管理
- {
- name: 'statistics0',
- path: 'statistics0',
- meta: { myInd: 3 },
- component: () => import('@/views/statistics/statistics0.vue')
- },
- {
- name: 'statistics1',
- path: 'statistics1',
- meta: { myInd: 3 },
- component: () => import('@/views/statistics/statistics1.vue')
- },
- // 系统管理
- {
- name: 'system1',
- path: 'system1',
- meta: { myInd: 4 },
- component: () => import('@/views/system/system1.vue')
- },
- {
- name: 'system2',
- path: 'system2',
- meta: { myInd: 4 },
- component: () => import('@/views/system/system2.vue')
- }
- ]
- }
- ]
- })
- router.beforeEach((to, from, next) => {
- // 如果是去登录页,不需要验证,直接下一步
- if (to.name === 'login') next()
- // 否则要有token值才能下一步,不然就返回登录页
- else {
- const token = localStorage.getItem('daliCK_token')
- if (token) next()
- else {
- Message.warning('登录失效,请重新登录')
- next({ name: 'login' })
- }
- }
- })
- export default router
|