vben
authored
|
1
2
3
4
5
|
<template>
<Header :class="getHeaderClass">
<!-- left start -->
<div :class="`${prefixCls}-left`">
<!-- logo -->
|
vben
authored
|
6
7
8
|
<AppLogo
v-if="getShowHeaderLogo || getIsMobile"
:class="`${prefixCls}-logo`"
|
vben
authored
|
9
|
:theme="getHeaderTheme"
|
vben
authored
|
10
|
:style="getLogoWidth"
|
vben
authored
|
11
|
/>
|
vben
authored
|
12
|
<LayoutTrigger
|
vben
authored
|
13
14
15
|
v-if="
(getShowContent && getShowHeaderTrigger && !getSplit && !getIsMixSidebar) || getIsMobile
"
|
vben
authored
|
16
|
:theme="getHeaderTheme"
|
vben
authored
|
17
|
:sider="false"
|
vben
authored
|
18
|
/>
|
vben
authored
|
19
|
<LayoutBreadcrumb v-if="getShowContent && getShowBread" :theme="getHeaderTheme" />
|
vben
authored
|
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
</div>
<!-- left end -->
<!-- menu start -->
<div :class="`${prefixCls}-menu`" v-if="getShowTopMenu && !getIsMobile">
<LayoutMenu
:isHorizontal="true"
:theme="getHeaderTheme"
:splitType="getSplitType"
:menuMode="getMenuMode"
/>
</div>
<!-- menu-end -->
<!-- action -->
<div :class="`${prefixCls}-action`">
|
sanmu
authored
|
36
|
<!-- <AppSearch :class="`${prefixCls}-action__item `" v-if="getShowSearch" /> -->
|
vben
authored
|
37
|
|
vben
authored
|
38
|
<ErrorAction v-if="getUseErrorHandle" :class="`${prefixCls}-action__item error-action`" />
|
vben
authored
|
39
|
|
sanmu
authored
|
40
|
<!-- <Notify v-if="getShowNotice" :class="`${prefixCls}-action__item notify-item`" /> -->
|
vben
authored
|
41
|
|
vben
authored
|
42
|
<FullScreen v-if="getShowFullScreen" :class="`${prefixCls}-action__item fullscreen-item`" />
|
vben
authored
|
43
|
|
sanmu
authored
|
44
|
<!-- <AppLocalePicker
|
Vben
authored
|
45
|
v-if="getShowLocalePicker"
|
vben
authored
|
46
47
48
|
:reload="true"
:showText="false"
:class="`${prefixCls}-action__item`"
|
sanmu
authored
|
49
|
/> -->
|
vben
authored
|
50
51
|
<UserDropDown :theme="getHeaderTheme" />
|
sanmu
authored
|
52
|
<!-- <SettingDrawer v-if="getShowSetting" :class="`${prefixCls}-action__item`" /> -->
|
vben
authored
|
53
54
55
56
57
58
59
60
61
|
</div>
</Header>
</template>
<script lang="ts">
import { defineComponent, unref, computed } from 'vue';
import { propTypes } from '/@/utils/propTypes';
import { Layout } from 'ant-design-vue';
|
|
62
|
import { AppLogo, AppSearch, AppLocalePicker } from '/@/components/Application';
|
vben
authored
|
63
|
import LayoutMenu from '../menu/index.vue';
|
vben
authored
|
64
65
66
67
68
69
70
|
import LayoutTrigger from '../trigger/index.vue';
import { useHeaderSetting } from '/@/hooks/setting/useHeaderSetting';
import { useMenuSetting } from '/@/hooks/setting/useMenuSetting';
import { useRootSetting } from '/@/hooks/setting/useRootSetting';
import { MenuModeEnum, MenuSplitTyeEnum } from '/@/enums/menuEnum';
|
vben
authored
|
71
|
import { SettingButtonPositionEnum } from '/@/enums/appEnum';
|
vben
authored
|
72
|
|
vben
authored
|
73
|
import { UserDropDown, LayoutBreadcrumb, FullScreen, Notify, ErrorAction } from './components';
|
vben
authored
|
74
75
76
|
import { useAppInject } from '/@/hooks/web/useAppInject';
import { useDesign } from '/@/hooks/web/useDesign';
|
vben
authored
|
77
|
import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent';
|
Vben
authored
|
78
|
import { useLocale } from '/@/locales/useLocale';
|
sanmu
authored
|
79
80
81
|
import { useUserStoreWithOut } from '/@/store/modules/user';
const userStore = useUserStoreWithOut();
|
vben
authored
|
82
|
|
vben
authored
|
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
export default defineComponent({
name: 'LayoutHeader',
components: {
Header: Layout.Header,
AppLogo,
LayoutTrigger,
LayoutBreadcrumb,
LayoutMenu,
UserDropDown,
AppLocalePicker,
FullScreen,
Notify,
AppSearch,
ErrorAction,
|
vben
authored
|
97
98
99
|
SettingDrawer: createAsyncComponent(() => import('/@/layouts/default/setting/index.vue'), {
loading: true,
}),
|
vben
authored
|
100
101
102
103
104
105
|
},
props: {
fixed: propTypes.bool,
},
setup(props) {
const { prefixCls } = useDesign('layout-header');
|
vben
authored
|
106
107
108
109
110
111
|
const {
getShowTopMenu,
getShowHeaderTrigger,
getSplit,
getIsMixMode,
getMenuWidth,
|
vben
authored
|
112
|
getIsMixSidebar,
|
vben
authored
|
113
|
} = useMenuSetting();
|
Vben
authored
|
114
115
|
const { getUseErrorHandle, getShowSettingButton, getSettingButtonPosition } =
useRootSetting();
|
vben
authored
|
116
117
118
119
120
121
122
123
|
const {
getHeaderTheme,
getShowFullScreen,
getShowNotice,
getShowContent,
getShowBread,
getShowHeaderLogo,
|
vben
authored
|
124
|
getShowHeader,
|
Vben
authored
|
125
|
getShowSearch,
|
vben
authored
|
126
127
|
} = useHeaderSetting();
|
Vben
authored
|
128
129
|
const { getShowLocalePicker } = useLocale();
|
vben
authored
|
130
131
132
133
134
135
|
const { getIsMobile } = useAppInject();
const getHeaderClass = computed(() => {
const theme = unref(getHeaderTheme);
return [
prefixCls,
|
vben
authored
|
136
137
138
139
140
|
{
[`${prefixCls}--fixed`]: props.fixed,
[`${prefixCls}--mobile`]: unref(getIsMobile),
[`${prefixCls}--${theme}`]: theme,
},
|
vben
authored
|
141
142
143
|
];
});
|
vben
authored
|
144
145
146
147
148
149
150
151
152
153
154
155
|
const getShowSetting = computed(() => {
if (!unref(getShowSettingButton)) {
return false;
}
const settingButtonPosition = unref(getSettingButtonPosition);
if (settingButtonPosition === SettingButtonPositionEnum.AUTO) {
return unref(getShowHeader);
}
return settingButtonPosition === SettingButtonPositionEnum.HEADER;
});
|
vben
authored
|
156
|
const getLogoWidth = computed(() => {
|
vben
authored
|
157
|
if (!unref(getIsMixMode) || unref(getIsMobile)) {
|
vben
authored
|
158
159
160
161
162
163
|
return {};
}
const width = unref(getMenuWidth) < 180 ? 180 : unref(getMenuWidth);
return { width: `${width}px` };
});
|
vben
authored
|
164
165
166
167
168
169
170
171
|
const getSplitType = computed(() => {
return unref(getSplit) ? MenuSplitTyeEnum.TOP : MenuSplitTyeEnum.NONE;
});
const getMenuMode = computed(() => {
return unref(getSplit) ? MenuModeEnum.HORIZONTAL : null;
});
|
sanmu
authored
|
172
173
174
175
|
const nickName = computed(() => {
return userStore.getUserInfo?.nickName;
});
|
vben
authored
|
176
177
178
179
180
181
182
183
184
185
|
return {
prefixCls,
getHeaderClass,
getShowHeaderLogo,
getHeaderTheme,
getShowHeaderTrigger,
getIsMobile,
getShowBread,
getShowContent,
getSplitType,
|
vben
authored
|
186
|
getSplit,
|
vben
authored
|
187
188
|
getMenuMode,
getShowTopMenu,
|
Vben
authored
|
189
|
getShowLocalePicker,
|
vben
authored
|
190
191
192
|
getShowFullScreen,
getShowNotice,
getUseErrorHandle,
|
vben
authored
|
193
|
getLogoWidth,
|
vben
authored
|
194
|
getIsMixSidebar,
|
vben
authored
|
195
|
getShowSettingButton,
|
vben
authored
|
196
|
getShowSetting,
|
Vben
authored
|
197
|
getShowSearch,
|
sanmu
authored
|
198
|
nickName,
|
vben
authored
|
199
200
201
202
203
|
};
},
});
</script>
<style lang="less">
|
vben
authored
|
204
|
@import url('./index.less');
|
vben
authored
|
205
|
</style>
|