Commit 84a62671 by 冒粤蓉

fix portal

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