index.vue 7.7 KB

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