index.vue 10 KB

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