index.vue 9.8 KB

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