imatrix-ui 0.2.3-up → 0.2.5-up
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/lib/super-ui.css +1 -1
- package/lib/super-ui.js +1033 -1118
- package/lib/super-ui.umd.cjs +25 -31
- package/package.json +33 -34
- package/packages/super-grid/src/normal-column.vue +1224 -1221
- package/packages/super-nine-grid/src/super-nine-grid.vue +1188 -1164
- package/packages/super-nine-grid/src/utils.js +264 -264
- package/src/permission.js +160 -160
- package/src/router/index.js +110 -110
- package/src/store/modules/permission.js +145 -145
- package/src/styles/theme/dark-blue/button.scss +6 -0
- package/src/styles/theme/dark-blue/index.scss +6 -5
- package/src/styles/theme/dark-blue/pagination.scss +4 -0
- package/src/utils/auth-api.js +161 -159
- package/src/utils/util.js +544 -539
- package/src/views/layout/components/Menubar/SidebarItem.vue +164 -164
- package/src/views/layout/components/Sidebar/SidebarItem.vue +135 -135
|
@@ -1,164 +1,164 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="menu-wrapper">
|
|
3
|
-
<template v-if="!item.children || item.children.lenght === 0">
|
|
4
|
-
<app-link :to="toPath(item)" @click="clickMenu(toPath(item))">
|
|
5
|
-
<el-menu-item
|
|
6
|
-
:index="item.fullPath + '~~' + item.i18nValue"
|
|
7
|
-
:class="{ 'submenu-title-noDropdown': !isNest }"
|
|
8
|
-
>
|
|
9
|
-
<item
|
|
10
|
-
:icon="item.iconName"
|
|
11
|
-
:title="getI18nName(item)"
|
|
12
|
-
:is-root="true"
|
|
13
|
-
/>
|
|
14
|
-
</el-menu-item>
|
|
15
|
-
</app-link>
|
|
16
|
-
</template>
|
|
17
|
-
|
|
18
|
-
<el-sub-menu v-else :index="item.fullPath + '~~' + item.i18nValue">
|
|
19
|
-
<template v-slot:title>
|
|
20
|
-
<item
|
|
21
|
-
:icon="item.iconName"
|
|
22
|
-
:title="getI18nName(item)"
|
|
23
|
-
:has-children="item.children.length > 0 ? true : false"
|
|
24
|
-
/>
|
|
25
|
-
</template>
|
|
26
|
-
|
|
27
|
-
<template v-for="child in item.children">
|
|
28
|
-
<sidebar-item
|
|
29
|
-
v-if="child.children && child.children.length > 0"
|
|
30
|
-
:is-nest="true"
|
|
31
|
-
:item="child"
|
|
32
|
-
class="nest-menu"
|
|
33
|
-
/>
|
|
34
|
-
<app-link v-else :to="toPath(child)" @click="clickMenu(toPath(child))">
|
|
35
|
-
<el-menu-item :index="child.fullPath + '~~' + child.i18nValue">
|
|
36
|
-
<item :icon="child.iconName" :title="getI18nName(child)" />
|
|
37
|
-
</el-menu-item>
|
|
38
|
-
</app-link>
|
|
39
|
-
</template>
|
|
40
|
-
</el-sub-menu>
|
|
41
|
-
</div>
|
|
42
|
-
</template>
|
|
43
|
-
|
|
44
|
-
<script>
|
|
45
|
-
import Item from './Item.vue'
|
|
46
|
-
import AppLink from './Link.vue'
|
|
47
|
-
import * as Vue from 'vue'
|
|
48
|
-
import { getI18nName } from 'imatrix-ui/src/utils/menu'
|
|
49
|
-
import tabJs from '../../../../api/tab'
|
|
50
|
-
|
|
51
|
-
export default {
|
|
52
|
-
name: 'SidebarItem',
|
|
53
|
-
components: { Item, AppLink },
|
|
54
|
-
props: {
|
|
55
|
-
// route object
|
|
56
|
-
item: {
|
|
57
|
-
type: Object,
|
|
58
|
-
required: true,
|
|
59
|
-
},
|
|
60
|
-
isNest: {
|
|
61
|
-
type: Boolean,
|
|
62
|
-
default: false,
|
|
63
|
-
},
|
|
64
|
-
basePath: {
|
|
65
|
-
type: String,
|
|
66
|
-
default: '',
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
data() {
|
|
70
|
-
return {
|
|
71
|
-
onlyOneChild: null,
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
methods: {
|
|
75
|
-
...tabJs,
|
|
76
|
-
hasOneShowingChild(children, parent) {
|
|
77
|
-
if (children && children.length > 0) {
|
|
78
|
-
this.onlyOneChild = children[0]
|
|
79
|
-
}
|
|
80
|
-
// When there is only one child router, the child router is displayed by default
|
|
81
|
-
if (children.length === 1) {
|
|
82
|
-
return true
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// Show parent if there are no child router to display
|
|
86
|
-
if (!children || children.length === 0) {
|
|
87
|
-
// children不存在
|
|
88
|
-
this.onlyOneChild = { ...parent, path: '', noShowingChildren: true }
|
|
89
|
-
return true
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return false
|
|
93
|
-
},
|
|
94
|
-
toPath(menu) {
|
|
95
|
-
const toPathObj = {}
|
|
96
|
-
const routePath = menu.fullPath
|
|
97
|
-
toPathObj.openWay = menu.openWay
|
|
98
|
-
if (this.isExternalLink(menu.pageType)) {
|
|
99
|
-
toPathObj.path = '/tab-content-iframe-index'
|
|
100
|
-
toPathObj.tabPath = '/iframe-page/page'
|
|
101
|
-
toPathObj.query = {}
|
|
102
|
-
toPathObj.query.src = routePath
|
|
103
|
-
toPathObj.isExternal = true
|
|
104
|
-
// 如果路径中没有拼系统编码,才需要把系统编码放到参数中
|
|
105
|
-
toPathObj.query.customSystem =
|
|
106
|
-
window.$vueApp.config.globalProperties.customSystem
|
|
107
|
-
toPathObj.query._menuCode = menu.code
|
|
108
|
-
toPathObj.query._menuName = getI18nName(menu)
|
|
109
|
-
} else {
|
|
110
|
-
toPathObj.path = '/tab-content-index'
|
|
111
|
-
toPathObj.tabPath = routePath
|
|
112
|
-
toPathObj.query = {}
|
|
113
|
-
toPathObj.query.customSystem =
|
|
114
|
-
window.$vueApp.config.globalProperties.customSystem
|
|
115
|
-
toPathObj.query._menuCode = menu.code
|
|
116
|
-
toPathObj.query._menuName = getI18nName(menu)
|
|
117
|
-
}
|
|
118
|
-
return toPathObj
|
|
119
|
-
},
|
|
120
|
-
isExternalLink(pageType) {
|
|
121
|
-
if (pageType && pageType === 'iframe') {
|
|
122
|
-
return true
|
|
123
|
-
}
|
|
124
|
-
return false
|
|
125
|
-
},
|
|
126
|
-
clickMenu(toPathObj) {
|
|
127
|
-
// console.log('clickMenu----toPathObj=', toPathObj)
|
|
128
|
-
if (
|
|
129
|
-
toPathObj.openWay &&
|
|
130
|
-
toPathObj.openWay === 'NEW_PAGE_OPEN' &&
|
|
131
|
-
toPathObj.query
|
|
132
|
-
) {
|
|
133
|
-
// 新页签打开菜单
|
|
134
|
-
let url = toPathObj.query.src
|
|
135
|
-
if (url && url.indexOf('?') > 0) {
|
|
136
|
-
url += '&'
|
|
137
|
-
} else {
|
|
138
|
-
url += '?'
|
|
139
|
-
}
|
|
140
|
-
if (toPathObj.query.customSystem) {
|
|
141
|
-
url += 'customSystem=' + toPathObj.query.customSystem
|
|
142
|
-
}
|
|
143
|
-
if (toPathObj.query._menuCode) {
|
|
144
|
-
url += '_menuCode=' + toPathObj.query._menuCode
|
|
145
|
-
}
|
|
146
|
-
if (toPathObj.query._menuCode) {
|
|
147
|
-
url += '_menuName=' + toPathObj.query._menuName
|
|
148
|
-
}
|
|
149
|
-
window.open(url, toPathObj.query._menuCode)
|
|
150
|
-
} else {
|
|
151
|
-
// 刷新页签打开菜单
|
|
152
|
-
this.addTabs(
|
|
153
|
-
toPathObj.query,
|
|
154
|
-
this.$store.state.tabContent.openTab,
|
|
155
|
-
toPathObj.tabPath
|
|
156
|
-
)
|
|
157
|
-
}
|
|
158
|
-
},
|
|
159
|
-
getI18nName(menu) {
|
|
160
|
-
return getI18nName(menu)
|
|
161
|
-
},
|
|
162
|
-
},
|
|
163
|
-
}
|
|
164
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<div class="menu-wrapper">
|
|
3
|
+
<template v-if="!item.children || item.children.lenght === 0">
|
|
4
|
+
<app-link :to="toPath(item)" @click="clickMenu(toPath(item))">
|
|
5
|
+
<el-menu-item
|
|
6
|
+
:index="item.fullPath + '~~' + item.i18nValue"
|
|
7
|
+
:class="{ 'submenu-title-noDropdown': !isNest }"
|
|
8
|
+
>
|
|
9
|
+
<item
|
|
10
|
+
:icon="item.iconName"
|
|
11
|
+
:title="getI18nName(item)"
|
|
12
|
+
:is-root="true"
|
|
13
|
+
/>
|
|
14
|
+
</el-menu-item>
|
|
15
|
+
</app-link>
|
|
16
|
+
</template>
|
|
17
|
+
|
|
18
|
+
<el-sub-menu v-else :index="item.fullPath + '~~' + item.i18nValue">
|
|
19
|
+
<template v-slot:title>
|
|
20
|
+
<item
|
|
21
|
+
:icon="item.iconName"
|
|
22
|
+
:title="getI18nName(item)"
|
|
23
|
+
:has-children="item.children.length > 0 ? true : false"
|
|
24
|
+
/>
|
|
25
|
+
</template>
|
|
26
|
+
|
|
27
|
+
<template v-for="child in item.children">
|
|
28
|
+
<sidebar-item
|
|
29
|
+
v-if="child.children && child.children.length > 0"
|
|
30
|
+
:is-nest="true"
|
|
31
|
+
:item="child"
|
|
32
|
+
class="nest-menu"
|
|
33
|
+
/>
|
|
34
|
+
<app-link v-else :to="toPath(child)" @click="clickMenu(toPath(child))">
|
|
35
|
+
<el-menu-item :index="child.fullPath + '~~' + child.i18nValue">
|
|
36
|
+
<item :icon="child.iconName" :title="getI18nName(child)" />
|
|
37
|
+
</el-menu-item>
|
|
38
|
+
</app-link>
|
|
39
|
+
</template>
|
|
40
|
+
</el-sub-menu>
|
|
41
|
+
</div>
|
|
42
|
+
</template>
|
|
43
|
+
|
|
44
|
+
<script>
|
|
45
|
+
import Item from './Item.vue'
|
|
46
|
+
import AppLink from './Link.vue'
|
|
47
|
+
import * as Vue from 'vue'
|
|
48
|
+
import { getI18nName } from 'imatrix-ui/src/utils/menu'
|
|
49
|
+
import tabJs from '../../../../api/tab'
|
|
50
|
+
|
|
51
|
+
export default {
|
|
52
|
+
name: 'SidebarItem',
|
|
53
|
+
components: { Item, AppLink },
|
|
54
|
+
props: {
|
|
55
|
+
// route object
|
|
56
|
+
item: {
|
|
57
|
+
type: Object,
|
|
58
|
+
required: true,
|
|
59
|
+
},
|
|
60
|
+
isNest: {
|
|
61
|
+
type: Boolean,
|
|
62
|
+
default: false,
|
|
63
|
+
},
|
|
64
|
+
basePath: {
|
|
65
|
+
type: String,
|
|
66
|
+
default: '',
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
data() {
|
|
70
|
+
return {
|
|
71
|
+
onlyOneChild: null,
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
methods: {
|
|
75
|
+
...tabJs,
|
|
76
|
+
hasOneShowingChild(children, parent) {
|
|
77
|
+
if (children && children.length > 0) {
|
|
78
|
+
this.onlyOneChild = children[0]
|
|
79
|
+
}
|
|
80
|
+
// When there is only one child router, the child router is displayed by default
|
|
81
|
+
if (children.length === 1) {
|
|
82
|
+
return true
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Show parent if there are no child router to display
|
|
86
|
+
if (!children || children.length === 0) {
|
|
87
|
+
// children不存在
|
|
88
|
+
this.onlyOneChild = { ...parent, path: '', noShowingChildren: true }
|
|
89
|
+
return true
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return false
|
|
93
|
+
},
|
|
94
|
+
toPath(menu) {
|
|
95
|
+
const toPathObj = {}
|
|
96
|
+
const routePath = menu.fullPath
|
|
97
|
+
toPathObj.openWay = menu.openWay
|
|
98
|
+
if (this.isExternalLink(menu.pageType)) {
|
|
99
|
+
toPathObj.path = '/tab-content-iframe-index'
|
|
100
|
+
toPathObj.tabPath = '/iframe-page/page'
|
|
101
|
+
toPathObj.query = {}
|
|
102
|
+
toPathObj.query.src = routePath
|
|
103
|
+
toPathObj.isExternal = true
|
|
104
|
+
// 如果路径中没有拼系统编码,才需要把系统编码放到参数中
|
|
105
|
+
toPathObj.query.customSystem =
|
|
106
|
+
window.$vueApp.config.globalProperties.customSystem
|
|
107
|
+
toPathObj.query._menuCode = menu.code
|
|
108
|
+
toPathObj.query._menuName = getI18nName(menu)
|
|
109
|
+
} else {
|
|
110
|
+
toPathObj.path = '/tab-content-index'
|
|
111
|
+
toPathObj.tabPath = routePath
|
|
112
|
+
toPathObj.query = {}
|
|
113
|
+
toPathObj.query.customSystem =
|
|
114
|
+
window.$vueApp.config.globalProperties.customSystem
|
|
115
|
+
toPathObj.query._menuCode = menu.code
|
|
116
|
+
toPathObj.query._menuName = getI18nName(menu)
|
|
117
|
+
}
|
|
118
|
+
return toPathObj
|
|
119
|
+
},
|
|
120
|
+
isExternalLink(pageType) {
|
|
121
|
+
if (pageType && pageType === 'iframe') {
|
|
122
|
+
return true
|
|
123
|
+
}
|
|
124
|
+
return false
|
|
125
|
+
},
|
|
126
|
+
clickMenu(toPathObj) {
|
|
127
|
+
// console.log('clickMenu----toPathObj=', toPathObj)
|
|
128
|
+
if (
|
|
129
|
+
toPathObj.openWay &&
|
|
130
|
+
toPathObj.openWay === 'NEW_PAGE_OPEN' &&
|
|
131
|
+
toPathObj.query
|
|
132
|
+
) {
|
|
133
|
+
// 新页签打开菜单
|
|
134
|
+
let url = toPathObj.query.src
|
|
135
|
+
if (url && url.indexOf('?') > 0) {
|
|
136
|
+
url += '&'
|
|
137
|
+
} else {
|
|
138
|
+
url += '?'
|
|
139
|
+
}
|
|
140
|
+
if (toPathObj.query.customSystem) {
|
|
141
|
+
url += 'customSystem=' + toPathObj.query.customSystem
|
|
142
|
+
}
|
|
143
|
+
if (toPathObj.query._menuCode) {
|
|
144
|
+
url += '_menuCode=' + toPathObj.query._menuCode
|
|
145
|
+
}
|
|
146
|
+
if (toPathObj.query._menuCode) {
|
|
147
|
+
url += '_menuName=' + toPathObj.query._menuName
|
|
148
|
+
}
|
|
149
|
+
window.open(url, toPathObj.query._menuCode)
|
|
150
|
+
} else {
|
|
151
|
+
// 刷新页签打开菜单
|
|
152
|
+
this.addTabs(
|
|
153
|
+
toPathObj.query,
|
|
154
|
+
this.$store.state.tabContent.openTab,
|
|
155
|
+
toPathObj.tabPath
|
|
156
|
+
)
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
getI18nName(menu) {
|
|
160
|
+
return getI18nName(menu)
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
}
|
|
164
|
+
</script>
|
|
@@ -1,135 +1,135 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div v-if="!item.hidden && item.children" class="menu-wrapper">
|
|
3
|
-
<template
|
|
4
|
-
v-if="
|
|
5
|
-
hasOneShowingChild(item.children, item) &&
|
|
6
|
-
(!onlyOneChild.children || onlyOneChild.noShowingChildren) &&
|
|
7
|
-
!item.alwaysShow
|
|
8
|
-
"
|
|
9
|
-
>
|
|
10
|
-
<app-link :to="resolvePath(onlyOneChild.path)">
|
|
11
|
-
<el-menu-item
|
|
12
|
-
:index="
|
|
13
|
-
resolvePath(onlyOneChild.path) + '~~' + onlyOneChild.meta.title
|
|
14
|
-
"
|
|
15
|
-
:class="{ 'submenu-title-noDropdown': !isNest }"
|
|
16
|
-
>
|
|
17
|
-
<item
|
|
18
|
-
v-if="onlyOneChild.meta"
|
|
19
|
-
:icon="onlyOneChild.meta.icon || item.meta.icon"
|
|
20
|
-
:title="$t(onlyOneChild.meta.title)"
|
|
21
|
-
/>
|
|
22
|
-
</el-menu-item>
|
|
23
|
-
</app-link>
|
|
24
|
-
</template>
|
|
25
|
-
|
|
26
|
-
<el-sub-menu
|
|
27
|
-
v-else
|
|
28
|
-
:index="resolvePath(item.path) + '~~' + item.meta.title"
|
|
29
|
-
>
|
|
30
|
-
<template v-slot:title>
|
|
31
|
-
<item
|
|
32
|
-
v-if="item.meta"
|
|
33
|
-
:icon="item.meta.icon"
|
|
34
|
-
:title="$t(item.meta.title)"
|
|
35
|
-
:has-children="item.children.length > 0 ? true : false"
|
|
36
|
-
/>
|
|
37
|
-
</template>
|
|
38
|
-
|
|
39
|
-
<template v-for="child in visibleChildren">
|
|
40
|
-
<sidebar-item
|
|
41
|
-
v-if="child.children && child.children.length > 0"
|
|
42
|
-
:is-nest="true"
|
|
43
|
-
:item="child"
|
|
44
|
-
:base-path="resolvePath(child.path)"
|
|
45
|
-
class="nest-menu"
|
|
46
|
-
/>
|
|
47
|
-
<app-link v-else :to="resolvePath(child.path)">
|
|
48
|
-
<el-menu-item
|
|
49
|
-
:index="resolvePath(child.path) + '~~' + child.meta.title"
|
|
50
|
-
>
|
|
51
|
-
<item
|
|
52
|
-
v-if="child.meta"
|
|
53
|
-
:icon="child.meta.icon"
|
|
54
|
-
:title="$t(child.meta.title)"
|
|
55
|
-
/>
|
|
56
|
-
</el-menu-item>
|
|
57
|
-
</app-link>
|
|
58
|
-
</template>
|
|
59
|
-
</el-sub-menu>
|
|
60
|
-
</div>
|
|
61
|
-
</template>
|
|
62
|
-
|
|
63
|
-
<script>
|
|
64
|
-
import path from 'path'
|
|
65
|
-
import { isExternal } from '../../../../utils'
|
|
66
|
-
import Item from './Item.vue'
|
|
67
|
-
import AppLink from './Link.vue'
|
|
68
|
-
|
|
69
|
-
export default {
|
|
70
|
-
name: 'SidebarItem',
|
|
71
|
-
components: { Item, AppLink },
|
|
72
|
-
props: {
|
|
73
|
-
// route object
|
|
74
|
-
item: {
|
|
75
|
-
type: Object,
|
|
76
|
-
required: true,
|
|
77
|
-
},
|
|
78
|
-
isNest: {
|
|
79
|
-
type: Boolean,
|
|
80
|
-
default: false,
|
|
81
|
-
},
|
|
82
|
-
basePath: {
|
|
83
|
-
type: String,
|
|
84
|
-
default: '',
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
data() {
|
|
88
|
-
return {
|
|
89
|
-
onlyOneChild: null,
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
computed: {
|
|
93
|
-
visibleChildren() {
|
|
94
|
-
return this.item.children.filter((child) => {
|
|
95
|
-
return !child.hidden
|
|
96
|
-
})
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
methods: {
|
|
100
|
-
hasOneShowingChild(children, parent) {
|
|
101
|
-
const showingChildren = children.filter((item) => {
|
|
102
|
-
if (item.hidden) {
|
|
103
|
-
return false
|
|
104
|
-
} else {
|
|
105
|
-
// Temp set(will be used if only has one showing child)
|
|
106
|
-
this.onlyOneChild = item
|
|
107
|
-
return true
|
|
108
|
-
}
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
// When there is only one child router, the child router is displayed by default
|
|
112
|
-
if (showingChildren.length === 1) {
|
|
113
|
-
return true
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// Show parent if there are no child router to display
|
|
117
|
-
if (showingChildren.length === 0) {
|
|
118
|
-
this.onlyOneChild = { ...parent, path: '', noShowingChildren: true }
|
|
119
|
-
return true
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return false
|
|
123
|
-
},
|
|
124
|
-
resolvePath(routePath) {
|
|
125
|
-
if (this.isExternalLink(routePath)) {
|
|
126
|
-
return routePath
|
|
127
|
-
}
|
|
128
|
-
return path.resolve(this.basePath, routePath)
|
|
129
|
-
},
|
|
130
|
-
isExternalLink(routePath) {
|
|
131
|
-
return isExternal(routePath)
|
|
132
|
-
},
|
|
133
|
-
},
|
|
134
|
-
}
|
|
135
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<div v-if="!item.hidden && item.children" class="menu-wrapper">
|
|
3
|
+
<template
|
|
4
|
+
v-if="
|
|
5
|
+
hasOneShowingChild(item.children, item) &&
|
|
6
|
+
(!onlyOneChild.children || onlyOneChild.noShowingChildren) &&
|
|
7
|
+
!item.alwaysShow
|
|
8
|
+
"
|
|
9
|
+
>
|
|
10
|
+
<app-link :to="resolvePath(onlyOneChild.path)">
|
|
11
|
+
<el-menu-item
|
|
12
|
+
:index="
|
|
13
|
+
resolvePath(onlyOneChild.path) + '~~' + onlyOneChild.meta.title
|
|
14
|
+
"
|
|
15
|
+
:class="{ 'submenu-title-noDropdown': !isNest }"
|
|
16
|
+
>
|
|
17
|
+
<item
|
|
18
|
+
v-if="onlyOneChild.meta"
|
|
19
|
+
:icon="onlyOneChild.meta.icon || item.meta.icon"
|
|
20
|
+
:title="$t(onlyOneChild.meta.title)"
|
|
21
|
+
/>
|
|
22
|
+
</el-menu-item>
|
|
23
|
+
</app-link>
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
<el-sub-menu
|
|
27
|
+
v-else
|
|
28
|
+
:index="resolvePath(item.path) + '~~' + item.meta.title"
|
|
29
|
+
>
|
|
30
|
+
<template v-slot:title>
|
|
31
|
+
<item
|
|
32
|
+
v-if="item.meta"
|
|
33
|
+
:icon="item.meta.icon"
|
|
34
|
+
:title="$t(item.meta.title)"
|
|
35
|
+
:has-children="item.children.length > 0 ? true : false"
|
|
36
|
+
/>
|
|
37
|
+
</template>
|
|
38
|
+
|
|
39
|
+
<template v-for="child in visibleChildren">
|
|
40
|
+
<sidebar-item
|
|
41
|
+
v-if="child.children && child.children.length > 0"
|
|
42
|
+
:is-nest="true"
|
|
43
|
+
:item="child"
|
|
44
|
+
:base-path="resolvePath(child.path)"
|
|
45
|
+
class="nest-menu"
|
|
46
|
+
/>
|
|
47
|
+
<app-link v-else :to="resolvePath(child.path)">
|
|
48
|
+
<el-menu-item
|
|
49
|
+
:index="resolvePath(child.path) + '~~' + child.meta.title"
|
|
50
|
+
>
|
|
51
|
+
<item
|
|
52
|
+
v-if="child.meta"
|
|
53
|
+
:icon="child.meta.icon"
|
|
54
|
+
:title="$t(child.meta.title)"
|
|
55
|
+
/>
|
|
56
|
+
</el-menu-item>
|
|
57
|
+
</app-link>
|
|
58
|
+
</template>
|
|
59
|
+
</el-sub-menu>
|
|
60
|
+
</div>
|
|
61
|
+
</template>
|
|
62
|
+
|
|
63
|
+
<script>
|
|
64
|
+
import path from 'path'
|
|
65
|
+
import { isExternal } from '../../../../utils'
|
|
66
|
+
import Item from './Item.vue'
|
|
67
|
+
import AppLink from './Link.vue'
|
|
68
|
+
|
|
69
|
+
export default {
|
|
70
|
+
name: 'SidebarItem',
|
|
71
|
+
components: { Item, AppLink },
|
|
72
|
+
props: {
|
|
73
|
+
// route object
|
|
74
|
+
item: {
|
|
75
|
+
type: Object,
|
|
76
|
+
required: true,
|
|
77
|
+
},
|
|
78
|
+
isNest: {
|
|
79
|
+
type: Boolean,
|
|
80
|
+
default: false,
|
|
81
|
+
},
|
|
82
|
+
basePath: {
|
|
83
|
+
type: String,
|
|
84
|
+
default: '',
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
data() {
|
|
88
|
+
return {
|
|
89
|
+
onlyOneChild: null,
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
computed: {
|
|
93
|
+
visibleChildren() {
|
|
94
|
+
return this.item.children.filter((child) => {
|
|
95
|
+
return !child.hidden
|
|
96
|
+
})
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
methods: {
|
|
100
|
+
hasOneShowingChild(children, parent) {
|
|
101
|
+
const showingChildren = children.filter((item) => {
|
|
102
|
+
if (item.hidden) {
|
|
103
|
+
return false
|
|
104
|
+
} else {
|
|
105
|
+
// Temp set(will be used if only has one showing child)
|
|
106
|
+
this.onlyOneChild = item
|
|
107
|
+
return true
|
|
108
|
+
}
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
// When there is only one child router, the child router is displayed by default
|
|
112
|
+
if (showingChildren.length === 1) {
|
|
113
|
+
return true
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Show parent if there are no child router to display
|
|
117
|
+
if (showingChildren.length === 0) {
|
|
118
|
+
this.onlyOneChild = { ...parent, path: '', noShowingChildren: true }
|
|
119
|
+
return true
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return false
|
|
123
|
+
},
|
|
124
|
+
resolvePath(routePath) {
|
|
125
|
+
if (this.isExternalLink(routePath)) {
|
|
126
|
+
return routePath
|
|
127
|
+
}
|
|
128
|
+
return path.resolve(this.basePath, routePath)
|
|
129
|
+
},
|
|
130
|
+
isExternalLink(routePath) {
|
|
131
|
+
return isExternal(routePath)
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
}
|
|
135
|
+
</script>
|