2020-12-13 22:05:34 +08:00
|
|
|
<template>
|
|
|
|
|
<Dropdown :dropMenuList="getDropMenuList" :trigger="getTrigger" @menuEvent="handleMenuEvent">
|
|
|
|
|
<div :class="`${prefixCls}__info`" @contextmenu="handleContext" v-if="isTabs">
|
|
|
|
|
<span class="ml-1">{{ getTitle }}</span>
|
|
|
|
|
</div>
|
|
|
|
|
|
2020-12-15 00:13:23 +08:00
|
|
|
<span :class="`${prefixCls}__extra-quick`" v-else @click="handleContext">
|
2021-02-19 22:15:02 +08:00
|
|
|
<Icon icon="ion:chevron-down" />
|
2020-12-13 22:05:34 +08:00
|
|
|
</span>
|
|
|
|
|
</Dropdown>
|
|
|
|
|
</template>
|
|
|
|
|
<script lang="ts">
|
|
|
|
|
import type { PropType } from 'vue';
|
|
|
|
|
|
|
|
|
|
import { defineComponent, computed } from 'vue';
|
|
|
|
|
import { Dropdown } from '/@/components/Dropdown/index';
|
2021-02-13 11:15:06 +08:00
|
|
|
import Icon from '/@/components/Icon';
|
2020-12-13 22:05:34 +08:00
|
|
|
|
|
|
|
|
import { TabContentProps, TabContentEnum } from '../types';
|
|
|
|
|
|
|
|
|
|
import { useDesign } from '/@/hooks/web/useDesign';
|
|
|
|
|
import { useTabDropdown } from '../useTabDropdown';
|
|
|
|
|
import { useI18n } from '/@/hooks/web/useI18n';
|
|
|
|
|
|
|
|
|
|
import { RouteLocationNormalized } from 'vue-router';
|
|
|
|
|
export default defineComponent({
|
|
|
|
|
name: 'TabContent',
|
2021-02-19 22:15:02 +08:00
|
|
|
components: { Dropdown, Icon },
|
2020-12-13 22:05:34 +08:00
|
|
|
props: {
|
|
|
|
|
tabItem: {
|
|
|
|
|
type: Object as PropType<RouteLocationNormalized>,
|
|
|
|
|
default: null,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
type: {
|
|
|
|
|
type: Number as PropType<TabContentEnum>,
|
|
|
|
|
default: TabContentEnum.TAB_TYPE,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
setup(props) {
|
|
|
|
|
const { prefixCls } = useDesign('multiple-tabs-content');
|
|
|
|
|
const { t } = useI18n();
|
|
|
|
|
|
|
|
|
|
const getTitle = computed(() => {
|
|
|
|
|
const { tabItem: { meta } = {} } = props;
|
|
|
|
|
return meta && t(meta.title);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const {
|
|
|
|
|
getDropMenuList,
|
|
|
|
|
handleMenuEvent,
|
|
|
|
|
handleContextMenu,
|
|
|
|
|
getTrigger,
|
|
|
|
|
isTabs,
|
|
|
|
|
} = useTabDropdown(props as TabContentProps);
|
|
|
|
|
|
|
|
|
|
function handleContext(e: ChangeEvent) {
|
|
|
|
|
props.tabItem && handleContextMenu(props.tabItem)(e);
|
|
|
|
|
}
|
|
|
|
|
return {
|
|
|
|
|
prefixCls,
|
|
|
|
|
getDropMenuList,
|
|
|
|
|
handleMenuEvent,
|
|
|
|
|
handleContext,
|
|
|
|
|
getTrigger,
|
|
|
|
|
isTabs,
|
|
|
|
|
getTitle,
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
</script>
|