@lambo-design/pro-layout 1.0.0-beta.1 → 1.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/components/pro-layout-header.vue +4 -1
- package/src/components/pro-layout-logo.vue +3 -0
- package/src/components/pro-layout-nav.vue +93 -17
- package/src/components/pro-layout-sider-collapsed-menu.vue +94 -0
- package/src/components/pro-layout-sider-icon.vue +81 -0
- package/src/components/pro-layout-sider-menu-item.vue +37 -0
- package/src/components/pro-layout-sider.vue +217 -4
- package/src/components/pro-layout-tabs.vue +373 -4
- package/src/components/pro-layout-tools-user.vue +84 -0
- package/src/components/pro-layout-tools.vue +10 -4
- package/src/components/pro-layout-trigger.vue +1 -1
- package/src/index.vue +103 -10
- package/src/styles/images/menuicon/icon-cang-s.png +0 -0
- package/src/styles/images/menuicon/icon-cang.png +0 -0
- package/src/styles/images/menuicon/icon-ding-s.png +0 -0
- package/src/styles/images/menuicon/icon-ding.png +0 -0
- package/src/styles/images/menuicon/icon-huo1-s.png +0 -0
- package/src/styles/images/menuicon/icon-huo1.png +0 -0
- package/src/styles/images/menuicon/icon-huo2-s.png +0 -0
- package/src/styles/images/menuicon/icon-huo2.png +0 -0
- package/src/styles/images/menuicon/icon-huo3-s.png +0 -0
- package/src/styles/images/menuicon/icon-huo3.png +0 -0
- package/src/styles/images/menuicon/icon-jin-s.png +0 -0
- package/src/styles/images/menuicon/icon-jin.png +0 -0
- package/src/styles/images/menuicon/icon-ke1-s.png +0 -0
- package/src/styles/images/menuicon/icon-ke1.png +0 -0
- package/src/styles/images/menuicon/icon-ke2-s.png +0 -0
- package/src/styles/images/menuicon/icon-ke2.png +0 -0
- package/src/styles/images/menuicon/icon-pin1-s.png +0 -0
- package/src/styles/images/menuicon/icon-pin1.png +0 -0
- package/src/styles/images/menuicon/icon-pin2-s.png +0 -0
- package/src/styles/images/menuicon/icon-pin2.png +0 -0
- package/src/styles/images/menuicon/icon-she-s.png +0 -0
- package/src/styles/images/menuicon/icon-she.png +0 -0
- package/src/styles/images/menuicon/icon-shi2-s.png +0 -0
- package/src/styles/images/menuicon/icon-shi2.png +0 -0
- package/src/styles/images/menuicon/icon-shi3-s.png +0 -0
- package/src/styles/images/menuicon/icon-shi3.png +0 -0
- package/src/styles/images/menuicon/icon-shu-s.png +0 -0
- package/src/styles/images/menuicon/icon-shu.png +0 -0
- package/src/styles/images/menuicon/icon-xi2-s.png +0 -0
- package/src/styles/images/menuicon/icon-xi2.png +0 -0
- package/src/styles/images/menuicon/icon-xiao-s.png +0 -0
- package/src/styles/images/menuicon/icon-xiao.png +0 -0
- package/src/styles/images/menuicon/icon-yang-s.png +0 -0
- package/src/styles/images/menuicon/icon-yang.png +0 -0
- package/src/styles/images/menuicon/icon-zhi-s.png +0 -0
- package/src/styles/images/menuicon/icon-zhi.png +0 -0
- package/src/styles/images/menuicon/icon-zhong-s.png +0 -0
- package/src/styles/images/menuicon/icon-zhong.png +0 -0
- package/src/utils/menuItem.js +21 -0
- package/src/utils/sider.js +25 -0
package/package.json
CHANGED
|
@@ -39,6 +39,8 @@ export default {
|
|
|
39
39
|
|
|
40
40
|
<style scoped lang="less">
|
|
41
41
|
.pro-layout-logo{
|
|
42
|
+
overflow: hidden;
|
|
43
|
+
border-bottom: 1px solid #000000;
|
|
42
44
|
.logo{
|
|
43
45
|
width: 150px;
|
|
44
46
|
height: 55px;
|
|
@@ -46,6 +48,7 @@ export default {
|
|
|
46
48
|
background-size: 100%;
|
|
47
49
|
float: left;
|
|
48
50
|
margin-top: 8px;
|
|
51
|
+
border-bottom: 1px solid #000000;
|
|
49
52
|
}
|
|
50
53
|
.divider{
|
|
51
54
|
height: 33px;
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="pro-layout-nav">
|
|
3
|
-
<Menu mode="horizontal" :active-name="activeName" @on-select="selectApp">
|
|
3
|
+
<Menu ref="topNav" mode="horizontal" theme="dark" :active-name="activeName" @on-select="selectApp">
|
|
4
4
|
<MenuItem :name="item.appId" v-for="item in topMenList" :key="item.appId">
|
|
5
|
-
<Icon :type="item.icon ? item.icon : 'ios-paper'" />
|
|
6
5
|
{{item.name}}
|
|
6
|
+
<div class="line"></div>
|
|
7
7
|
</MenuItem>
|
|
8
8
|
<Submenu name="other" v-if="otherList.length > 0">
|
|
9
9
|
<template slot="title">
|
|
10
10
|
...
|
|
11
11
|
</template>
|
|
12
12
|
<MenuItem :name="item.appId" v-for="item in otherList" :key="item.appId">
|
|
13
|
-
|
|
14
|
-
{{item.name}}
|
|
13
|
+
{{item.name}}
|
|
15
14
|
</MenuItem>
|
|
16
15
|
</Submenu>
|
|
17
16
|
</Menu>
|
|
@@ -20,6 +19,8 @@
|
|
|
20
19
|
|
|
21
20
|
<script>
|
|
22
21
|
import Bus from "@lambo-design/shared/utils/bus";
|
|
22
|
+
import {deepCopy} from "@lambo-design/shared/utils/assist";
|
|
23
|
+
import config from "@lambo-design/shared/config/config";
|
|
23
24
|
|
|
24
25
|
export default {
|
|
25
26
|
name: "pro-layout-logo",
|
|
@@ -28,7 +29,9 @@ export default {
|
|
|
28
29
|
navList : [],
|
|
29
30
|
topMenList : [],
|
|
30
31
|
otherList : [],
|
|
31
|
-
activeName : ''
|
|
32
|
+
activeName : '',
|
|
33
|
+
topMenuNum : 4,
|
|
34
|
+
originMenuList: []
|
|
32
35
|
}
|
|
33
36
|
},
|
|
34
37
|
methods: {
|
|
@@ -36,28 +39,58 @@ export default {
|
|
|
36
39
|
Bus.$on('nav-list',(data)=>{
|
|
37
40
|
this.initNav(data)
|
|
38
41
|
});
|
|
42
|
+
Bus.$on('change-app', ({appId,appInfo})=> {
|
|
43
|
+
this.changeApp(appId,appInfo)
|
|
44
|
+
});
|
|
45
|
+
Bus.$on('menu-list',(data)=>{
|
|
46
|
+
this.initMenu(data)
|
|
47
|
+
});
|
|
39
48
|
},
|
|
40
49
|
destroyListener(){
|
|
41
50
|
Bus.$off('nav-list')
|
|
51
|
+
Bus.$off('menu-list')
|
|
52
|
+
Bus.$off('change-app')
|
|
42
53
|
},
|
|
43
54
|
initNav(data){
|
|
55
|
+
if (data.toString() === this.navList.toString()) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
44
58
|
this.navList = data;
|
|
45
|
-
if (data.length >
|
|
46
|
-
|
|
47
|
-
this.
|
|
59
|
+
if (data.length > this.topMenuNum) {
|
|
60
|
+
let navList = deepCopy(data);
|
|
61
|
+
this.topMenList = navList.splice(0,this.topMenuNum);
|
|
62
|
+
this.otherList = navList;
|
|
48
63
|
} else {
|
|
49
64
|
this.topMenList = this.navList
|
|
50
65
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (item.appId == appId) {
|
|
56
|
-
appInfo = item;
|
|
57
|
-
break;
|
|
66
|
+
if (this.topMenList.length > 0){
|
|
67
|
+
let appId = this.topMenList[0].appId;
|
|
68
|
+
if (this.activeName) {
|
|
69
|
+
appId = this.activeName;
|
|
58
70
|
}
|
|
71
|
+
this.selectApp(appId);
|
|
59
72
|
}
|
|
60
|
-
|
|
73
|
+
},
|
|
74
|
+
initMenu(data){
|
|
75
|
+
this.originMenuList = deepCopy(data);
|
|
76
|
+
},
|
|
77
|
+
selectApp(appId){
|
|
78
|
+
this.activeName = appId;
|
|
79
|
+
let res = this.navList.filter(app => app.appId == appId);
|
|
80
|
+
Bus.$emit('change-app', {appId,appInfo:res[0]})
|
|
81
|
+
},
|
|
82
|
+
changeApp(appId,appInfo) {
|
|
83
|
+
this.activeName = appId;
|
|
84
|
+
this.$nextTick(() => {
|
|
85
|
+
this.$refs.topNav.updateActiveName()
|
|
86
|
+
})
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
watch: {
|
|
90
|
+
activeName(){
|
|
91
|
+
this.$nextTick(()=>{
|
|
92
|
+
this.$refs.topNav.updateActiveName();
|
|
93
|
+
})
|
|
61
94
|
}
|
|
62
95
|
},
|
|
63
96
|
created(){
|
|
@@ -69,6 +102,49 @@ export default {
|
|
|
69
102
|
}
|
|
70
103
|
</script>
|
|
71
104
|
|
|
72
|
-
<style scoped>
|
|
105
|
+
<style scoped lang="less">
|
|
106
|
+
@import '@lambo-design/core/src/styles/default.less';
|
|
107
|
+
.pro-layout-nav{
|
|
108
|
+
.ivu-menu{
|
|
109
|
+
.ivu-menu-item{
|
|
110
|
+
&:hover{
|
|
111
|
+
background: rgba(255,255,255,0.2);
|
|
112
|
+
.line{
|
|
113
|
+
border-bottom: 2px solid var(--primary-color,@_primary-color);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
&.ivu-menu-item-active,&.ivu-menu-item-selected{
|
|
117
|
+
background: rgba(255,255,255,0.2);
|
|
118
|
+
.line{
|
|
119
|
+
border-bottom: 2px solid var(--primary-color,@_primary-color);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/deep/.ivu-menu-submenu{
|
|
124
|
+
.ivu-menu-submenu-title > i{
|
|
125
|
+
&.ivu-menu-submenu-title-icon{
|
|
126
|
+
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
.ivu-select-dropdown{
|
|
130
|
+
background: var(--menu-dark-title,@_menu-dark-title);
|
|
131
|
+
color: var(--heading-color-dark,@_heading-color-dark);
|
|
132
|
+
.ivu-menu-drop-list{
|
|
133
|
+
.ivu-menu-item{
|
|
134
|
+
color: var(--menu-dark-subsidiary-color,@_menu-dark-subsidiary-color);
|
|
135
|
+
&:hover{
|
|
136
|
+
background: rgba(255,255,255,0.2);
|
|
137
|
+
color: var(--heading-color-dark,@_heading-color-dark);
|
|
138
|
+
}
|
|
139
|
+
&.ivu-menu-item-active,&.ivu-menu-item-selected{
|
|
140
|
+
background: rgba(255,255,255,0.2);
|
|
141
|
+
color: var(--heading-color-dark,@_heading-color-dark);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
73
149
|
|
|
74
150
|
</style>
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Dropdown ref="dropdown" :class="hideTitle ? '' : 'collased-menu-dropdown'" :placement="placement"
|
|
3
|
+
:transfer="hideTitle" @on-click="handleClick">
|
|
4
|
+
<a :style="{textAlign: !hideTitle ? 'left' : ''}" class="drop-menu-a" type="text"
|
|
5
|
+
@mouseover="handleMousemove($event, children)">
|
|
6
|
+
<ProLayoutSiderIcon :icon-type="parentItem.meta.icon"></ProLayoutSiderIcon>
|
|
7
|
+
<span v-if="!hideTitle" class="menu-title">{{ showTitle(parentItem) }}</span>
|
|
8
|
+
<Icon v-if="!hideTitle" :size="20" style="float: right;" type="ios-arrow-forward"/>
|
|
9
|
+
</a>
|
|
10
|
+
<DropdownMenu ref="dropdown" slot="list">
|
|
11
|
+
<template v-for="child in children">
|
|
12
|
+
<ProLayoutSiderCollapsedMenu v-if="showChildren(child)" :key="`drop-${child.name}`"
|
|
13
|
+
:parent-item="child">
|
|
14
|
+
</ProLayoutSiderCollapsedMenu>
|
|
15
|
+
<DropdownItem v-else :key="`drop-${child.name}`" :name="child.name">
|
|
16
|
+
<ProLayoutSiderIcon :icon-type="child.meta.icon"></ProLayoutSiderIcon>
|
|
17
|
+
<span class="menu-title">{{ showTitle(child) }}</span>
|
|
18
|
+
</DropdownItem>
|
|
19
|
+
</template>
|
|
20
|
+
</DropdownMenu>
|
|
21
|
+
</Dropdown>
|
|
22
|
+
</template>
|
|
23
|
+
<script>
|
|
24
|
+
import sider from '../utils/sider'
|
|
25
|
+
import menuItem from '../utils/menuItem'
|
|
26
|
+
import {findNodeUpperByClasses} from '@lambo-design/shared/utils/platform'
|
|
27
|
+
|
|
28
|
+
export default {
|
|
29
|
+
name: 'ProLayoutSiderCollapsedMenu',
|
|
30
|
+
mixins: [sider, menuItem],
|
|
31
|
+
props: {
|
|
32
|
+
hideTitle: {
|
|
33
|
+
type: Boolean,
|
|
34
|
+
default: false
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
data() {
|
|
38
|
+
return {
|
|
39
|
+
placement: 'right-start'
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
methods: {
|
|
43
|
+
handleClick(name) {
|
|
44
|
+
this.$emit('on-click', name)
|
|
45
|
+
},
|
|
46
|
+
handleMousemove(event, children) {
|
|
47
|
+
const {pageY} = event
|
|
48
|
+
const height = children.length * 38
|
|
49
|
+
const isOverflow = pageY + height < window.innerHeight
|
|
50
|
+
this.placement = isOverflow ? 'right-start' : 'right-end'
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
mounted() {
|
|
54
|
+
let dropdown = findNodeUpperByClasses(this.$refs.dropdown.$el, ['ivu-select-dropdown', 'ivu-dropdown-transfer'])
|
|
55
|
+
if (dropdown) dropdown.style.overflow = 'visible'
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
</script>
|
|
59
|
+
<style lang="less" scoped>
|
|
60
|
+
@import "@lambo-design/core/src/styles/default";
|
|
61
|
+
.collased-menu-dropdown {
|
|
62
|
+
width: 100%;
|
|
63
|
+
margin: 0;
|
|
64
|
+
line-height: normal;
|
|
65
|
+
padding: 7px 0 6px 16px;
|
|
66
|
+
clear: both;
|
|
67
|
+
font-size: var(--font-size-base, 14px) !important;
|
|
68
|
+
white-space: nowrap;
|
|
69
|
+
list-style: none;
|
|
70
|
+
cursor: pointer;
|
|
71
|
+
transition: background 0.2s ease-in-out;
|
|
72
|
+
&:hover{
|
|
73
|
+
color: var(--heading-color, @_heading-color);
|
|
74
|
+
background: rgba(26,26,26,0.05);
|
|
75
|
+
}
|
|
76
|
+
a.drop-menu-a{
|
|
77
|
+
display: inline-block;
|
|
78
|
+
width: 100%;
|
|
79
|
+
font-weight: normal;
|
|
80
|
+
color: var(--text-color, @_text-color);
|
|
81
|
+
&:hover{
|
|
82
|
+
color: var(--heading-color, @_heading-color);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
</style>
|
|
87
|
+
<style lang="less">
|
|
88
|
+
.ivu-select-dropdown {
|
|
89
|
+
&.ivu-dropdown-transfer {
|
|
90
|
+
max-height: 400px;
|
|
91
|
+
max-width: 150px;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
</style>
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Icon v-if="isIvuIcon" :type="typeName" :size="iconSize"></Icon>
|
|
3
|
+
<i v-else class="iconfont" :style="renderImage"></i>
|
|
4
|
+
</template>
|
|
5
|
+
|
|
6
|
+
<script>
|
|
7
|
+
export default {
|
|
8
|
+
name: "pro-layout-sider-icon",
|
|
9
|
+
props: {
|
|
10
|
+
iconType: {
|
|
11
|
+
type: String,
|
|
12
|
+
default: 'icon'
|
|
13
|
+
},
|
|
14
|
+
iconSize: {
|
|
15
|
+
type: String | Number,
|
|
16
|
+
default: 14
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
computed: {
|
|
20
|
+
isIvuIcon(){
|
|
21
|
+
if (this.iconType && this.iconType.indexOf('iconfont') > -1) {
|
|
22
|
+
return false
|
|
23
|
+
}
|
|
24
|
+
return true;
|
|
25
|
+
},
|
|
26
|
+
typeName(){
|
|
27
|
+
let iconType = this.iconType;
|
|
28
|
+
if (!iconType) {
|
|
29
|
+
iconType = 'ios-folder';
|
|
30
|
+
}
|
|
31
|
+
if (iconType == 'icon'){
|
|
32
|
+
iconType = 'ios-folder'
|
|
33
|
+
}
|
|
34
|
+
return iconType;
|
|
35
|
+
},
|
|
36
|
+
renderImage(){
|
|
37
|
+
let iconType = this.iconType;
|
|
38
|
+
if (!iconType) {
|
|
39
|
+
iconType = 'icon'
|
|
40
|
+
}
|
|
41
|
+
if (iconType.indexOf('iconfont') > -1) {
|
|
42
|
+
let imgName = iconType.replace('iconfont','').replace(/\s+/g,'');
|
|
43
|
+
return 'background: url('+ require('../styles/images/menuicon/' + imgName + '-s.png') +') no-repeat;background-size: 100%;';
|
|
44
|
+
}
|
|
45
|
+
return '';
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<style scoped lang="less">
|
|
52
|
+
.iconfont{
|
|
53
|
+
width: 14px;
|
|
54
|
+
height: 14px;
|
|
55
|
+
float: left;
|
|
56
|
+
margin-top: 6px;
|
|
57
|
+
filter: brightness(0.8);
|
|
58
|
+
}
|
|
59
|
+
.ivu-menu-submenu{
|
|
60
|
+
.ivu-menu-submenu-title{
|
|
61
|
+
&:hover {
|
|
62
|
+
.iconfont{
|
|
63
|
+
filter: brightness(1.4);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
.menu-collapsed{
|
|
69
|
+
a.drop-menu-a{
|
|
70
|
+
.iconfont{
|
|
71
|
+
width: 26px;
|
|
72
|
+
height: 26px;
|
|
73
|
+
}
|
|
74
|
+
&:hover{
|
|
75
|
+
.iconfont{
|
|
76
|
+
filter: brightness(1.4);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
</style>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Submenu v-show="isShow" :name="`${parentName}`">
|
|
3
|
+
<template slot="title">
|
|
4
|
+
<ProLayoutSiderIcon :icon-type="parentItem.meta.icon"></ProLayoutSiderIcon>
|
|
5
|
+
<span>{{ showTitle(parentItem) }}</span>
|
|
6
|
+
</template>
|
|
7
|
+
<template v-for="item in children">
|
|
8
|
+
<template v-if="item.children && item.children.length === 1">
|
|
9
|
+
<ProLayoutSiderMenuItem v-if="showChildren(item)" :key="`menu-${item.name}`"
|
|
10
|
+
:parent-item="item">
|
|
11
|
+
</ProLayoutSiderMenuItem>
|
|
12
|
+
<menu-item v-else :key="`menu-${item.children[0].name}`" :name="getNameOrHref(item, true)">
|
|
13
|
+
<ProLayoutSiderIcon :icon-type="item.meta.icon"></ProLayoutSiderIcon>
|
|
14
|
+
<span>{{ showTitle(item.children[0]) }}</span>
|
|
15
|
+
</menu-item>
|
|
16
|
+
</template>
|
|
17
|
+
<template v-else>
|
|
18
|
+
<ProLayoutSiderMenuItem v-if="showChildren(item)" :key="`menu-${item.name}`"
|
|
19
|
+
:parent-item="item">
|
|
20
|
+
</ProLayoutSiderMenuItem>
|
|
21
|
+
<menu-item v-else :key="`menu-${item.name}`" :name="getNameOrHref(item)">
|
|
22
|
+
<ProLayoutSiderIcon :icon-type="item.meta.icon"></ProLayoutSiderIcon>
|
|
23
|
+
<span>{{ showTitle(item) }}</span>
|
|
24
|
+
</menu-item>
|
|
25
|
+
</template>
|
|
26
|
+
</template>
|
|
27
|
+
</Submenu>
|
|
28
|
+
</template>
|
|
29
|
+
<script>
|
|
30
|
+
import sider from '../utils/sider'
|
|
31
|
+
import menuItem from '../utils/menuItem'
|
|
32
|
+
|
|
33
|
+
export default {
|
|
34
|
+
name: 'ProLayoutSiderMenuItem',
|
|
35
|
+
mixins: [sider, menuItem],
|
|
36
|
+
}
|
|
37
|
+
</script>
|
|
@@ -1,15 +1,228 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="pro-layout-sider">
|
|
3
|
-
|
|
3
|
+
<Menu v-show="!collapsed" ref="menu"
|
|
4
|
+
:accordion="accordion" :active-name="activeName"
|
|
5
|
+
:open-names="openedNames" theme="dark"
|
|
6
|
+
width="auto" @on-select="handleSelect">
|
|
7
|
+
<template v-for="item in menuList">
|
|
8
|
+
<template v-if="item.children && item.children.length === 1">
|
|
9
|
+
<ProLayoutSiderMenuItem v-if="showChildren(item)"
|
|
10
|
+
:key="`menu-${item.name}`"
|
|
11
|
+
:parent-item="item">
|
|
12
|
+
</ProLayoutSiderMenuItem>
|
|
13
|
+
<MenuItem v-else :key="`menu-${item.children[0].name}`"
|
|
14
|
+
:name="getNameOrHref(item, true)">
|
|
15
|
+
<ProLayoutSiderIcon :icon-type="item.meta.icon"></ProLayoutSiderIcon>
|
|
16
|
+
<span>{{ showTitle(item.children[0]) }}</span>
|
|
17
|
+
</MenuItem>
|
|
18
|
+
</template>
|
|
19
|
+
<template v-else>
|
|
20
|
+
<ProLayoutSiderMenuItem v-if="showChildren(item)" :key="`menu-${item.name}`"
|
|
21
|
+
:parent-item="item">
|
|
22
|
+
</ProLayoutSiderMenuItem>
|
|
23
|
+
<MenuItem v-else :key="`menu-${item.name}`"
|
|
24
|
+
:name="getNameOrHref(item)">
|
|
25
|
+
<ProLayoutSiderIcon :icon-type="item.meta.icon"></ProLayoutSiderIcon>
|
|
26
|
+
<span>{{ showTitle(item) }}</span>
|
|
27
|
+
</MenuItem>
|
|
28
|
+
</template>
|
|
29
|
+
</template>
|
|
30
|
+
</Menu>
|
|
31
|
+
<div v-show="collapsed" :list="menuList" class="menu-collapsed">
|
|
32
|
+
<template v-for="item in menuList">
|
|
33
|
+
<ProLayoutSiderCollapsedMenu v-if="item.children && item.children.length > 1" :key="`drop-menu-${item.name}`"
|
|
34
|
+
:parent-item="item" theme="dark" hide-title
|
|
35
|
+
@on-click="handleSelect">
|
|
36
|
+
</ProLayoutSiderCollapsedMenu>
|
|
37
|
+
<Tooltip v-else :key="`drop-menu-${item.name}`" :content="showTitle(item.children && item.children[0] ? item.children[0] : item)"
|
|
38
|
+
placement="right" transfer>
|
|
39
|
+
<a :style="{textAlign: 'center'}" class="drop-menu-a"
|
|
40
|
+
@click="handleSelect(getNameOrHref(item, true))">
|
|
41
|
+
<ProLayoutSiderIcon :icon-type="item.meta.icon" icon-size="26"></ProLayoutSiderIcon>
|
|
42
|
+
</a>
|
|
43
|
+
</Tooltip>
|
|
44
|
+
</template>
|
|
45
|
+
</div>
|
|
4
46
|
</div>
|
|
5
47
|
</template>
|
|
6
48
|
|
|
7
49
|
<script>
|
|
50
|
+
import Bus from "@lambo-design/shared/utils/bus";
|
|
51
|
+
import {deepCopy} from "@lambo-design/shared/utils/assist";
|
|
52
|
+
import generatorMenuList from "@lambo-design/shared/utils/menu/index";
|
|
53
|
+
import sider from '../utils/sider'
|
|
54
|
+
import ProLayoutSiderMenuItem from './pro-layout-sider-menu-item'
|
|
55
|
+
import ProLayoutSiderCollapsedMenu from './pro-layout-sider-collapsed-menu'
|
|
56
|
+
import {
|
|
57
|
+
filterMenuName,
|
|
58
|
+
filterMenuUri,
|
|
59
|
+
tagExists
|
|
60
|
+
} from "@lambo-design/shared/utils/platform";
|
|
61
|
+
|
|
8
62
|
export default {
|
|
9
|
-
name: "pro-layout-
|
|
63
|
+
name: "pro-layout-sider",
|
|
64
|
+
components: {
|
|
65
|
+
ProLayoutSiderMenuItem,
|
|
66
|
+
ProLayoutSiderCollapsedMenu
|
|
67
|
+
},
|
|
68
|
+
data(){
|
|
69
|
+
return {
|
|
70
|
+
navList: [],
|
|
71
|
+
originMenuList:[],
|
|
72
|
+
menuList: [],
|
|
73
|
+
appId: '',
|
|
74
|
+
collapsed: false,
|
|
75
|
+
accordion: true,
|
|
76
|
+
activeName: '',
|
|
77
|
+
openedNames: [],
|
|
78
|
+
tagValue: '',
|
|
79
|
+
tagList: []
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
mixins:[sider],
|
|
83
|
+
methods: {
|
|
84
|
+
initListener(){
|
|
85
|
+
Bus.$on('nav-list',(data)=>{
|
|
86
|
+
this.initNav(data)
|
|
87
|
+
});
|
|
88
|
+
Bus.$on('menu-list',(data)=>{
|
|
89
|
+
this.initMenu(data)
|
|
90
|
+
});
|
|
91
|
+
Bus.$on('trigger-change',(data)=>{
|
|
92
|
+
this.triggerChange(data)
|
|
93
|
+
});
|
|
94
|
+
Bus.$on('change-app', ({appId,appInfo})=> {
|
|
95
|
+
this.changeApp(appId,appInfo)
|
|
96
|
+
})
|
|
97
|
+
Bus.$on('tag-list',(data,current)=>{
|
|
98
|
+
this.initTags(data,current)
|
|
99
|
+
});
|
|
100
|
+
Bus.$on('menu-click',(current)=>{
|
|
101
|
+
this.menuClick(current)
|
|
102
|
+
});
|
|
103
|
+
},
|
|
104
|
+
destroyListener(){
|
|
105
|
+
Bus.$off('nav-list')
|
|
106
|
+
Bus.$off('menu-list')
|
|
107
|
+
Bus.$off('trigger-change')
|
|
108
|
+
Bus.$off('change-app')
|
|
109
|
+
Bus.$off('tag-list')
|
|
110
|
+
Bus.$off('menu-click')
|
|
111
|
+
},
|
|
112
|
+
initNav(data){
|
|
113
|
+
if (data.toString() === this.navList.toString()) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
this.navList = data;
|
|
117
|
+
},
|
|
118
|
+
initMenu(data){
|
|
119
|
+
if (data && data.length > 0) {
|
|
120
|
+
let item = data[0];
|
|
121
|
+
if (item.appId && item.appId !== this.appId) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
this.originMenuList = deepCopy(data);
|
|
126
|
+
this.changeMenu()
|
|
127
|
+
},
|
|
128
|
+
changeApp(appId,appInfo){
|
|
129
|
+
this.appId = appId;
|
|
130
|
+
this.changeMenu()
|
|
131
|
+
},
|
|
132
|
+
changeMenu(){
|
|
133
|
+
let treeMenuList = generatorMenuList(this.originMenuList,this.appId);
|
|
134
|
+
if (treeMenuList && treeMenuList.length > 0) {
|
|
135
|
+
this.menuList = treeMenuList;
|
|
136
|
+
} else {
|
|
137
|
+
this.menuList = [];
|
|
138
|
+
}
|
|
139
|
+
this.openedNames = this.getOpenedNamesByActiveName();
|
|
140
|
+
},
|
|
141
|
+
handleSelect(name){
|
|
142
|
+
let menu = null;
|
|
143
|
+
if (name.indexOf("isTurnByHref_") > -1) {
|
|
144
|
+
name = name.replace("isTurnByHref_","");
|
|
145
|
+
menu = filterMenuUri(this.menuList,name);
|
|
146
|
+
} else {
|
|
147
|
+
menu = filterMenuName(this.menuList,name);
|
|
148
|
+
}
|
|
149
|
+
let tagList = this.tagList;
|
|
150
|
+
if (menu && menu.name) {
|
|
151
|
+
if (!tagExists(tagList,menu.name)) {
|
|
152
|
+
tagList.push(menu);
|
|
153
|
+
}
|
|
154
|
+
Bus.$emit('tag-list', tagList, menu.name)
|
|
155
|
+
}
|
|
156
|
+
//Bus.$emit('menu-click', name)
|
|
157
|
+
},
|
|
158
|
+
triggerChange(data){
|
|
159
|
+
this.collapsed = data;
|
|
160
|
+
},
|
|
161
|
+
initTags(data,name){
|
|
162
|
+
this.tagList = data;
|
|
163
|
+
this.value = name;
|
|
164
|
+
},
|
|
165
|
+
menuClick(current) {
|
|
166
|
+
this.activeName = current;
|
|
167
|
+
},
|
|
168
|
+
getOpenedNamesByActiveName(){
|
|
169
|
+
let res = filterMenuName(this.menuList,this.activeName);
|
|
170
|
+
let openNames = []
|
|
171
|
+
if (res) {
|
|
172
|
+
const crumbs = res.meta.crumbs;
|
|
173
|
+
if (crumbs) {
|
|
174
|
+
crumbs.forEach(item => {
|
|
175
|
+
if (item.type === 1) {
|
|
176
|
+
openNames.push(item.name)
|
|
177
|
+
}
|
|
178
|
+
})
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return openNames
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
watch:{
|
|
185
|
+
activeName(){
|
|
186
|
+
this.openedNames = this.getOpenedNamesByActiveName();
|
|
187
|
+
},
|
|
188
|
+
openedNames() {
|
|
189
|
+
this.$nextTick(() => {
|
|
190
|
+
this.$refs.menu.updateOpened()
|
|
191
|
+
this.$refs.menu.updateActiveName()
|
|
192
|
+
})
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
created(){
|
|
196
|
+
this.initListener();
|
|
197
|
+
},
|
|
198
|
+
beforeDestroy(){
|
|
199
|
+
this.destroyListener();
|
|
200
|
+
}
|
|
201
|
+
|
|
10
202
|
}
|
|
11
203
|
</script>
|
|
12
204
|
|
|
13
|
-
<style scoped>
|
|
14
|
-
|
|
205
|
+
<style scoped lang="less">
|
|
206
|
+
@import "@lambo-design/core/src/styles/default";
|
|
207
|
+
.pro-layout-sider{
|
|
208
|
+
/deep/.ivu-menu-submenu{
|
|
209
|
+
.ivu-menu{
|
|
210
|
+
background: #1A1A1A;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
.menu-collapsed {
|
|
214
|
+
padding-top: 10px;
|
|
215
|
+
/deep/a.drop-menu-a{
|
|
216
|
+
display: inline-block;
|
|
217
|
+
padding: 6px 20px;
|
|
218
|
+
width: 100%;
|
|
219
|
+
text-align: center;
|
|
220
|
+
font-weight: normal;
|
|
221
|
+
color: var(--menu-dark-subsidiary-color, @_menu-dark-subsidiary-color);
|
|
222
|
+
&:hover{
|
|
223
|
+
color: var(--heading-color-dark, @_heading-color-dark);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
15
228
|
</style>
|