index.vue 7.6 KB

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