vben
authored
|
1
2
|
<template>
<Dropdown :dropMenuList="getDropMenuList" :trigger="getTrigger" @menuEvent="handleMenuEvent">
|
Vben
authored
|
3
|
<div :class="`${prefixCls}__info`" @contextmenu="handleContext" v-if="getIsTabs">
|
vben
authored
|
4
5
|
<span class="ml-1">{{ getTitle }}</span>
</div>
|
vben
authored
|
6
|
<span :class="`${prefixCls}__extra-quick`" v-else @click="handleContext">
|
vben
authored
|
7
|
<Icon icon="ion:chevron-down" />
|
vben
authored
|
8
9
10
11
12
|
</span>
</Dropdown>
</template>
<script lang="ts">
import type { PropType } from 'vue';
|
Vben
authored
|
13
|
import type { RouteLocationNormalized } from 'vue-router';
|
vben
authored
|
14
|
|
Vben
authored
|
15
|
import { defineComponent, computed, unref } from 'vue';
|
vben
authored
|
16
|
import { Dropdown } from '/@/components/Dropdown/index';
|
Vben
authored
|
17
|
import { Icon } from '/@/components/Icon';
|
vben
authored
|
18
|
|
Vben
authored
|
19
|
import { TabContentProps } from '../types';
|
vben
authored
|
20
21
22
|
import { useDesign } from '/@/hooks/web/useDesign';
import { useI18n } from '/@/hooks/web/useI18n';
|
Vben
authored
|
23
|
import { useTabDropdown } from '../useTabDropdown';
|
vben
authored
|
24
25
26
|
export default defineComponent({
name: 'TabContent',
|
vben
authored
|
27
|
components: { Dropdown, Icon },
|
vben
authored
|
28
29
30
31
32
|
props: {
tabItem: {
type: Object as PropType<RouteLocationNormalized>,
default: null,
},
|
Vben
authored
|
33
|
isExtra: Boolean,
|
vben
authored
|
34
35
36
37
38
39
40
|
},
setup(props) {
const { prefixCls } = useDesign('multiple-tabs-content');
const { t } = useI18n();
const getTitle = computed(() => {
const { tabItem: { meta } = {} } = props;
|
Vben
authored
|
41
|
return meta && t(meta.title as string);
|
vben
authored
|
42
43
|
});
|
Vben
authored
|
44
45
|
const getIsTabs = computed(() => !props.isExtra);
|
Vben
authored
|
46
47
48
|
const getTrigger = computed((): ('contextmenu' | 'click' | 'hover')[] =>
unref(getIsTabs) ? ['contextmenu'] : ['click']
);
|
vben
authored
|
49
|
|
Vben
authored
|
50
51
52
53
54
55
|
const { getDropMenuList, handleMenuEvent, handleContextMenu } = useTabDropdown(
props as TabContentProps,
getIsTabs
);
function handleContext(e) {
|
vben
authored
|
56
57
|
props.tabItem && handleContextMenu(props.tabItem)(e);
}
|
Vben
authored
|
58
|
|
vben
authored
|
59
60
61
62
63
64
|
return {
prefixCls,
getDropMenuList,
handleMenuEvent,
handleContext,
getTrigger,
|
Vben
authored
|
65
|
getIsTabs,
|
vben
authored
|
66
67
68
69
70
|
getTitle,
};
},
});
</script>
|