index.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <template>
  2. <Header :class="getHeaderClass">
  3. <!-- left start -->
  4. <div :class="`${prefixCls}-left`">
  5. <!-- logo -->
  6. <AppLogo v-if="getShowHeaderLogo || getIsMobile" :class="`${prefixCls}-logo`" :theme="getHeaderTheme" :style="getLogoWidth" />
  7. <LayoutTrigger
  8. v-if="(getShowContent && getShowHeaderTrigger && !getSplit && !getIsMixSidebar) || getIsMobile"
  9. :theme="getHeaderTheme"
  10. :sider="false"
  11. />
  12. <LayoutBreadcrumb v-if="getShowContent && getShowBread" :theme="getHeaderTheme" />
  13. <!-- 欢迎语 -->
  14. <span
  15. v-if="getShowContent && getShowBreadTitle && !getIsMobile"
  16. :class="[prefixCls, `${prefixCls}--${getHeaderTheme}`, 'headerIntroductionClass']"
  17. >
  18. {{ t('layout.header.welcomeIn') }} {{ title }}
  19. </span>
  20. </div>
  21. <!-- left end -->
  22. <!-- menu start -->
  23. <div :class="`${prefixCls}-menu`" v-if="getShowTopMenu && !getIsMobile">
  24. <LayoutMenu :isHorizontal="true" :theme="getHeaderTheme" :splitType="getSplitType" :menuMode="getMenuMode" />
  25. </div>
  26. <!-- menu-end -->
  27. <!-- action -->
  28. <div :class="`${prefixCls}-action`">
  29. <AppSearch :class="`${prefixCls}-action__item `" v-if="getShowSearch" />
  30. <ErrorAction v-if="getUseErrorHandle" :class="`${prefixCls}-action__item error-action`" />
  31. <Notify v-if="getShowNotice" :class="`${prefixCls}-action__item notify-item`" />
  32. <FullScreen v-if="getShowFullScreen" :class="`${prefixCls}-action__item fullscreen-item`" />
  33. <LockScreen v-if="getUseLockPage" />
  34. <AppLocalePicker v-if="getShowLocalePicker" :reload="true" :showText="false" :class="`${prefixCls}-action__item`" />
  35. <UserDropDown :theme="getHeaderTheme" />
  36. <SettingDrawer v-if="getShowSetting" :class="`${prefixCls}-action__item`" />
  37. </div>
  38. </Header>
  39. <LoginSelect ref="loginSelectRef" @success="loginSelectOk"></LoginSelect>
  40. </template>
  41. <script lang="ts">
  42. import { defineComponent, unref, computed, ref, onMounted, toRaw } from 'vue';
  43. import { useGlobSetting } from '/@/hooks/setting';
  44. import { propTypes } from '/@/utils/propTypes';
  45. import { Layout } from 'ant-design-vue';
  46. import { AppLogo } from '/@/components/Application';
  47. import LayoutMenu from '../menu/index.vue';
  48. import LayoutTrigger from '../trigger/index.vue';
  49. import { AppSearch } from '/@/components/Application';
  50. import { useHeaderSetting } from '/@/hooks/setting/useHeaderSetting';
  51. import { useMenuSetting } from '/@/hooks/setting/useMenuSetting';
  52. import { useRootSetting } from '/@/hooks/setting/useRootSetting';
  53. import { MenuModeEnum, MenuSplitTyeEnum } from '/@/enums/menuEnum';
  54. import { SettingButtonPositionEnum } from '/@/enums/appEnum';
  55. import { AppLocalePicker } from '/@/components/Application';
  56. import { UserDropDown, LayoutBreadcrumb, FullScreen, Notify, ErrorAction, LockScreen } from './components';
  57. import { useAppInject } from '/@/hooks/web/useAppInject';
  58. import { useDesign } from '/@/hooks/web/useDesign';
  59. import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent';
  60. import { useLocale } from '/@/locales/useLocale';
  61. import LoginSelect from '/@/views/sys/login/LoginSelect.vue';
  62. import { useUserStore } from '/@/store/modules/user';
  63. import { useI18n } from '/@/hooks/web/useI18n';
  64. const { t } = useI18n();
  65. export default defineComponent({
  66. name: 'LayoutHeader',
  67. components: {
  68. Header: Layout.Header,
  69. AppLogo,
  70. LayoutTrigger,
  71. LayoutBreadcrumb,
  72. LayoutMenu,
  73. UserDropDown,
  74. AppLocalePicker,
  75. FullScreen,
  76. Notify,
  77. AppSearch,
  78. ErrorAction,
  79. LockScreen,
  80. LoginSelect,
  81. SettingDrawer: createAsyncComponent(() => import('/@/layouts/default/setting/index.vue'), {
  82. loading: true,
  83. }),
  84. },
  85. props: {
  86. fixed: propTypes.bool,
  87. },
  88. setup(props) {
  89. const { prefixCls } = useDesign('layout-header');
  90. const userStore = useUserStore();
  91. const { getShowTopMenu, getShowHeaderTrigger, getSplit, getIsMixMode, getMenuWidth, getIsMixSidebar } = useMenuSetting();
  92. const { getUseErrorHandle, getShowSettingButton, getSettingButtonPosition, getAiIconShow } = useRootSetting();
  93. const { title } = useGlobSetting();
  94. const {
  95. getHeaderTheme,
  96. getShowFullScreen,
  97. getShowNotice,
  98. getShowContent,
  99. getShowBread,
  100. getShowHeaderLogo,
  101. getShowHeader,
  102. getShowSearch,
  103. getUseLockPage,
  104. getShowBreadTitle,
  105. } = useHeaderSetting();
  106. const { getShowLocalePicker } = useLocale();
  107. const { getIsMobile } = useAppInject();
  108. const getHeaderClass = computed(() => {
  109. const theme = unref(getHeaderTheme);
  110. return [
  111. prefixCls,
  112. {
  113. [`${prefixCls}--fixed`]: props.fixed,
  114. [`${prefixCls}--mobile`]: unref(getIsMobile),
  115. [`${prefixCls}--${theme}`]: theme,
  116. },
  117. ];
  118. });
  119. const getShowSetting = computed(() => {
  120. if (!unref(getShowSettingButton)) {
  121. return false;
  122. }
  123. const settingButtonPosition = unref(getSettingButtonPosition);
  124. if (settingButtonPosition === SettingButtonPositionEnum.AUTO) {
  125. return unref(getShowHeader);
  126. }
  127. return settingButtonPosition === SettingButtonPositionEnum.HEADER;
  128. });
  129. const getLogoWidth = computed(() => {
  130. if (!unref(getIsMixMode) || unref(getIsMobile)) {
  131. return {};
  132. }
  133. const width = unref(getMenuWidth) < 180 ? 180 : unref(getMenuWidth);
  134. return { width: `${width}px` };
  135. });
  136. const getSplitType = computed(() => {
  137. return unref(getSplit) ? MenuSplitTyeEnum.TOP : MenuSplitTyeEnum.NONE;
  138. });
  139. const getMenuMode = computed(() => {
  140. return unref(getSplit) ? MenuModeEnum.HORIZONTAL : null;
  141. });
  142. /**
  143. * 首页多租户部门弹窗逻辑
  144. */
  145. const loginSelectRef = ref();
  146. function showLoginSelect() {
  147. //update-begin---author:liusq Date:20220101 for:判断登录进来是否需要弹窗选择租户----
  148. //判断是否是登陆进来
  149. const loginInfo = toRaw(userStore.getLoginInfo) || {};
  150. if (!!loginInfo.isLogin) {
  151. loginSelectRef.value.show(loginInfo);
  152. }
  153. //update-end---author:liusq Date:20220101 for:判断登录进来是否需要弹窗选择租户----
  154. }
  155. function loginSelectOk() {
  156. console.log('成功。。。。。');
  157. }
  158. onMounted(() => {
  159. showLoginSelect();
  160. });
  161. return {
  162. prefixCls,
  163. getHeaderClass,
  164. getShowHeaderLogo,
  165. getHeaderTheme,
  166. getShowHeaderTrigger,
  167. getIsMobile,
  168. getShowBreadTitle,
  169. getShowBread,
  170. getShowContent,
  171. getSplitType,
  172. getSplit,
  173. getMenuMode,
  174. getShowTopMenu,
  175. getShowLocalePicker,
  176. getShowFullScreen,
  177. getShowNotice,
  178. getUseErrorHandle,
  179. getLogoWidth,
  180. getIsMixSidebar,
  181. getShowSettingButton,
  182. getShowSetting,
  183. getShowSearch,
  184. getUseLockPage,
  185. loginSelectOk,
  186. loginSelectRef,
  187. title,
  188. t,
  189. getAiIconShow,
  190. };
  191. },
  192. });
  193. </script>
  194. <style lang="less">
  195. @import './index.less';
  196. //update-begin---author:scott ---date:2022-09-30 for:默认隐藏顶部菜单面包屑-----------
  197. //顶部欢迎语展示样式
  198. @prefix-cls: ~'@{namespace}-layout-header';
  199. .ant-layout .@{prefix-cls} {
  200. display: flex;
  201. padding: 0 8px;
  202. // update-begin--author:liaozhiyang---date:20240407---for:【QQYUN-8762】顶栏高度
  203. height: @header-height;
  204. // update-end--author:liaozhiyang---date:20240407---for:【QQYUN-8762】顶栏高度
  205. align-items: center;
  206. .headerIntroductionClass {
  207. margin-right: 4px;
  208. margin-bottom: 2px;
  209. border-bottom: 0px;
  210. border-left: 0px;
  211. }
  212. &--light {
  213. .headerIntroductionClass {
  214. color: #000;
  215. }
  216. }
  217. &--dark {
  218. .headerIntroductionClass {
  219. color: rgba(255, 255, 255, 1);
  220. }
  221. .anticon,
  222. .truncate {
  223. color: rgba(255, 255, 255, 1);
  224. }
  225. }
  226. //update-end---author:scott ---date::2022-09-30 for:默认隐藏顶部菜单面包屑--------------
  227. }
  228. </style>