Head.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. <template>
  2. <div class="head-wrapper">
  3. <div class="head-logo">
  4. <svg-icon icon-class="zhihui-logo" @click="topHome()" />
  5. </div>
  6. <div v-for="item in headList" :key="item.path" class="nav-tag" :class="{'active-nav-tag':activeNavTag === item.name}" @click="changeNavTag(item)">
  7. <div v-if="item.icon" class="icon">
  8. <div v-show="notice && item.name.search(/个人工作台/)>=0" class="if-notice" />
  9. <svg-icon :icon-class="item.icon" />
  10. </div>
  11. <div class="name">{{ item.name }}</div>
  12. </div>
  13. <div @mouseleave="target = true">
  14. <div :class="[target ? 'nav-div1' : 'nav-div2']">
  15. <el-tooltip v-if="!target" class="item" effect="dark" content="工具集合" placement="right">
  16. <div class="div-child" @click="$router.push({ name: 'Interface' })"><svg-icon icon-class="tool-enter" /></div>
  17. </el-tooltip>
  18. <el-tooltip v-if="!target" class="item" effect="dark" content="环境平台" placement="right">
  19. <div class="div-child" @click="$router.push({ name: 'env' })"><svg-icon icon-class="env-enter" /></div>
  20. </el-tooltip>
  21. </div>
  22. <div class="nav-div3 nav-circular" />
  23. <div class="nav-div4 nav-circular" @mouseenter="target = false" />
  24. </div>
  25. <!-- <div v-show="navTagType === 2" class="nav-tag-type" @click="setNavTagType(1)">
  26. <i class="el-icon-notebook-2" style="transform: rotate(90deg);" />
  27. </div>
  28. <div v-show="navTagType === 1" class="nav-tag-type" @click="setNavTagType(2)">
  29. <i class="el-icon-notebook-2" />
  30. </div> -->
  31. <el-tooltip class="item" effect="dark" content="用户指导手册" placement="right">
  32. <el-link class="user-tip" href="https://base3.xiaojukeji.com/docs/zhihui/" target="_blank">
  33. <svg-icon style="width: 24px; height: 24px;" icon-class="question" />
  34. </el-link>
  35. </el-tooltip>
  36. <div v-if="userInfo" class="user-info">
  37. <a-popover placement="rightBottom" overlay-class-name="head-popover">
  38. <template #content>
  39. <div class="user-control">
  40. <div class="user-name">{{ userInfo.name }}</div>
  41. <div class="line" />
  42. <div class="user-logout">
  43. <el-button v-if="navTagType === 1" type="primary" plain size="small" @click="setNavTagType(2)">顶部导航</el-button>
  44. <el-button v-if="navTagType === 2" type="primary" plain size="small" @click="setNavTagType(1)">侧边导航</el-button>
  45. </div>
  46. <div class="line" />
  47. <div class="user-logout">
  48. <el-button type="primary" plain size="small" @click="layout()">退出登录</el-button>
  49. </div>
  50. </div>
  51. </template>
  52. <img :src="userInfo.phoneUrl">
  53. </a-popover>
  54. </div>
  55. </div>
  56. </template>
  57. <script>
  58. import { mapGetters } from 'vuex'
  59. import routes from '@/router/newRouter'
  60. import websocket from '@/views/workbench/mixins/websocket'
  61. import { memberGetLoginInMemberInfoByLdap } from '@/api/projectIndex'
  62. import { logoutUrl } from '@/apiConfig/requestIP.js'
  63. export default {
  64. mixins: [websocket],
  65. data() {
  66. return {
  67. headList: routes.filter(item => item.name !== '业务线'),
  68. userInfo: null,
  69. target: true
  70. }
  71. },
  72. computed: {
  73. ...mapGetters(['activeNavTag', 'navTagType', 'notice'])
  74. },
  75. watch: {
  76. $route: {
  77. handler(to) {
  78. this.findRoute(to.name)
  79. },
  80. immediate: true
  81. }
  82. },
  83. created() {
  84. this.getLoginUser()
  85. },
  86. methods: {
  87. getTarget() {
  88. this.target = !this.target
  89. },
  90. findRoute(routeName) {
  91. for (const element of routes) {
  92. if (element.name === routeName) {
  93. // 先对父元素进行查找
  94. this.$store.dispatch('global/setActiveNavTag', element.name)
  95. } else if (element.children) {
  96. const child = element.children.find(item => item.name === routeName) // 对子元素进行查找
  97. child ? this.$store.dispatch('global/setActiveNavTag', element.name) : '' // 父元素的名字设为路径
  98. }
  99. }
  100. },
  101. // 切换二级导航
  102. changeNavTag(nav) {
  103. this.$store.dispatch('global/setActiveNavTag', nav.name) // 设置二级导航的类别
  104. this.$router.push({ name: nav.name }) // 跳转
  105. },
  106. // 设置二级导航类型
  107. setNavTagType(type) {
  108. this.$store.dispatch('global/setNavTagType', type)
  109. localStorage.setItem('navTagType', type)
  110. },
  111. // 获取登录人员信息
  112. async getLoginUser() {
  113. const res = await memberGetLoginInMemberInfoByLdap()
  114. if (res && res.data) this.userInfo = res.data || null
  115. },
  116. // 退出登录
  117. layout() {
  118. window.location.href = logoutUrl
  119. },
  120. topHome() {
  121. this.$router.push({ path: '/' })
  122. },
  123. // websocket数据接收
  124. websocketonmessage(e) {
  125. const { hasReminding } = JSON.parse(e.data)
  126. if (hasReminding) {
  127. this.$store.dispatch('data/setNotice', true)
  128. const link = document.querySelector('link')
  129. link.href = link.href.replace(/favicon.ico/, 'favicon-tips.ico')
  130. } else {
  131. this.$store.dispatch('data/setNotice', false)
  132. const link = document.querySelector('link')
  133. link.href = link.href.replace(/favicon-tips.ico/, 'favicon.ico')
  134. }
  135. }
  136. }
  137. }
  138. </script>
  139. <style lang="scss" scoped>
  140. .head-wrapper {
  141. display: flex;
  142. flex-direction: column;
  143. flex-shrink: 0;
  144. z-index: 99;
  145. width: 80px;
  146. align-items: center;
  147. background: #409eff;
  148. font-size: 20px;
  149. color: #333;
  150. padding-top: 17px;
  151. }
  152. .head-logo {
  153. height: 40px;
  154. width: 40px;
  155. margin-bottom: 42px;
  156. .svg-icon {
  157. cursor: pointer;
  158. width: 100%;
  159. height: 100%;
  160. }
  161. }
  162. .nav-tag {
  163. width: 100%;
  164. font-size: 14px;
  165. color: #ffffff;
  166. text-align: center;
  167. margin-bottom: 20px;
  168. padding: 5px 0 9px 0;
  169. cursor: pointer;
  170. .icon {
  171. position: relative;
  172. color: #ffffff;
  173. height: 27px;
  174. width: 33px;
  175. margin: 7px auto;
  176. font-size: 32px;
  177. }
  178. .svg-icon {
  179. position: absolute;
  180. top: 0;
  181. left: 0;
  182. width: 100%;
  183. height: 100%;
  184. }
  185. .if-notice {
  186. position: absolute;
  187. z-index: 1;
  188. height: 8px;
  189. width: 8px;
  190. background-color: #E02020;
  191. border-radius: 50%;
  192. top: 0;
  193. right: 0;
  194. transform: translateY(-50%);
  195. }
  196. }
  197. .active-nav-tag {
  198. background-color: #1E89F7;
  199. }
  200. .nav-tag-type {
  201. margin-top: auto;
  202. color: #ffffff;
  203. cursor: pointer;
  204. }
  205. .user-tip {
  206. margin-top: auto;
  207. margin-bottom: 20px;
  208. }
  209. .user-info {
  210. height: 30px;
  211. width: 30px;
  212. display: flex;
  213. justify-content: center;
  214. align-items: center;
  215. background-color: #fff;
  216. border-radius: 50%;
  217. overflow: hidden;
  218. // margin-top: auto;
  219. margin-bottom: 30px;
  220. img {
  221. height: 30px;
  222. }
  223. }
  224. .user-control {
  225. height: 143px;
  226. width: 95px;
  227. display: flex;
  228. flex-direction: column;
  229. display: grid;
  230. grid-template-rows: 47px 1px 47px 1px 47px;
  231. justify-items: center;
  232. align-items: center;
  233. .line {
  234. width: 100%;
  235. height: 1px;
  236. background-color: rgba(112, 112, 112, 0.2);
  237. }
  238. }
  239. </style>
  240. <style lang="scss" scoped>
  241. .head-popover {
  242. box-shadow: 10px 0px 11px #dedede;
  243. /deep/ .ant-popover-inner-content {
  244. padding: 0;
  245. }
  246. }
  247. .nav-div1 {
  248. width:25px;height:50px;border-radius: 0 50px 50px 0;line-height:50px;background: #FFF; position: absolute; bottom: 172px; left: 0;border: 1px solid #333;opacity: 0.8;animation:myfirsts 0.5s;
  249. }
  250. .nav-div2 {
  251. bottom: 122px; width:70px; height:150px; line-height:150px;border-radius: 0 80px 80px 0;;background: rgb(255, 255, 255); position: absolute; left: 0;opacity: 0.8;animation:myfirst 1s;
  252. }
  253. @keyframes myfirst
  254. {
  255. from {bottom: 172px; width:25px; height:50px; line-height:50px;}
  256. to {bottom: 122px; width:70px; height:150px; line-height:150px;}
  257. }
  258. @keyframes myfirsts
  259. {
  260. from {bottom: 122px; width:70px; height:150px; line-height:150px;}
  261. to {bottom: 172px; width:25px; height:50px; line-height:50px;}
  262. }
  263. .nav-div3 {
  264. width:25px;
  265. height:50px;
  266. line-height:50px;
  267. background: #FFF;
  268. bottom: 172px;
  269. border: 1px solid #eee;
  270. opacity: 0.63;
  271. }
  272. .nav-div4 {
  273. width:20px;
  274. height:40px;
  275. line-height:45px;
  276. background: #FFF;
  277. bottom: 177px;
  278. border: 1px solid #eee;
  279. }
  280. .div-child {
  281. text-align: right;
  282. margin-right: 24px;
  283. line-height: 75px;
  284. cursor: pointer;
  285. opacity: 1;
  286. animation:myfirs 4s;
  287. }
  288. @keyframes myfirs
  289. {
  290. from {opacity: 0}
  291. to {opacity: 1}
  292. }
  293. .nav-circular {
  294. position: absolute;
  295. left: 0;
  296. border-radius: 0 50px 50px 0;
  297. cursor: pointer;
  298. }
  299. </style>