Commit ba685b20 by 冒粤蓉

fix

1 parent ea7b7598
......@@ -35,8 +35,38 @@ export default {
isQiankun: window.__POWERED_BY_QIANKUN__,
}
},
watch: {
$route(to, from) {
if(this.isQiankun) {
this.getBreadcrumb();
}
}
},
methods: {
...mapMutations(['updateBaseURL']),
getBreadcrumb() {
let matched = this.$route.matched.filter(item => item.name); // this.$route.matched 可以获取到一个数组,包含当前路由的所有嵌套路径片段的路由记录
const first = matched[0];
const { meta, path } = first;
const basePath = '/system#';
let breadcrumb = [];
if(meta) {
const { title, parentTitle, parentPath } = meta;
if(parentTitle) {
breadcrumb.push({
name: parentTitle,
path: basePath + parentPath
})
}
if(title) {
breadcrumb.push({
name: title,
path: basePath + path
})
}
this.$root.parentVuex.dispatch('menu/setBreadCrumb', breadcrumb);
}
},
goToPage(path) {
this.$root.parentRouter.push(path);
}
......
......@@ -39,27 +39,6 @@ function render({ data = {} , container } = {}) {
},
render: h => h(App),
}).$mount(container ? container.querySelector('#glsx-sub-system') : '#glsx-sub-system');
router.beforeEach((to, from, next)=>{
const metaTitle = to.meta.title;
const thisBreadCrumb = data.store.getters.curBreadCrumb;
if(metaTitle) {
if(thisBreadCrumb) {
let nextChildren = {};
nextChildren = {
active: true,
menuName: metaTitle,
path: '/system#' + to.path,
params: to.params
};
thisBreadCrumb.children.children = nextChildren;
}
} else {
thisBreadCrumb.children.children = '';
}
data.store.dispatch('menu/setBreadCrumb', thisBreadCrumb);
next();
})
}
if (!window.__POWERED_BY_QIANKUN__) {
......
import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
Vue.use(VueRouter)
const routes = [
{
path: '/',
name: 'User',
name: 'user',
meta: { title: '用户管理' },
component: () => import('../views/user/index.vue')
},
{
path: '/user',
name: 'User',
name: 'user',
meta: { title: '用户管理' },
component: () => import('../views/user/index.vue')
},
{
path: '/role',
name: 'Role',
name: 'role',
meta: { title: '角色管理' },
component: () => import('../views/role/index.vue')
},
{
path: '/orginizaManage',
name: 'OrginizaManage',
name: 'orginizaManage',
meta: { title: '组织管理' },
component: () => import('../views/orginizaManage/index.vue')
},
{
path: '/menuManage',
name: 'MenuManage',
name: 'menuManage',
meta: { title: '菜单管理' },
component: () => import('../views/menuManage/index.vue')
},
{
path: '/dictionaryManage',
name: 'DictionaryManage',
name: 'dictionaryManage',
meta: { title: '字典管理' },
component: () => import('../views/dictionaryManage/index.vue')
},
{
path: '/dictionaryManage/dictionaryData',
name: 'dictionaryData',
meta: { title: '字典数据' },
meta: {
title: '字典数据',
parentTitle: '字典管理',
parentPath: '/dictionaryManage',
},
component: () => import('../views/dictionaryManage/dictionaryData/index.vue')
},
{
path: '/workLog',
name: 'workLog',
meta: { title: '操作日志' },
component: () => import('../views/workLog/index.vue')
}
]
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!