Navbar.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  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
  10. id="breadcrumb-container"
  11. class="breadcrumb-container"
  12. v-if="!topNav"
  13. />
  14. <top-nav id="topmenu-container" class="topmenu-container" v-if="topNav" />
  15. <div class="right-menu">
  16. <template v-if="device !== 'mobile'">
  17. <search id="header-search" class="right-menu-item" />
  18. <!-- <el-tooltip content="源码地址" effect="dark" placement="bottom">
  19. <ruo-yi-git id="ruoyi-git" class="right-menu-item hover-effect" />
  20. </el-tooltip>
  21. <el-tooltip content="文档地址" effect="dark" placement="bottom">
  22. <ruo-yi-doc id="ruoyi-doc" class="right-menu-item hover-effect" />
  23. </el-tooltip> -->
  24. <el-tooltip content="版本说明" effect="dark" placement="bottom">
  25. <version
  26. id="version"
  27. class="right-menu-item hover-effect"
  28. @openMsg="openMsg"
  29. />
  30. </el-tooltip>
  31. <el-dialog
  32. append-to-body
  33. :visible.sync="dialogVisible"
  34. width="560px"
  35. :show-close="false"
  36. :close-on-click-modal="false"
  37. >
  38. <div slot="title" class="hearders">
  39. <div class="leftTitle">版本说明</div>
  40. <div class="rightBoxs">
  41. <img
  42. src="@/assets/images/Close@2x.png"
  43. alt=""
  44. @click="dialogVisible = false"
  45. />
  46. </div>
  47. </div>
  48. <div class="dialogSty">
  49. <h2>v1.0.0</h2>
  50. <p>1.开发中...待完善</p>
  51. </div>
  52. <span slot="footer" class="dialog-footer">
  53. <el-button @click="dialogVisible = false">关 闭</el-button>
  54. </span>
  55. </el-dialog>
  56. <screenfull id="screenfull" class="right-menu-item hover-effect" />
  57. <el-tooltip content="布局大小" effect="dark" placement="bottom">
  58. <size-select id="size-select" class="right-menu-item hover-effect" />
  59. </el-tooltip>
  60. </template>
  61. <el-dropdown
  62. class="avatar-container right-menu-item hover-effect"
  63. trigger="click"
  64. >
  65. <div class="avatar-wrapper">
  66. <img :src="avatar" class="user-avatar" />
  67. <i class="el-icon-caret-bottom" />
  68. </div>
  69. <el-dropdown-menu slot="dropdown">
  70. <router-link to="/user/profile">
  71. <el-dropdown-item>个人中心</el-dropdown-item>
  72. </router-link>
  73. <el-dropdown-item @click.native="setting = true">
  74. <span>布局设置</span>
  75. </el-dropdown-item>
  76. <el-dropdown-item divided @click.native="logout">
  77. <span>退出登录</span>
  78. </el-dropdown-item>
  79. </el-dropdown-menu>
  80. </el-dropdown>
  81. </div>
  82. </div>
  83. </template>
  84. <script>
  85. import { mapGetters } from "vuex";
  86. import Breadcrumb from "@/components/Breadcrumb";
  87. import TopNav from "@/components/TopNav";
  88. import Hamburger from "@/components/Hamburger";
  89. import Screenfull from "@/components/Screenfull";
  90. import SizeSelect from "@/components/SizeSelect";
  91. import version from "@/components/version";
  92. import Search from "@/components/HeaderSearch";
  93. import RuoYiGit from "@/components/RuoYi/Git";
  94. import RuoYiDoc from "@/components/RuoYi/Doc";
  95. export default {
  96. components: {
  97. Breadcrumb,
  98. TopNav,
  99. Hamburger,
  100. Screenfull,
  101. SizeSelect,
  102. Search,
  103. RuoYiGit,
  104. RuoYiDoc,
  105. version,
  106. },
  107. data() {
  108. return {
  109. dialogVisible: false,
  110. };
  111. },
  112. computed: {
  113. ...mapGetters(["sidebar", "avatar", "device"]),
  114. setting: {
  115. get() {
  116. return this.$store.state.settings.showSettings;
  117. },
  118. set(val) {
  119. this.$store.dispatch("settings/changeSetting", {
  120. key: "showSettings",
  121. value: val,
  122. });
  123. },
  124. },
  125. topNav: {
  126. get() {
  127. return this.$store.state.settings.topNav;
  128. },
  129. },
  130. },
  131. methods: {
  132. openMsg() {
  133. this.dialogVisible = true;
  134. },
  135. toggleSideBar() {
  136. this.$store.dispatch("app/toggleSideBar");
  137. },
  138. async logout() {
  139. this.$confirm("确定注销并退出系统吗?", "提示", {
  140. confirmButtonText: "确定",
  141. cancelButtonText: "取消",
  142. type: "warning",
  143. })
  144. .then(() => {
  145. this.$store.dispatch("LogOut").then(() => {
  146. location.href = "/index";
  147. });
  148. })
  149. .catch(() => {});
  150. },
  151. },
  152. };
  153. </script>
  154. <style lang="scss" scoped>
  155. /deep/.el-button {
  156. border-radius: 8px;
  157. }
  158. /deep/.el-dialog {
  159. z-index: 9999;
  160. border-radius: 8px;
  161. .el-dialog__header {
  162. padding: 0;
  163. .hearders {
  164. height: 40px;
  165. display: flex;
  166. align-items: center;
  167. justify-content: space-between;
  168. padding: 0px 18px 0px 20px;
  169. border-bottom: 1px solid #e2e2e2;
  170. .leftTitle {
  171. font-size: 14px;
  172. font-weight: bold;
  173. color: #2f4378;
  174. }
  175. .rightBoxs {
  176. display: flex;
  177. align-items: center;
  178. img {
  179. width: 14px;
  180. height: 14px;
  181. margin-left: 13px;
  182. cursor: pointer;
  183. }
  184. }
  185. }
  186. }
  187. .el-dialog__body {
  188. padding: 0px 20px;
  189. max-height: 450px;
  190. overflow: auto;
  191. h2 {
  192. font-weight: bold;
  193. color: #333;
  194. border-bottom: 2px dashed #000;
  195. padding-bottom: 10px;
  196. }
  197. }
  198. .el-dialog__footer {
  199. padding: 0;
  200. .dialog-footer {
  201. padding: 0px 40px;
  202. height: 70px;
  203. border-top: 1px solid #e2e2e2;
  204. display: flex;
  205. align-items: center;
  206. justify-content: flex-end;
  207. }
  208. }
  209. }
  210. .imgBox {
  211. width: 100%;
  212. // height: 210px;
  213. border: 1px solid #e2e2e2;
  214. border-radius: 8px;
  215. padding: 8px 8px 3px;
  216. display: flex;
  217. flex-direction: column;
  218. align-items: center;
  219. .imgLabel {
  220. flex: 1;
  221. width: 100%;
  222. border: 1px dotted #e2e2e2;
  223. color: #999;
  224. font-size: 14px;
  225. cursor: pointer;
  226. border-radius: 8px;
  227. .msPhoto {
  228. display: flex;
  229. justify-content: center;
  230. align-items: center;
  231. max-width: 100%;
  232. max-height: 270px;
  233. img {
  234. max-width: 100%;
  235. max-height: 270px;
  236. }
  237. }
  238. .imgbbx {
  239. display: flex;
  240. flex-direction: column;
  241. align-items: center;
  242. justify-content: center;
  243. width: 100%;
  244. height: 100%;
  245. i {
  246. font-weight: bold;
  247. margin: 14px 0;
  248. font-size: 24px;
  249. }
  250. }
  251. }
  252. p {
  253. margin: 5px 0px;
  254. }
  255. }
  256. .navbar {
  257. height: 50px;
  258. overflow: hidden;
  259. position: relative;
  260. background: #fff;
  261. box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
  262. .hamburger-container {
  263. line-height: 46px;
  264. height: 100%;
  265. float: left;
  266. cursor: pointer;
  267. transition: background 0.3s;
  268. -webkit-tap-highlight-color: transparent;
  269. &:hover {
  270. background: rgba(0, 0, 0, 0.025);
  271. }
  272. }
  273. .breadcrumb-container {
  274. float: left;
  275. }
  276. .topmenu-container {
  277. position: absolute;
  278. left: 50px;
  279. }
  280. .errLog-container {
  281. display: inline-block;
  282. vertical-align: top;
  283. }
  284. .right-menu {
  285. float: right;
  286. height: 100%;
  287. line-height: 50px;
  288. &:focus {
  289. outline: none;
  290. }
  291. .right-menu-item {
  292. display: inline-block;
  293. padding: 0 8px;
  294. height: 100%;
  295. font-size: 18px;
  296. color: #5a5e66;
  297. vertical-align: text-bottom;
  298. &.hover-effect {
  299. cursor: pointer;
  300. transition: background 0.3s;
  301. &:hover {
  302. background: rgba(0, 0, 0, 0.025);
  303. }
  304. }
  305. }
  306. .avatar-container {
  307. margin-right: 30px;
  308. .avatar-wrapper {
  309. margin-top: 5px;
  310. position: relative;
  311. .user-avatar {
  312. cursor: pointer;
  313. width: 40px;
  314. height: 40px;
  315. border-radius: 10px;
  316. }
  317. .el-icon-caret-bottom {
  318. cursor: pointer;
  319. position: absolute;
  320. right: -20px;
  321. top: 25px;
  322. font-size: 12px;
  323. }
  324. }
  325. }
  326. }
  327. }
  328. </style>