Commit 84a62671 by 冒粤蓉

fix portal

1 parent 7c1910f2
......@@ -9,11 +9,13 @@
:key="item.origin.menuNo"
@click="titleClick(item, $event)" >
<div class="ant-menu-submenu-title" style="padding-left: 24px;">
<img v-if="item.origin.icon" :src="item.origin.icon" />
<UserOutlined v-else />
<DesktopOutlined v-if="item.origin.icon === 'DesktopOutlined'" />
<CarOutlined v-if="item.origin.icon === 'CarOutlined'" />
<SettingOutlined v-if="!item.origin.icon" />
<span>{{item.origin.menuName}}</span>
<i class="ant-menu-submenu-arrow"></i>
</div>
<!-- ant-menu-item-selected ant-menu-item-active -->
<!-- ant-motion-collapse-legacy ant-motion-collapse-legacy-active -->
<ul class="ant-menu-sub ant-menu ant-menu-inline"
......@@ -35,6 +37,9 @@
<script>
import {
CarOutlined,
DesktopOutlined,
SettingOutlined,
UserOutlined,
TeamOutlined,
FileOutlined,
......@@ -48,9 +53,9 @@ import { menuTree as menuTreeLocalList } from 'config/menuTree';
export default {
name: 'Menu',
components: {
UserOutlined,
TeamOutlined,
FileOutlined,
CarOutlined,
DesktopOutlined,
SettingOutlined,
},
setup(props, context) {
const { ctx } = getCurrentInstance();
......@@ -74,6 +79,7 @@ export default {
// 点击二级菜单标题
const cItemClick = (path, cItem, parentItem) => {
const cOrigin = cItem.origin;
let showEmpty = false;
// 激活active类
state.menuList.forEach(ele => {
const children = ele.children;
......@@ -86,11 +92,17 @@ export default {
state.curBreadCrumb.parent['menuName'] = parentItem.origin.menuName;
state.curBreadCrumb.children = [{
menuName: cOrigin.menuName,
path: cOrigin.path || '',
path: cOrigin.path || '/404',
active: true
}];
localStorage.setItem('breadCrumb', JSON.stringify(state.curBreadCrumb));
path = path ? path : '/404';
if(path === '/404') {
showEmpty = true;
}
store.dispatch('app/setCommonData', { showEmpty });
history.pushState(null, path, path);
}
......@@ -149,22 +161,35 @@ export default {
const getNewTree = getMenuTree(res.data, menuTreeLocalList),
firstParent = getNewTree[0].origin,
firstChildren = getNewTree[0].children[0].origin;
getNewTree.forEach((item, index) => {
item.showSubList = index == 0 ? true: false;
item.children.forEach((cItem, cIndex) => {
cItem.subItemActive = cIndex == 0 && index == 0 ? true: false;
})
});
let showEmpty = false;
state.menuList = getNewTree;
// 同步面包屑
state.curBreadCrumb.parent['menuName'] = firstParent.menuName;
const getBreadCrumb = JSON.parse(localStorage.getItem('breadCrumb'));
const breadChildren = getBreadCrumb ? getBreadCrumb.children[0] : '';
let parentMenuName = getBreadCrumb ? getBreadCrumb.parent.menuName : firstParent.menuName,
childrenMenuName = breadChildren.menuName || firstChildren.menuName,
childrenPath = breadChildren.path || firstChildren.menuName || '';
state.curBreadCrumb.parent['menuName'] = parentMenuName;
state.curBreadCrumb.children.push({
menuName: firstChildren.menuName,
path: firstChildren.path || '',
menuName: childrenMenuName,
path: childrenPath,
active: true
});
getNewTree.forEach((item, index) => {
item.showSubList = item.origin.menuName == parentMenuName ? true: false;
item.children.forEach((cItem, cIndex) => {
cItem.subItemActive = cItem.origin.menuName === childrenMenuName ? true: false;
})
});
if(childrenPath === '/404' || childrenPath === '/') {
showEmpty = true;
}
store.dispatch('app/setCommonData', { showEmpty });
history.pushState(null, childrenPath, childrenPath);
store.dispatch('menu/setBreadCrumb', state.curBreadCrumb);
}
}, err => {
......
......@@ -50,7 +50,7 @@ export default {
})
const showEmpty = computed(() => {
return !state.el_sub_innerH;
return !state.el_sub_innerH || store.getters.commonData.showEmpty;
})
const breadCrumbList = computed(() => {
......@@ -99,6 +99,9 @@ export default {
</script>
<style lang="less" scoped>
@import 'styles/variables.less';
.ant-layout-content {
min-height: unset !important;
}
.ant-empty {
margin-top: 200px;
}
......
......@@ -33,6 +33,7 @@ export default {
const logout = () => {
localStorage.removeItem('token');
localStorage.removeItem('userInfo');
localStorage.removeItem('breadCrumb');
store.dispatch('app/setToken', '');
setTimeout(()=>{
window.location.reload();
......
......@@ -9,7 +9,7 @@ const menuTree = [
menuName: "设备管理",
menuNo: 201,
type: 1,
icon: ''
icon: 'CarOutlined'
},
children: [
{
......@@ -29,7 +29,7 @@ const menuTree = [
menuName: "系统管理",
menuNo: 101,
type: 1,
icon: ''
icon: 'DesktopOutlined'
},
children: [
{
......@@ -47,7 +47,7 @@ const menuTree = [
menuName: "用户组管理",
menuNo: 10102,
type: 2,
path: ''
path: '/404'
}
},
{
......
......@@ -9,16 +9,16 @@ const showLoading = status => {
registerMicroApps(apps, {
// qiankun 生命周期钩子 - 加载前
beforeLoad: (app) => {
showLoading(true);
// showLoading(true);
// 超时
setTimeout(() => {
showLoading(false);
}, 10000)
// setTimeout(() => {
// showLoading(false);
// }, 1000)
return Promise.resolve();
},
// qiankun 生命周期钩子 - 挂载后
afterMount: (app) => {
showLoading(false);
// showLoading(false);
return Promise.resolve();
},
});
......
......@@ -8,7 +8,7 @@ export default {
userInfo: {},
showLoading: false,
commonData: {
parent: 0
showEmpty: false
}
},
mutations: {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!