index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  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. handleClickOutside() {
  171. this.$store.dispatch("app/closeSideBar", { withoutAnimation: false });
  172. },
  173. getlogo() {
  174. let logo = sessionStorage.getItem("logo");
  175. // this.title = sessionStorage.getItem("title") || "工业应用操作系统";
  176. this.title = sessionStorage.getItem("title") || "生产协同管理系统";
  177. if (logo) {
  178. this.logo = process.env.VUE_APP_BASE_API + logo;
  179. } else {
  180. // this.logo = mes412;
  181. // this.logo = mecLogoLogin;
  182. this.logo = mecosLogo1;
  183. // this.logo = comp;
  184. }
  185. },
  186. },
  187. mounted() {
  188. this.getlogo();
  189. var user = JSON.parse(sessionStorage.getItem("sessionObj"));
  190. this.userName = JSON.parse(user.data).username;
  191. // this.startTokenRefresh();
  192. },
  193. beforeDestroy() {
  194. if (this.timer) {
  195. clearInterval(this.timer);
  196. }
  197. },
  198. };
  199. </script>
  200. <style lang="scss" scoped>
  201. @import "~@/assets/styles/mixin.scss";
  202. @import "~@/assets/styles/variables.scss";
  203. .combarr {
  204. /* height: 100vh !important; */
  205. /* overflow: scroll; */
  206. }
  207. .avatar-wrapper {
  208. white-space: nowrap;
  209. }
  210. .el-dropdown-menu {
  211. z-index: 10000 !important;
  212. }
  213. .sidebar-container {
  214. background-color: #222653 !important;
  215. }
  216. /* .main-container{
  217. position: relative;
  218. }
  219. .navbar{
  220. position:sticky !important;
  221. } */
  222. .combar {
  223. position: fixed;
  224. display: block;
  225. width: 100%;
  226. z-index: 1000;
  227. background: #fff;
  228. /* border-bottom: 1px solid #6f7af3; */
  229. border-bottom: 1px solid #fff;
  230. box-shadow: 0px 0px 2px 0px #222653;
  231. }
  232. .jianbiase {
  233. /* width: 120px; */
  234. height: 37px;
  235. /* height: 25px; */
  236. /* background: linear-gradient(
  237. 128.13deg,
  238. rgba(82, 79, 255, 1) 0%,
  239. rgba(255, 74, 74, 1) 100%
  240. ); */
  241. /* box-shadow: 0px 4px 16px rgba(179, 192, 231, 1); */
  242. /* border-radius: 27px; */
  243. margin-top: 15px;
  244. font-size: 16px;
  245. font-weight: 500;
  246. letter-spacing: 0px;
  247. line-height: 20.27px;
  248. color: black;
  249. /* color: rgba(255, 255, 255, 1); */
  250. padding: 0px 20px 0px 25px;
  251. box-sizing: border-box;
  252. }
  253. .user-avatar {
  254. cursor: pointer;
  255. width: 50px;
  256. height: 50px;
  257. border-radius: 50px;
  258. z-index: 2;
  259. vertical-align: middle;
  260. margin-right: -18px;
  261. position: relative;
  262. }
  263. .right-menu-item {
  264. display: inline-block;
  265. padding: 0 8px;
  266. height: 100%;
  267. font-size: 18px;
  268. color: #7c008a;
  269. vertical-align: text-bottom;
  270. float: right;
  271. margin-right: 50px;
  272. margin-top: 18px;
  273. }
  274. #dropdown-menu-1780 {
  275. z-index: 1000000;
  276. }
  277. .imgg {
  278. /* width: 553px; */
  279. width: 200px;
  280. height: 80px;
  281. // float: left;
  282. margin-top: 7px;
  283. margin-bottom: 8px;
  284. /* margin-left: 50px; */
  285. }
  286. .logo-title {
  287. width: 100%;
  288. display: flex;
  289. align-items: center;
  290. .title {
  291. flex: 1;
  292. /* margin-left: 10px; */
  293. margin-top: 10px;
  294. display: block;
  295. font-size: 26px;
  296. font-weight: 520;
  297. letter-spacing: 2px;
  298. line-height: 38.4px;
  299. /* color: rgba(7, 68, 138, 1); */
  300. color: black;
  301. text-align: left;
  302. vertical-align: top;
  303. float: left;
  304. white-space: nowrap;
  305. overflow: hidden;
  306. text-overflow: ellipsis;
  307. /* max-width: ; */
  308. }
  309. }
  310. .spann {
  311. text-align: center;
  312. line-height: 100px;
  313. font-size: 30px;
  314. color: #003e8a;
  315. font-weight: bolder;
  316. margin-left: -335px;
  317. }
  318. .app-wrapper {
  319. @include clearfix;
  320. position: relative;
  321. height: 100%;
  322. width: 100%;
  323. &.mobile.openSidebar {
  324. position: fixed;
  325. top: 0;
  326. }
  327. }
  328. .drawer-bg {
  329. background: #000;
  330. opacity: 0.3;
  331. width: 100%;
  332. top: 0;
  333. height: 100%;
  334. position: absolute;
  335. z-index: 999;
  336. }
  337. .fixed-header {
  338. position: fixed;
  339. top: 100px;
  340. right: 0;
  341. z-index: 9;
  342. width: calc(100% - #{$base-sidebar-width});
  343. transition: width 0.28s;
  344. }
  345. .hideSidebar .fixed-header {
  346. width: calc(100% - 54px);
  347. }
  348. .sidebarHide .fixed-header {
  349. width: 100%;
  350. }
  351. .mobile .fixed-header {
  352. width: 100%;
  353. }
  354. </style>