index.vue 10 KB

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