food/src/components/Breadcrumb.vue
tk c5f2a27789 【类 型】:fix
【主	题】:取消面包屑的链接 显示‘飞机主控’ 和 ‘小程序后台’
【描	述】:
	[原因]:
	[过程]:
	[影响]:
【结	束】

# 类型 包含:
# feat:新功能(feature)
# fix:修补bug
# docs:文档(documentation)
# style: 格式(不影响代码运行的变动)
# refactor:重构(即不是新增功能,也不是修改bug的代码变动)
# test:增加测试
# chore:构建过程或辅助工具的变动
2024-06-17 13:53:12 +08:00

78 lines
1.8 KiB
Vue

<template>
<el-breadcrumb separator-class="el-icon-caret-right" class="app-breadcrumb">
<el-breadcrumb-item>
<!-- <router-link to="/">飞机主控</router-link> -->
{{ $route.meta.tapName === "plane" ? "飞机主控" : "小程序后台" }}
</el-breadcrumb-item>
<el-breadcrumb-item v-for="(item, index) in breadcrumb" :key="index">
<!-- <router-link :to="item.path">{{ item.title }}</router-link> -->
{{ item.title }}
</el-breadcrumb-item>
</el-breadcrumb>
</template>
<script>
export default {
name: 'Breadcrumb',
data () {
return {
breadcrumb: []
}
},
mounted () {
this.refreshBreadcrumb()
},
computed: {
/**
* @description: 拿路由列表 并过滤不显示项 和没有权限项
*/
routes () {
return this.$router.options.routes.filter(
item => item.meta.hidden !== true && item.meta.roles.indexOf(this.$store.state.user.power.trim()) >= 0
)
},
/**
* @description: 当前路径
*/
presentPath () {
return this.$route.path
}
},
watch: {
presentPath () {
this.refreshBreadcrumb()
}
},
methods: {
/**
* @description: 刷新面包条数据
*/
refreshBreadcrumb () {
const temp = []
this.routes.forEach(element => {
element.children.forEach(child => {
if (this.presentPath.search(child.path) !== -1) {
temp[0] = { title: element.meta.title, path: element.path }
temp[1] = { title: child.meta.title, path: child.path }
}
})
})
this.breadcrumb = temp
}
}
}
</script>
<style lang="scss" scoped>
@import "@/styles/theme.scss";
.el-breadcrumb * {
font-weight: normal !important;
color: $maintext-color !important;
font-size: 14px;
line-height: 50px;
cursor: text;
}
</style>