index.vue 10 KB

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