index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. <template>
  2. <div class="combarr">
  3. <div class="combar">
  4. <div class="bar"></div>
  5. <el-row>
  6. <el-col :span="12">
  7. <span>
  8. <img src="../assets/images/comlo.png" alt="" class="imgg" />
  9. </span>
  10. </el-col>
  11. <el-col :span="4" :offset="8">
  12. <el-dropdown
  13. class="avatar-container right-menu-item hover-effect"
  14. trigger="click"
  15. >
  16. <div class="avatar-wrapper">
  17. <img :src="avatar" class="user-avatar" />
  18. <span style="">
  19. <button class="jianbiase">{{ userName || "默认用户" }}</button>
  20. </span>
  21. <!-- <i class="el-icon-caret-bottom" /> -->
  22. </div>
  23. <el-dropdown-menu slot="dropdown" style="margin-top: -20px">
  24. <router-link to="/user/profile">
  25. <el-dropdown-item>个人中心</el-dropdown-item>
  26. </router-link>
  27. <el-dropdown-item @click.native="setting = true">
  28. <span>布局设置</span>
  29. </el-dropdown-item>
  30. <el-dropdown-item divided @click.native="logout">
  31. <span>退出登录</span>
  32. </el-dropdown-item>
  33. </el-dropdown-menu>
  34. </el-dropdown>
  35. </el-col>
  36. </el-row>
  37. </div>
  38. <div style="height: 100px"></div>
  39. <div
  40. :class="classObj"
  41. class="app-wrapper"
  42. :style="{ '--current-color': theme }"
  43. >
  44. <div
  45. v-if="device === 'mobile' && sidebar.opened"
  46. class="drawer-bg"
  47. @click="handleClickOutside"
  48. />
  49. <sidebar
  50. v-if="!sidebar.hide"
  51. class="sidebar-container"
  52. style="background-color: #222653"
  53. />
  54. <div
  55. :class="{ hasTagsView: needTagsView, sidebarHide: sidebar.hide }"
  56. class="main-container"
  57. >
  58. <div :class="{ 'fixed-header': fixedHeader }">
  59. <!-- <navbar /> -->
  60. <tags-view v-if="needTagsView" />
  61. </div>
  62. <app-main />
  63. <right-panel>
  64. <settings />
  65. </right-panel>
  66. </div>
  67. </div>
  68. </div>
  69. </template>
  70. <script>
  71. import { mapGetters } from "vuex";
  72. import RightPanel from "@/components/RightPanel";
  73. import { AppMain, Navbar, Settings, Sidebar, TagsView } from "./components";
  74. import ResizeMixin from "./mixin/ResizeHandler";
  75. import { mapState } from "vuex";
  76. import variables from "@/assets/styles/variables.scss";
  77. export default {
  78. name: "Layout",
  79. components: {
  80. AppMain,
  81. Navbar,
  82. RightPanel,
  83. Settings,
  84. Sidebar,
  85. TagsView,
  86. },
  87. data() {
  88. return {
  89. userName: "默认用户",
  90. };
  91. },
  92. mixins: [ResizeMixin],
  93. computed: {
  94. ...mapState({
  95. theme: (state) => state.settings.theme,
  96. sideTheme: (state) => state.settings.sideTheme,
  97. sidebar: (state) => state.app.sidebar,
  98. device: (state) => state.app.device,
  99. needTagsView: (state) => state.settings.tagsView,
  100. fixedHeader: (state) => state.settings.fixedHeader,
  101. ...mapGetters(["avatar"]),
  102. }),
  103. classObj() {
  104. return {
  105. // hideSidebar: !this.sidebar.opened,
  106. openSidebar: this.sidebar.opened,
  107. withoutAnimation: this.sidebar.withoutAnimation,
  108. mobile: this.device === "mobile",
  109. };
  110. },
  111. variables() {
  112. return variables;
  113. },
  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. },
  126. methods: {
  127. async logout() {
  128. this.$confirm("确定注销并退出系统吗?", "提示", {
  129. confirmButtonText: "确定",
  130. cancelButtonText: "取消",
  131. type: "warning",
  132. })
  133. .then(() => {
  134. this.$store.dispatch("LogOut").then(() => {
  135. location.href = "/index";
  136. });
  137. })
  138. .catch(() => {});
  139. },
  140. handleClickOutside() {
  141. this.$store.dispatch("app/closeSideBar", { withoutAnimation: false });
  142. },
  143. },
  144. mounted() {
  145. var user = sessionStorage.getItem("sessionObj");
  146. var user = JSON.parse(user);
  147. this.userName = JSON.parse(user.data).username;
  148. },
  149. };
  150. </script>
  151. <style lang="scss" scoped>
  152. @import "~@/assets/styles/mixin.scss";
  153. @import "~@/assets/styles/variables.scss";
  154. .el-dropdown-menu {
  155. z-index: 10000 !important;
  156. }
  157. /* .main-container{
  158. position: relative;
  159. }
  160. .navbar{
  161. position:sticky !important;
  162. } */
  163. .combar {
  164. position: fixed;
  165. display: block;
  166. width: 100%;
  167. z-index: 1000;
  168. background: #fff;
  169. border-bottom: 1px solid #6f7af3;
  170. box-shadow: 0px 0px 2px 0px #222653;
  171. }
  172. .jianbiase {
  173. width: 120px;
  174. height: 37px;
  175. /* height: 25px; */
  176. background: linear-gradient(
  177. 128.13deg,
  178. rgba(82, 79, 255, 1) 0%,
  179. rgba(255, 74, 74, 1) 100%
  180. );
  181. box-shadow: 0px 4px 16px rgba(179, 192, 231, 1);
  182. border-radius: 27px;
  183. margin-top: 15px;
  184. font-size: 14px;
  185. font-weight: 500;
  186. letter-spacing: 0px;
  187. line-height: 20.27px;
  188. color: rgba(255, 255, 255, 1);
  189. }
  190. .user-avatar {
  191. cursor: pointer;
  192. width: 50px;
  193. height: 50px;
  194. border-radius: 50px; //是谁的样式来着
  195. z-index: 2;
  196. vertical-align: middle;
  197. margin-right: -18px;
  198. position: relative;
  199. }
  200. .right-menu-item {
  201. display: inline-block;
  202. padding: 0 8px;
  203. height: 100%;
  204. font-size: 18px;
  205. color: #7c008a;
  206. vertical-align: text-bottom;
  207. float: right;
  208. margin-right: 50px;
  209. margin-top: 18px;
  210. }
  211. #dropdown-menu-1780 {
  212. z-index: 1000000;
  213. }
  214. .imgg {
  215. width: 553px;
  216. height: 80px;
  217. float: left;
  218. margin-top: 15px;
  219. /* margin-left: 50px; */
  220. }
  221. .spann {
  222. text-align: center;
  223. line-height: 100px;
  224. font-size: 30px;
  225. color: #003e8a;
  226. font-weight: bolder;
  227. margin-left: -335px;
  228. }
  229. .app-wrapper {
  230. @include clearfix;
  231. position: relative;
  232. height: 100%;
  233. width: 100%;
  234. &.mobile.openSidebar {
  235. position: fixed;
  236. top: 0;
  237. }
  238. }
  239. .drawer-bg {
  240. background: #000;
  241. opacity: 0.3;
  242. width: 100%;
  243. top: 0;
  244. height: 100%;
  245. position: absolute;
  246. z-index: 999;
  247. }
  248. .fixed-header {
  249. position: fixed;
  250. top: 100px;
  251. right: 0;
  252. z-index: 9;
  253. width: calc(100% - #{$base-sidebar-width});
  254. transition: width 0.28s;
  255. }
  256. .hideSidebar .fixed-header {
  257. width: calc(100% - 54px);
  258. }
  259. .sidebarHide .fixed-header {
  260. width: 100%;
  261. }
  262. .mobile .fixed-header {
  263. width: 100%;
  264. }
  265. </style>