Commit 841dd0d2 authored by jiaxu.yan's avatar jiaxu.yan

Merge branch 'develop' of http://gitlab.91isoft.com:90/car-test/web into develop

parents bb2cab8e 8d869221
......@@ -36,19 +36,34 @@ export default {
},
methods: {
getBreadcrumb() {
// only show routes with meta.title
// // only show routes with meta.title
let matched = this.$route.matched.filter(
item => item.meta && item.meta.title
)
const first = matched[0]
if (!this.isDashboard(first)) {
matched = [{ path: '/index', meta: { title: '首页' } }].concat(matched)
}
this.levelList = matched.filter(
item => item.meta && item.meta.title && item.meta.breadcrumb !== false
)
const temp = matched.filter(item => item.meta && item.meta.title && item.meta.breadcrumb !== false)
// 为三级面包屑提供逻辑 从$route parentName取值
if (this.$route.meta.secondaryMenuName) {
temp.splice(-1, 0, { redirect: 'noRedirect', meta: { title: this.$route.meta.secondaryMenuName }, path: 'secondaryMenuName' })
}
this.levelList = this.removeDuplicateTitles(temp)
},
// 去除同名title的面包屑
removeDuplicateTitles(arr) {
const titles = new Set() // 用于存储已经遇到的title值
const result = [] // 存储最终的结果数组
for (let i = 0; i < arr.length; i++) {
const title = arr[i].meta.title
console.log('面包屑', title)
if (!titles.has(title)) {
titles.add(title)
result.push(arr[i])
}
}
return result
},
isDashboard(route) {
const name = route && route.name
......
......@@ -37,14 +37,22 @@ const permission = {
const sdata = JSON.parse(JSON.stringify(res.data))
const rdata = JSON.parse(JSON.stringify(res.data))
const sidebarRoutes = filterAsyncRouter(sdata)
sidebarRoutes.forEach(item => {
if (item.children && item.children.length > 0){
item.children.forEach(c => {
c.meta['activeMenu'] = `${item.path === '/' ? '' : item.path}/${item.children[0].path}`
})
}
})
const rewriteRoutes = filterAsyncRouter(rdata, false, true)
console.log('rewriteRoutes', rewriteRoutes)
rewriteRoutes.forEach(item => {
if (item.children && item.children.length > 0){
for (let i = 0; i < item.children.length; i++) {
// 将parentName字段放入meta中
if (item.children[i].secondaryMenuName) {
item.children[i].meta['secondaryMenuName'] = item.children[i].secondaryMenuName
// item.children[i - 1].meta['activeMenu'] = `${item.path === '/' ? '' : item.path}/${item.children[i].path}`
item.children[i].meta['activeMenu'] = `${item.path === '/' ? '' : item.path}/${item.children[i + 1].path}`
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment