feat:路由文件添加页面信息

This commit is contained in:
wuzhihao
2024-08-30 14:56:16 +08:00
2 changed files with 90 additions and 13 deletions

View File

@@ -7,6 +7,7 @@ import local from '../utils/local'
Vue.use(VueRouter)
const routes = [
<<<<<<< HEAD
{
path: '/login',
component: Login,
@@ -96,25 +97,89 @@ const routes = [
},
]
},
=======
{
path: '/login',
component: Login,
meta: { title: '登录', activeMenu: '/login' }
},
{
path: '/',
component: Layout,
redirect: '/disease-resistance/disease-resistance',
meta: { title: '', activeMenu: '/disease-resistance/disease-resistance' }
}, {
// 首页
path: '/index',
component: Layout,
children: [
{
path: '/index/index',
component: () =>
import('../views/index/index.vue'),
meta: { title: '首页', activeMenu: '/index/index' }
}
]
},
{
// 遗传病风险
path: '/disease-resistance',
component: Layout,
children: [
{
path: '/disease-resistance/disease-resistance',
component: () =>
import('../views/disease-resistance/disease-resistance.vue'),
meta: { title: '遗传病风险', activeMenu: '/disease-resistance/disease-resistance' }
}
]
},
{
// 档案信息
path: '/archive-information',
component: Layout,
children: [
{
path: '/archive-information/archive-information',
component: () =>
import('../views/archive-information/archive-information.vue'),
meta: { title: '档案信息', activeMenu: '/archive-information/archive-information' }
}
]
},
{
// 快速查询
path: '/quick-Search/quick-Search',
component: Layout,
children: [
{
path: '/quick-Search/quick-Search',
component: () =>
import('../views/quick-Search/quick-Search.vue'),
meta: { title: '快速查询', activeMenu: '/quick-Search/quick-Search' }
}
]
}
>>>>>>> d14b2f2f812d1e29c7e72c864828024a3008a9a6
]
const router = new VueRouter({
routes
routes
})
// 前置路由守卫
router.beforeEach((to, from, next) => {
// to到哪里取 from 从哪里来 next 放行
const token = local.get('token_sd')
if (to.meta.title) { // 修改总标题
document.title = '肉牛溯源系统' + '-' + to.meta.title // routes数组中--meta是关键
}
if (token) { // ok
next()
} else { // no
if (to.path === '/login') {
next()
// to到哪里取 from 从哪里来 next 放行
const token = local.get('token_sd')
if (to.meta.title) { // 修改总标题
document.title = '肉牛溯源系统' + '-' + to.meta.title // routes数组中--meta是关键
}
if (token) { // ok
next()
} else { // no
if (to.path === '/login') {
next()
}
next('/login')
}
next('/login')
}
})
export default router

View File

@@ -23,6 +23,10 @@
:default-active="activeIndex"
:unique-opened="true"
>
<el-menu-item index="/index/index">
<i class="el-icon-price-tag"></i>
<span slot="title">首页</span>
</el-menu-item>
<el-menu-item index="/disease-resistance/disease-resistance">
<i class="el-icon-orange"></i>
<span slot="title">遗传病风险</span>
@@ -62,6 +66,14 @@
>
</el-menu-item-group>
</el-submenu>
<el-menu-item index="/archive-information/archive-information">
<i class="el-icon-document"></i>
<span slot="title">档案信息</span>
</el-menu-item>
<el-menu-item index="/quick-Search/quick-Search">
<i class="el-icon-folder-checked"></i>
<span slot="title">快速查询</span>
</el-menu-item>
</el-menu>
</div>
</template>