Navbar.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <template>
  2. <div class="navbar">
  3. <hamburger
  4. id="hamburger-container"
  5. :is-active="sidebar.opened"
  6. class="hamburger-container"
  7. @toggleClick="toggleSideBar"
  8. />
  9. <breadcrumb id="breadcrumb-container" class="breadcrumb-container" />
  10. <div class="right-menu" style="display: flex">
  11. <div>
  12. <el-button @click="show_(0,0)" size="small" type="primary">查看工单</el-button>
  13. <el-button @click="add_(0,0)" size="small" type="primary">创建工单</el-button>
  14. </div>
  15. <template v-if="device!=='mobile'">
  16. <search id="header-search" class="right-menu-item" />
  17. <error-log class="errLog-container right-menu-item hover-effect" />
  18. <screenfull id="screenfull" class="right-menu-item hover-effect" />
  19. <el-tooltip content="Global Size" effect="dark" placement="bottom">
  20. <size-select id="size-select" class="right-menu-item hover-effect" />
  21. </el-tooltip>
  22. </template>
  23. <el-dropdown class="avatar-container right-menu-item hover-effect" trigger="click">
  24. <div class="avatar-wrapper">
  25. <img :src="avatar+'?imageView2/1/w/80/h/80'" class="user-avatar" />
  26. <i class="el-icon-caret-bottom" />
  27. </div>
  28. <el-dropdown-menu slot="dropdown">
  29. <!-- <router-link to="/profile/index">
  30. <el-dropdown-item>Profile</el-dropdown-item>
  31. </router-link>-->
  32. <router-link to="/">
  33. <el-dropdown-item>Dashboard</el-dropdown-item>
  34. </router-link>
  35. <!-- <a target="_blank" href="https://github.com/PanJiaChen/vue-element-admin/">
  36. <el-dropdown-item>Github</el-dropdown-item>
  37. </a>
  38. <a target="_blank" href="https://panjiachen.github.io/vue-element-admin-site/#/">
  39. <el-dropdown-item>Docs</el-dropdown-item>
  40. </a>-->
  41. <el-dropdown-item divided>
  42. <span style="display:block;" @click="logout">Log Out</span>
  43. </el-dropdown-item>
  44. </el-dropdown-menu>
  45. </el-dropdown>
  46. </div>
  47. </div>
  48. </template>
  49. <script>
  50. import { mapGetters } from "vuex";
  51. import Breadcrumb from "@/components/Breadcrumb";
  52. import Hamburger from "@/components/Hamburger";
  53. import ErrorLog from "@/components/ErrorLog";
  54. import Screenfull from "@/components/Screenfull";
  55. import SizeSelect from "@/components/SizeSelect";
  56. import Search from "@/components/HeaderSearch";
  57. export default {
  58. components: {
  59. Breadcrumb,
  60. Hamburger,
  61. ErrorLog,
  62. Screenfull,
  63. SizeSelect,
  64. Search
  65. },
  66. data() {
  67. console.log(this.$store.state);
  68. return {
  69. avatar: this.$store.state.user.avatar,
  70. direction: 'rtl',
  71. drawer: false,
  72. id:0,
  73. type:0,
  74. };
  75. },
  76. computed: {
  77. ...mapGetters(["sidebar", "device"])
  78. },
  79. methods: {
  80. toggleSideBar() {
  81. this.$store.dispatch("app/toggleSideBar");
  82. },
  83. add_(){
  84. this.$router.push("/main/task?action=add&time="+Math.random());
  85. },
  86. show_(){
  87. this.$router.push("/main/task?time="+Math.random());
  88. },
  89. async logout() {
  90. // await this.$store.dispatch("user/logout");
  91. console.log(
  92. this.$store.state.domainConfig.siteUrl +
  93. `/rooter/quit?next=${this.$route.fullPath}`
  94. );
  95. window.location.href =
  96. this.$store.state.domainConfig.siteUrl +
  97. `/rooter/quit?next=${this.$route.fullPath}`;
  98. }
  99. }
  100. };
  101. </script>
  102. <style lang="scss" scoped>
  103. .navbar {
  104. height: 50px;
  105. overflow: hidden;
  106. position: relative;
  107. background: #fff;
  108. box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
  109. .hamburger-container {
  110. line-height: 46px;
  111. height: 100%;
  112. float: left;
  113. cursor: pointer;
  114. transition: background 0.3s;
  115. -webkit-tap-highlight-color: transparent;
  116. &:hover {
  117. background: rgba(0, 0, 0, 0.025);
  118. }
  119. }
  120. .breadcrumb-container {
  121. float: left;
  122. }
  123. .errLog-container {
  124. display: inline-block;
  125. vertical-align: top;
  126. }
  127. .right-menu {
  128. float: right;
  129. height: 100%;
  130. line-height: 50px;
  131. &:focus {
  132. outline: none;
  133. }
  134. .right-menu-item {
  135. display: inline-block;
  136. padding: 0 8px;
  137. height: 100%;
  138. font-size: 18px;
  139. color: #5a5e66;
  140. vertical-align: text-bottom;
  141. &.hover-effect {
  142. cursor: pointer;
  143. transition: background 0.3s;
  144. &:hover {
  145. background: rgba(0, 0, 0, 0.025);
  146. }
  147. }
  148. }
  149. .avatar-container {
  150. margin-right: 30px;
  151. .avatar-wrapper {
  152. margin-top: 5px;
  153. position: relative;
  154. .user-avatar {
  155. cursor: pointer;
  156. width: 40px;
  157. height: 40px;
  158. border-radius: 10px;
  159. }
  160. .el-icon-caret-bottom {
  161. cursor: pointer;
  162. position: absolute;
  163. right: -20px;
  164. top: 25px;
  165. font-size: 12px;
  166. }
  167. }
  168. }
  169. }
  170. }
  171. </style>