index.vue 8.4 KB

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