index.vue 8.9 KB

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