sh-view 2.8.0 → 2.8.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/.eslintrc.js +25 -20
- package/other.js +8 -8
- package/package.json +9 -6
- package/packages/components/index.js +91 -91
- package/packages/components/sh-alert/alert.ts +30 -0
- package/packages/components/sh-alert/index.vue +143 -168
- package/packages/components/sh-badge/index.vue +242 -242
- package/packages/components/sh-calendar/index.vue +650 -650
- package/packages/components/sh-card/index.vue +148 -148
- package/packages/components/sh-code-editor/index.vue +19 -19
- package/packages/components/sh-col/index.vue +92 -92
- package/packages/components/sh-corner/index.vue +230 -230
- package/packages/components/sh-count-to/index.vue +131 -131
- package/packages/components/sh-date/index.vue +301 -301
- package/packages/components/sh-drawer/index.vue +579 -579
- package/packages/components/sh-drawer/scrollbar.js +78 -78
- package/packages/components/sh-empty/index.vue +42 -42
- package/packages/components/sh-form/js/props.js +76 -76
- package/packages/components/sh-form/js/useForm.js +229 -229
- package/packages/components/sh-header/index.vue +261 -260
- package/packages/components/sh-icon/css/default/ionicons.svg +869 -869
- package/packages/components/sh-icon/css/font/iconfont.json +247 -247
- package/packages/components/sh-icon/index.vue +41 -41
- package/packages/components/sh-image/index.vue +133 -133
- package/packages/components/sh-list/index.vue +146 -146
- package/packages/components/sh-loading/index.vue +53 -53
- package/packages/components/sh-modal/index.vue +188 -188
- package/packages/components/sh-noticebar/index.vue +215 -215
- package/packages/components/sh-poptip/index.vue +597 -597
- package/packages/components/sh-progress/index.vue +276 -276
- package/packages/components/sh-pull-refresh/index.vue +289 -289
- package/packages/components/sh-result/index.vue +114 -114
- package/packages/components/sh-row/index.vue +66 -66
- package/packages/components/sh-split/components/trigger.vue +33 -33
- package/packages/components/sh-split/index.vue +342 -342
- package/packages/components/sh-table/components/importModal.vue +363 -363
- package/packages/components/sh-table/components/sh-column.vue +68 -68
- package/packages/components/sh-table/js/excel_to_json.js +313 -313
- package/packages/components/sh-table/js/props.js +305 -305
- package/packages/components/sh-table/js/tableMethods.js +167 -167
- package/packages/components/sh-table/js/useTable.js +636 -636
- package/packages/components/sh-table/table.vue +217 -217
- package/packages/components/sh-tabs/index.vue +426 -426
- package/packages/components/sh-tag/index.vue +168 -168
- package/packages/components/sh-toolbar/index.vue +182 -182
- package/packages/components/sh-tree/components/table-tree.vue +289 -289
- package/packages/components/sh-tree/mixin/treeProps.js +122 -122
- package/packages/components/sh-upload/index.vue +535 -535
- package/packages/components/sh-water-fall/index.vue +80 -80
- package/packages/components/sh-water-mark/index.vue +96 -96
- package/packages/css/index.js +4 -4
- package/packages/directive/index.js +19 -19
- package/packages/directive/module/click-out.js +14 -14
- package/packages/directive/module/draggable.js +42 -42
- package/packages/directive/module/line-clamp.js +22 -22
- package/packages/directive/module/prevent-click.js +18 -18
- package/packages/directive/module/resize.js +14 -14
- package/packages/directive/module/ripple.js +166 -166
- package/packages/index.js +39 -39
- package/packages/mixin/index.js +86 -86
- package/packages/other/sh-cron-modal/components/cron-content.vue +294 -294
- package/packages/other/sh-cron-modal/index.vue +81 -81
- package/packages/other/sh-cron-modal/mixin/cron-emits.js +1 -1
- package/packages/other/sh-cron-modal/mixin/cron-props.js +9 -9
- package/packages/other/sh-cron-modal/tabs/cron-week-box.vue +126 -126
- package/packages/other/sh-menu/index.vue +326 -326
- package/packages/other/sh-menu/menu-group-content.vue +136 -136
- package/packages/other/sh-menu/menu-item-content.vue +71 -71
- package/packages/other/sh-menu-card/index.vue +250 -250
- package/packages/other/sh-menu-card/menu-box.vue +87 -87
- package/packages/other/sh-preview/components/sh-excel.vue +163 -163
- package/packages/other/sh-preview/js/data-hook.js +41 -41
- package/packages/other/sh-preview/js/data-props.js +15 -15
- package/packages/other/sh-system-tip/index.vue +115 -115
- package/packages/utils/resize.js +69 -70
- package/packages/utils/transfer-queue.js +12 -12
- package/packages/vxeTable/index.js +193 -184
- package/packages/vxeTable/plugins/export.js +450 -450
- package/packages/vxeTable/render/cell/vxe-render-img.vue +27 -27
- package/packages/vxeTable/render/cell/vxe-render-table.vue +51 -51
- package/packages/vxeTable/render/cell/vxe-render-time.vue +44 -44
- package/packages/vxeTable/render/cell/vxe-render-tree.vue +70 -70
- package/packages/vxeTable/render/filters/vxe-filter-input.vue +26 -26
- package/packages/vxeTable/render/filters/vxe-filter-time.vue +26 -26
- package/packages/vxeTable/render/globalRenders.jsx +514 -514
- package/packages/vxeTable/render/mixin/cell-hooks.js +198 -198
- package/packages/vxeTable/render/mixin/cell-props.js +23 -23
- package/packages/vxeTable/render/mixin/filter-hooks.js +46 -46
- package/tsconfig.json +25 -0
- package/types/component.d.ts +1 -0
- package/types/index.ts +0 -0
|
@@ -1,136 +1,136 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div v-if="showChildren(menuItem)" class="sh-menu-group" :class="groupClass">
|
|
3
|
-
<menuItemContent ref="groupItemRef" :menu-item="menuItem" :menu-level="menuLevel" :arrow="isArrow" @click="onMenuExpand(!expand)" />
|
|
4
|
-
<div v-show="expand" ref="groupListRef" class="sh-menu-group-list" :class="groupListClass" :style="groupListStyle">
|
|
5
|
-
<template v-for="(item, index) in menuItem.children" :key="`sh-menu-${menuLevel}-${index}`">
|
|
6
|
-
<menuGroupContent :menu-item="item" :menu-level="menuNextLevel" />
|
|
7
|
-
</template>
|
|
8
|
-
</div>
|
|
9
|
-
</div>
|
|
10
|
-
<template v-else>
|
|
11
|
-
<menuItemContent :menu-item="menuItem" :menu-level="menuLevel" @click.stop="onMenuClick" />
|
|
12
|
-
</template>
|
|
13
|
-
</template>
|
|
14
|
-
|
|
15
|
-
<script>
|
|
16
|
-
import { defineComponent, computed, getCurrentInstance, ref, watch, onMounted, inject, nextTick } from 'vue'
|
|
17
|
-
import menuItemContent from './menu-item-content.vue'
|
|
18
|
-
export default defineComponent({
|
|
19
|
-
name: 'MenuGroupContent',
|
|
20
|
-
components: {
|
|
21
|
-
menuItemContent
|
|
22
|
-
},
|
|
23
|
-
props: {
|
|
24
|
-
menuLevel: {
|
|
25
|
-
type: Number,
|
|
26
|
-
default: 0
|
|
27
|
-
},
|
|
28
|
-
menuItem: {
|
|
29
|
-
type: Object,
|
|
30
|
-
default() {
|
|
31
|
-
return {}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
setup(props, context) {
|
|
36
|
-
const { proxy } = getCurrentInstance()
|
|
37
|
-
const { $vUtils } = proxy
|
|
38
|
-
const { emit, slots } = context
|
|
39
|
-
const MenuInstance = inject('MenuInstance')
|
|
40
|
-
|
|
41
|
-
const groupItemRef = ref()
|
|
42
|
-
const groupListRef = ref()
|
|
43
|
-
const expand = ref(false)
|
|
44
|
-
const groupListStyle = ref({})
|
|
45
|
-
|
|
46
|
-
const menuNextLevel = computed(() => props.menuLevel + 1)
|
|
47
|
-
const isArrow = computed(() => {
|
|
48
|
-
return MenuInstance.props.collapsed ? !!props.menuLevel : true
|
|
49
|
-
})
|
|
50
|
-
const groupClass = computed(() => {
|
|
51
|
-
return {
|
|
52
|
-
is__level: !props.menuLevel,
|
|
53
|
-
is__active: MenuInstance.activeNames.includes(props.menuItem.name),
|
|
54
|
-
is__expand: expand.value
|
|
55
|
-
}
|
|
56
|
-
})
|
|
57
|
-
const groupListClass = computed(() => {
|
|
58
|
-
const { mode, collapsed } = MenuInstance.props
|
|
59
|
-
return {
|
|
60
|
-
'sh-menu-group-dropdown': mode === 'horizontal',
|
|
61
|
-
'sh-menu-group-dropright': mode === 'vertical' && collapsed
|
|
62
|
-
}
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
const setMenuExpand = () => {
|
|
66
|
-
const { mode, collapsed } = MenuInstance.props
|
|
67
|
-
expand.value = MenuInstance.openedNames.includes(props.menuItem.name)
|
|
68
|
-
if (expand.value && groupItemRef.value && ((mode === 'vertical' && collapsed) || mode === 'horizontal')) {
|
|
69
|
-
nextTick(() => {
|
|
70
|
-
const { offsetHeight, offsetWidth } = groupListRef.value
|
|
71
|
-
const { itemRef } = groupItemRef.value
|
|
72
|
-
const { left, right, top, bottom } = itemRef.getBoundingClientRect()
|
|
73
|
-
const winWidth = window.innerWidth
|
|
74
|
-
const winHeight = window.innerHeight
|
|
75
|
-
if (mode === 'vertical') {
|
|
76
|
-
let groupStyle = { left: `${right}px` }
|
|
77
|
-
if (offsetHeight >= winHeight) {
|
|
78
|
-
groupStyle.top = '10px'
|
|
79
|
-
groupStyle.bottom = '10px'
|
|
80
|
-
} else if (top + offsetHeight >= winHeight) {
|
|
81
|
-
groupStyle.bottom = '10px'
|
|
82
|
-
} else {
|
|
83
|
-
groupStyle.top = `${top}px`
|
|
84
|
-
}
|
|
85
|
-
groupListStyle.value = groupStyle
|
|
86
|
-
} else {
|
|
87
|
-
let groupStyle = { top: `${props.menuLevel ? top : bottom}px` }
|
|
88
|
-
if (right + offsetWidth >= winWidth) {
|
|
89
|
-
groupStyle.right = '10px'
|
|
90
|
-
} else {
|
|
91
|
-
groupStyle.left = `${props.menuLevel ? right : left}px`
|
|
92
|
-
}
|
|
93
|
-
groupListStyle.value = groupStyle
|
|
94
|
-
}
|
|
95
|
-
})
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
const showChildren = item => {
|
|
99
|
-
return item.children && item.children.length > 0
|
|
100
|
-
}
|
|
101
|
-
const onMenuClick = () => {
|
|
102
|
-
MenuInstance.onMenuSelect(props.menuItem)
|
|
103
|
-
}
|
|
104
|
-
const onMenuExpand = value => {
|
|
105
|
-
MenuInstance.onMenuExpand(value, props.menuItem)
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
watch(
|
|
109
|
-
() => MenuInstance.openedNames,
|
|
110
|
-
() => {
|
|
111
|
-
setMenuExpand()
|
|
112
|
-
}
|
|
113
|
-
)
|
|
114
|
-
|
|
115
|
-
onMounted(() => {
|
|
116
|
-
setMenuExpand()
|
|
117
|
-
})
|
|
118
|
-
|
|
119
|
-
return {
|
|
120
|
-
groupItemRef,
|
|
121
|
-
groupListRef,
|
|
122
|
-
groupClass,
|
|
123
|
-
groupListClass,
|
|
124
|
-
groupListStyle,
|
|
125
|
-
isArrow,
|
|
126
|
-
expand,
|
|
127
|
-
menuNextLevel,
|
|
128
|
-
showChildren,
|
|
129
|
-
onMenuExpand,
|
|
130
|
-
onMenuClick
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
})
|
|
134
|
-
</script>
|
|
135
|
-
|
|
136
|
-
<style scoped></style>
|
|
1
|
+
<template>
|
|
2
|
+
<div v-if="showChildren(menuItem)" class="sh-menu-group" :class="groupClass">
|
|
3
|
+
<menuItemContent ref="groupItemRef" :menu-item="menuItem" :menu-level="menuLevel" :arrow="isArrow" @click="onMenuExpand(!expand)" />
|
|
4
|
+
<div v-show="expand" ref="groupListRef" class="sh-menu-group-list" :class="groupListClass" :style="groupListStyle">
|
|
5
|
+
<template v-for="(item, index) in menuItem.children" :key="`sh-menu-${menuLevel}-${index}`">
|
|
6
|
+
<menuGroupContent :menu-item="item" :menu-level="menuNextLevel" />
|
|
7
|
+
</template>
|
|
8
|
+
</div>
|
|
9
|
+
</div>
|
|
10
|
+
<template v-else>
|
|
11
|
+
<menuItemContent :menu-item="menuItem" :menu-level="menuLevel" @click.stop="onMenuClick" />
|
|
12
|
+
</template>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script>
|
|
16
|
+
import { defineComponent, computed, getCurrentInstance, ref, watch, onMounted, inject, nextTick } from 'vue'
|
|
17
|
+
import menuItemContent from './menu-item-content.vue'
|
|
18
|
+
export default defineComponent({
|
|
19
|
+
name: 'MenuGroupContent',
|
|
20
|
+
components: {
|
|
21
|
+
menuItemContent
|
|
22
|
+
},
|
|
23
|
+
props: {
|
|
24
|
+
menuLevel: {
|
|
25
|
+
type: Number,
|
|
26
|
+
default: 0
|
|
27
|
+
},
|
|
28
|
+
menuItem: {
|
|
29
|
+
type: Object,
|
|
30
|
+
default() {
|
|
31
|
+
return {}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
setup(props, context) {
|
|
36
|
+
const { proxy } = getCurrentInstance()
|
|
37
|
+
const { $vUtils } = proxy
|
|
38
|
+
const { emit, slots } = context
|
|
39
|
+
const MenuInstance = inject('MenuInstance')
|
|
40
|
+
|
|
41
|
+
const groupItemRef = ref()
|
|
42
|
+
const groupListRef = ref()
|
|
43
|
+
const expand = ref(false)
|
|
44
|
+
const groupListStyle = ref({})
|
|
45
|
+
|
|
46
|
+
const menuNextLevel = computed(() => props.menuLevel + 1)
|
|
47
|
+
const isArrow = computed(() => {
|
|
48
|
+
return MenuInstance.props.collapsed ? !!props.menuLevel : true
|
|
49
|
+
})
|
|
50
|
+
const groupClass = computed(() => {
|
|
51
|
+
return {
|
|
52
|
+
is__level: !props.menuLevel,
|
|
53
|
+
is__active: MenuInstance.activeNames.includes(props.menuItem.name),
|
|
54
|
+
is__expand: expand.value
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
const groupListClass = computed(() => {
|
|
58
|
+
const { mode, collapsed } = MenuInstance.props
|
|
59
|
+
return {
|
|
60
|
+
'sh-menu-group-dropdown': mode === 'horizontal',
|
|
61
|
+
'sh-menu-group-dropright': mode === 'vertical' && collapsed
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
const setMenuExpand = () => {
|
|
66
|
+
const { mode, collapsed } = MenuInstance.props
|
|
67
|
+
expand.value = MenuInstance.openedNames.includes(props.menuItem.name)
|
|
68
|
+
if (expand.value && groupItemRef.value && ((mode === 'vertical' && collapsed) || mode === 'horizontal')) {
|
|
69
|
+
nextTick(() => {
|
|
70
|
+
const { offsetHeight, offsetWidth } = groupListRef.value
|
|
71
|
+
const { itemRef } = groupItemRef.value
|
|
72
|
+
const { left, right, top, bottom } = itemRef.getBoundingClientRect()
|
|
73
|
+
const winWidth = window.innerWidth
|
|
74
|
+
const winHeight = window.innerHeight
|
|
75
|
+
if (mode === 'vertical') {
|
|
76
|
+
let groupStyle = { left: `${right}px` }
|
|
77
|
+
if (offsetHeight >= winHeight) {
|
|
78
|
+
groupStyle.top = '10px'
|
|
79
|
+
groupStyle.bottom = '10px'
|
|
80
|
+
} else if (top + offsetHeight >= winHeight) {
|
|
81
|
+
groupStyle.bottom = '10px'
|
|
82
|
+
} else {
|
|
83
|
+
groupStyle.top = `${top}px`
|
|
84
|
+
}
|
|
85
|
+
groupListStyle.value = groupStyle
|
|
86
|
+
} else {
|
|
87
|
+
let groupStyle = { top: `${props.menuLevel ? top : bottom}px` }
|
|
88
|
+
if (right + offsetWidth >= winWidth) {
|
|
89
|
+
groupStyle.right = '10px'
|
|
90
|
+
} else {
|
|
91
|
+
groupStyle.left = `${props.menuLevel ? right : left}px`
|
|
92
|
+
}
|
|
93
|
+
groupListStyle.value = groupStyle
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const showChildren = item => {
|
|
99
|
+
return item.children && item.children.length > 0
|
|
100
|
+
}
|
|
101
|
+
const onMenuClick = () => {
|
|
102
|
+
MenuInstance.onMenuSelect(props.menuItem)
|
|
103
|
+
}
|
|
104
|
+
const onMenuExpand = value => {
|
|
105
|
+
MenuInstance.onMenuExpand(value, props.menuItem)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
watch(
|
|
109
|
+
() => MenuInstance.openedNames,
|
|
110
|
+
() => {
|
|
111
|
+
setMenuExpand()
|
|
112
|
+
}
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
onMounted(() => {
|
|
116
|
+
setMenuExpand()
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
return {
|
|
120
|
+
groupItemRef,
|
|
121
|
+
groupListRef,
|
|
122
|
+
groupClass,
|
|
123
|
+
groupListClass,
|
|
124
|
+
groupListStyle,
|
|
125
|
+
isArrow,
|
|
126
|
+
expand,
|
|
127
|
+
menuNextLevel,
|
|
128
|
+
showChildren,
|
|
129
|
+
onMenuExpand,
|
|
130
|
+
onMenuClick
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
})
|
|
134
|
+
</script>
|
|
135
|
+
|
|
136
|
+
<style scoped></style>
|
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div ref="itemRef" class="sh-menu-item" :class="itemClass" :style="itemStyle">
|
|
3
|
-
<sh-icon v-if="iconType" class="sh-menu-item-icon" :type="iconType"></sh-icon>
|
|
4
|
-
<span class="sh-menu-item-title">{{ itemTitle }}</span>
|
|
5
|
-
<sh-icon v-if="arrow" class="sh-menu-item-arrow" type="ios-arrow-forward"></sh-icon>
|
|
6
|
-
</div>
|
|
7
|
-
</template>
|
|
8
|
-
|
|
9
|
-
<script>
|
|
10
|
-
import { defineComponent, computed, getCurrentInstance, ref, inject } from 'vue'
|
|
11
|
-
export default defineComponent({
|
|
12
|
-
name: 'MenuItemBox',
|
|
13
|
-
props: {
|
|
14
|
-
arrow: Boolean,
|
|
15
|
-
menuLevel: {
|
|
16
|
-
type: Number
|
|
17
|
-
},
|
|
18
|
-
menuItem: {
|
|
19
|
-
type: Object,
|
|
20
|
-
default() {
|
|
21
|
-
return {}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
setup(props, context) {
|
|
26
|
-
const { proxy } = getCurrentInstance()
|
|
27
|
-
const { $vUtils } = proxy
|
|
28
|
-
const { emit, slots } = context
|
|
29
|
-
const MenuInstance = inject('MenuInstance')
|
|
30
|
-
|
|
31
|
-
const itemRef = ref()
|
|
32
|
-
|
|
33
|
-
const defaultIcon = computed(() => {
|
|
34
|
-
if (MenuInstance.props.defaultIcon && (!props.menuLevel || props.menuLevel < 1)) return 'md-folder'
|
|
35
|
-
else if (MenuInstance.props.defaultIcon && props.menuLevel === 1) return 'md-bookmark'
|
|
36
|
-
return ''
|
|
37
|
-
})
|
|
38
|
-
const iconType = computed(() => {
|
|
39
|
-
return props.menuItem.meta?.icon || props.menuItem.icon || defaultIcon.value
|
|
40
|
-
})
|
|
41
|
-
const itemClass = computed(() => {
|
|
42
|
-
return {
|
|
43
|
-
'sh-menu-item-level': !props.menuLevel,
|
|
44
|
-
'sh-menu-item-active': MenuInstance.activeName === props.menuItem.name
|
|
45
|
-
}
|
|
46
|
-
})
|
|
47
|
-
const itemStyle = computed(() => {
|
|
48
|
-
let result = {}
|
|
49
|
-
const { mode, collapsed, indent } = MenuInstance.props
|
|
50
|
-
if (mode === 'vertical' && !collapsed && props.menuLevel) {
|
|
51
|
-
result.paddingLeft = `${indent * props.menuLevel}px`
|
|
52
|
-
}
|
|
53
|
-
return result
|
|
54
|
-
})
|
|
55
|
-
const itemTitle = computed(() => {
|
|
56
|
-
const { labelField, labelFormat } = MenuInstance.props
|
|
57
|
-
return labelFormat ? labelFormat(props.menuItem) : $vUtils.get(props.menuItem, labelField)
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
return {
|
|
61
|
-
itemRef,
|
|
62
|
-
itemClass,
|
|
63
|
-
itemStyle,
|
|
64
|
-
itemTitle,
|
|
65
|
-
iconType
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
})
|
|
69
|
-
</script>
|
|
70
|
-
|
|
71
|
-
<style scoped></style>
|
|
1
|
+
<template>
|
|
2
|
+
<div ref="itemRef" class="sh-menu-item" :class="itemClass" :style="itemStyle">
|
|
3
|
+
<sh-icon v-if="iconType" class="sh-menu-item-icon" :type="iconType"></sh-icon>
|
|
4
|
+
<span class="sh-menu-item-title">{{ itemTitle }}</span>
|
|
5
|
+
<sh-icon v-if="arrow" class="sh-menu-item-arrow" type="ios-arrow-forward"></sh-icon>
|
|
6
|
+
</div>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script>
|
|
10
|
+
import { defineComponent, computed, getCurrentInstance, ref, inject } from 'vue'
|
|
11
|
+
export default defineComponent({
|
|
12
|
+
name: 'MenuItemBox',
|
|
13
|
+
props: {
|
|
14
|
+
arrow: Boolean,
|
|
15
|
+
menuLevel: {
|
|
16
|
+
type: Number
|
|
17
|
+
},
|
|
18
|
+
menuItem: {
|
|
19
|
+
type: Object,
|
|
20
|
+
default() {
|
|
21
|
+
return {}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
setup(props, context) {
|
|
26
|
+
const { proxy } = getCurrentInstance()
|
|
27
|
+
const { $vUtils } = proxy
|
|
28
|
+
const { emit, slots } = context
|
|
29
|
+
const MenuInstance = inject('MenuInstance')
|
|
30
|
+
|
|
31
|
+
const itemRef = ref()
|
|
32
|
+
|
|
33
|
+
const defaultIcon = computed(() => {
|
|
34
|
+
if (MenuInstance.props.defaultIcon && (!props.menuLevel || props.menuLevel < 1)) return 'md-folder'
|
|
35
|
+
else if (MenuInstance.props.defaultIcon && props.menuLevel === 1) return 'md-bookmark'
|
|
36
|
+
return ''
|
|
37
|
+
})
|
|
38
|
+
const iconType = computed(() => {
|
|
39
|
+
return props.menuItem.meta?.icon || props.menuItem.icon || defaultIcon.value
|
|
40
|
+
})
|
|
41
|
+
const itemClass = computed(() => {
|
|
42
|
+
return {
|
|
43
|
+
'sh-menu-item-level': !props.menuLevel,
|
|
44
|
+
'sh-menu-item-active': MenuInstance.activeName === props.menuItem.name
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
const itemStyle = computed(() => {
|
|
48
|
+
let result = {}
|
|
49
|
+
const { mode, collapsed, indent } = MenuInstance.props
|
|
50
|
+
if (mode === 'vertical' && !collapsed && props.menuLevel) {
|
|
51
|
+
result.paddingLeft = `${indent * props.menuLevel}px`
|
|
52
|
+
}
|
|
53
|
+
return result
|
|
54
|
+
})
|
|
55
|
+
const itemTitle = computed(() => {
|
|
56
|
+
const { labelField, labelFormat } = MenuInstance.props
|
|
57
|
+
return labelFormat ? labelFormat(props.menuItem) : $vUtils.get(props.menuItem, labelField)
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
itemRef,
|
|
62
|
+
itemClass,
|
|
63
|
+
itemStyle,
|
|
64
|
+
itemTitle,
|
|
65
|
+
iconType
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
})
|
|
69
|
+
</script>
|
|
70
|
+
|
|
71
|
+
<style scoped></style>
|