index.vue 6.5 KB

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