From 7e460156de73171f9660ce48f80703e79f8b478d Mon Sep 17 00:00:00 2001 From: Crunchy <3114200645@qq.com> Date: 星期六, 14 六月 2025 11:48:26 +0800 Subject: [PATCH] 初始化提交 --- src/router/index.js | 82 ++++++++++++++++++++++++++++++----------- 1 files changed, 60 insertions(+), 22 deletions(-) diff --git a/src/router/index.js b/src/router/index.js index 7219335..9bbbb95 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,6 +1,6 @@ import Vue from 'vue' import Router from 'vue-router' - +import store from '@/store/index' Vue.use(Router) /* Layout */ @@ -33,6 +33,7 @@ export const constantRoutes = [ { path: '/login', + name: 'login', component: () => import('@/views/login/index'), hidden: true }, @@ -49,27 +50,27 @@ redirect: '/home', children: [{ path: 'home', - name: 'Home', + name: '涓婚〉', component: () => import('@/views/home/index'), - meta: { title: '棣栭〉', icon: 'el-icon-house' } + meta: { title: '棣栭〉', icon: 'icon-shouye' } }] }, - { path: '/add_operation', component: Layout, redirect: '/add_operation/table', - meta: { title: '鍏ュ簱鎿嶄綔', icon: 'el-icon-edit-outline' }, + meta: { title: '鍏ュ簱鎿嶄綔', icon: 'icon-warehouse' }, children: [ { path: 'table', + name: '鍏ュ簱鎿嶄綔', component: () => import('@/views/add_operation/index'), - meta: { title: '鍏ュ簱鎿嶄綔', icon: 'el-icon-edit-outline' } + meta: { title: '鍏ュ簱鎿嶄綔', icon: 'icon-warehouse' } } // ,{ // path: 'barcode', // component: () => import('@/views/add_operation/barcode'), - // meta: { title: '鏉$爜鎵撳嵃', icon: 'el-icon-edit-outline' } + // meta: { title: '鏉$爜鎵撳嵃', icon: 'icon-warehouse' } // } ] }, @@ -77,39 +78,39 @@ path: '/out_operation', component: Layout, redirect: '/out_operation/table', - meta: { title: '鍑哄簱鎿嶄綔', icon: 'el-icon-box' }, + meta: { title: '鍑哄簱鎿嶄綔', icon: 'icon-warehouseOut' }, children: [ { path: 'table', - name: 'OutOperation', + name: '鍑哄簱鎿嶄綔', component: () => import('@/views/out_operation/index'), - meta: { title: '鍑哄簱鎿嶄綔', icon: 'el-icon-box' } + meta: { title: '鍑哄簱鎿嶄綔', icon: 'icon-warehouseOut' } } // ,{ // path: 'manual', // name: 'manual', // component: () => import('@/views/out_operation/manual'), // meta: { title: '鎵嬪姩鍑哄簱', icon: 'el-icon-box' } - // }, - // { - // path: 'outboundLedger', - // name: 'outboundLedger', - // component: () => import('@/views/out_operation/outboundLedger'), - // meta: { title: '鍑哄簱鍙拌处', icon: 'el-icon-box' } // } ] }, - { path: '/outbound', component: Layout, redirect: '/outbound/book', - meta: { title: '搴撳瓨绠$悊', icon: 'el-icon-box' }, + meta: { title: '搴撳瓨绠$悊', icon: 'icon-biaogeziduan' }, children: [ { path: 'book', + name: '鏀跺彂瀛樼鐞�', component: () => import('@/views/outbound/index.vue'), - meta: { title: '搴撳瓨绠$悊', icon: 'el-icon-box' } + meta: { title: '鏀跺彂瀛樼鐞�', icon: 'icon-kucunguanli' } + }, + { + path: 'outboundLedger', + name: '鍑哄簱鍙拌处', + component: () => import('@/views/outbound/outboundLedger'), + meta: { title: '鍑哄簱鍙拌处', icon: 'icon-taizhangzhangbuxinxichaxun' } } // ,{ // path: 'depositoryManagement', @@ -122,7 +123,7 @@ path: '/system', component: Layout, redirect: '/system/user', - meta: { title: '绯荤粺璁剧疆', icon: 'el-icon-box' }, + meta: { title: '绯荤粺璁剧疆', icon: 'icon-yonghuguanli' }, children: [ // { // path: 'index', @@ -131,8 +132,9 @@ // }, { path: 'user', + name: '绯荤粺璁剧疆', component: () => import('@/views/system/user'), - meta: { title: '鐢ㄦ埛绠$悊', icon: 'el-icon-box' } + meta: { title: '鐢ㄦ埛绠$悊', icon: 'icon-yonghuguanli' } } // ,{ // path: 'dict', @@ -146,7 +148,7 @@ ] const createRouter = () => new Router({ - // mode: 'history', // require service support + mode: 'history', // require service support scrollBehavior: () => ({ y: 0 }), routes: constantRoutes }) @@ -159,4 +161,40 @@ router.matcher = newRouter.matcher // reset router } +const getState = ()=> import("@/store/index") + +router.beforeEach(async (to, from, next) => { + // console.log(to,from) + let state = (await getState()).default.state + // console.log(state) + // console.log(to) + if (to.name === 'login') { + next() + return + } + // console.log("璺宠浆璺敱鍓嶇殑鍒ゆ柇") + let flag = false; + let {openTab} = state.openTab + // console.log(openTab) + for (let item of openTab) { + // console.log(item) + // console.log("item.name" , item.name) + // console.log("t0.name",to.name) + + if(item.name === to.name) { + // console.log('to.path',to.path); + store.commit('SET_ACTIVE_INDEX',to.path) + flag = true; + break; + } + } + if(!flag) { + // console.log("鎵ц涓�閬�") + // console.log('to.path',to.path); + store.commit('ADD_TAB', {route: to.path, name: to.name}); + store.commit('SET_ACTIVE_INDEX', to.path); + } + next() + +}) export default router -- Gitblit v1.9.3