/
RightTop.vue
133 lines (125 loc) · 3.96 KB
/
RightTop.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<template>
<div id="indexlayout-right-top" :class="{'topNavEnable': !topNavEnable, 'tabNavEnable': !tabNavEnable }">
<div class="indexlayout-right-top-top">
<div class="indexlayout-flexible"
@click="() => {
if(toggleCollapsed) {
toggleCollapsed();
}
}"
>
<MenuUnfoldOutlined v-if="collapsed" />
<MenuFoldOutlined v-else />
</div>
<div class="indexlayout-top-menu">
<div ref="topMenuCon" :style="{width: topMenuWidth}">
<template v-if="topNavEnable">
<template v-for="(item, key) in menuData">
<a-link
:key="key"
v-if="!item.hidden"
:to="item.path"
:class="{'active': belongTopMenu === item.path }"
class="indexlayout-top-menu-li"
>
{{t(item.title)}}
</a-link>
</template>
</template>
<bread-crumbs v-else class="breadcrumb" :list="breadCrumbs"></bread-crumbs>
</div>
</div>
<div class="indexlayout-top-menu-right">
<right-top-message />
<right-top-user />
<select-lang class="indexlayout-top-selectlang" />
</div>
</div>
<div v-if="topNavEnable" class="indexlayout-right-top-bot">
<div class="indexlayout-right-top-bot-home">
<EnvironmentOutlined />
</div>
<bread-crumbs class="breadcrumb" :list="breadCrumbs"></bread-crumbs>
</div>
<right-tab-nav v-if="tabNavEnable" :routeItem="routeItem"></right-tab-nav>
</div>
</template>
<script lang="ts">
import { defineComponent, onMounted, PropType, Ref, toRefs } from "vue";
import { useI18n } from "vue-i18n";
import { MenuFoldOutlined, MenuUnfoldOutlined, EnvironmentOutlined } from '@ant-design/icons-vue';
import { BreadcrumbType, RoutesDataItem } from '@/utils/routes';
import BreadCrumbs from '@/components/BreadCrumbs/index.vue';
import SelectLang from '@/components/SelectLang/index.vue';
import ALink from '@/components/ALink/index.vue';
import RightTopMessage from './RightTopMessage.vue';
import RightTopUser from './RightTopUser.vue';
import RightTabNav from './RightTabNav.vue';
import useTopMenuWidth from "../composables/useTopMenuWidth";
interface RightTopSetupData {
t: (key: string | number) => string;
topMenuCon: Ref;
topMenuWidth: Ref;
}
export default defineComponent({
name: 'RightTop',
components: {
ALink,
BreadCrumbs,
MenuFoldOutlined,
MenuUnfoldOutlined,
EnvironmentOutlined,
RightTopMessage,
RightTopUser,
SelectLang,
RightTabNav,
},
props: {
collapsed: {
type: Boolean,
default: false
},
tabNavEnable: {
type: Boolean,
default: true
},
topNavEnable: {
type: Boolean,
default: true
},
belongTopMenu: {
type: String,
default: ''
},
toggleCollapsed: {
type: Function as PropType<() => void>
},
breadCrumbs: {
type: Array as PropType<BreadcrumbType[]>,
default: () => {
return [];
}
},
menuData: {
type: Array as PropType<RoutesDataItem[]>,
default: () => {
return [];
}
},
routeItem: {
type: Object as PropType<RoutesDataItem>,
required: true
}
},
setup(props): RightTopSetupData {
const { t } = useI18n();
const { topNavEnable } = toRefs(props);
const { topMenuCon, topMenuWidth } = useTopMenuWidth(topNavEnable);
return {
t,
topMenuCon,
topMenuWidth
}
}
})
</script>