App.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. <template>
  2. <div class="main">
  3. <!-- 顶部菜单 -->
  4. <el-container v-if="!$store.state.showLoginPage">
  5. <el-header class="currentHeader" v-if="hideHeard === '0'">
  6. <div class="l">LOGO或者其他的什么</div>
  7. <Menu class="r" />
  8. <div class="userBox">
  9. <el-button
  10. type="text"
  11. style="color: #fff"
  12. v-if="!authToken"
  13. @click="goLogin"
  14. >登录</el-button
  15. >
  16. <el-popover
  17. popper-class="loginBoxPopover"
  18. placement="bottom"
  19. :width="150"
  20. trigger="hover"
  21. :show-arrow="false"
  22. v-else
  23. >
  24. <template #reference>
  25. <el-button type="text" style="color: #fff; font-size: 16px">{{
  26. username
  27. }}</el-button>
  28. </template>
  29. <div style="background-color: rgb(rgb(4, 12, 11))">
  30. <el-button
  31. type="text"
  32. style="color: #fff; width: 100%"
  33. @click="loginOut"
  34. >退&nbsp;出&nbsp;登&nbsp;录</el-button
  35. >
  36. </div>
  37. </el-popover>
  38. </div>
  39. </el-header>
  40. <el-main style="padding: 0">
  41. <router-view :key="$route.fullPath" v-if="authToken" />
  42. </el-main>
  43. </el-container>
  44. <LoginPage v-else />
  45. </div>
  46. </template>
  47. <script>
  48. import $ from "jquery";
  49. import LoginPage from "./views/user/login.vue";
  50. import Menu from "./views/menu/index.vue";
  51. import { useRoute, useRouter } from "vue-router";
  52. export default {
  53. components: {
  54. LoginPage,
  55. Menu,
  56. },
  57. data() {
  58. return {
  59. menu: [],
  60. defalutActiveMenu: "",
  61. hideMenus: "0",
  62. hideHeard: "0",
  63. username: localStorage.getItem("username"),
  64. authToken: localStorage.getItem("authToken"),
  65. };
  66. },
  67. created() {
  68. let that = this;
  69. const themeName = that.$store.state.themeName;
  70. $("#appBody").attr(
  71. "class",
  72. themeName === "dark" || themeName === "light" ? themeName : "dark"
  73. );
  74. },
  75. mounted() {
  76. // console.log(111, useRoute());
  77. // console.log(222, useRouter().options.routes);
  78. },
  79. methods: {
  80. goLogin() {
  81. this.$store.dispatch("changeShowLoginPage", true);
  82. },
  83. loginOut() {
  84. localStorage.setItem("authToken", "");
  85. this.authToken = "";
  86. this.$store.dispatch("changeShowLoginPage", true);
  87. },
  88. },
  89. watch: {
  90. $route(res) {
  91. this.hideHeard = res.query.hideheard || "0";
  92. this.hideMenus = res.query.hidemenus || "0";
  93. if (res.query.theme) {
  94. const theme = res.query.theme === "dark" ? "dark" : "light";
  95. this.$store.dispatch("changeTheme", theme);
  96. $("#appBody").attr("class", theme);
  97. }
  98. if (res.query.fn) {
  99. this[res.query.fn] && this[res.query.fn]();
  100. }
  101. if (localStorage.getItem("authToken")) {
  102. this.$store.dispatch("changeShowLoginPage", false);
  103. } else {
  104. this.$store.dispatch("changeShowLoginPage", true);
  105. }
  106. },
  107. "$store.state.moudleName"(msg) {
  108. if (window.__MODE__.showModuleName && msg) {
  109. this.BASE.showMsg({
  110. type: this.$store.state.themeName === "dark" ? "success" : "warning",
  111. showClose: true,
  112. msg,
  113. });
  114. }
  115. },
  116. },
  117. };
  118. </script>
  119. <style lang="less">
  120. @import "./assets/styles/main.less";
  121. html,
  122. body,
  123. #app {
  124. width: 100%;
  125. height: 100%;
  126. .el-container.is-vertical {
  127. .menubar {
  128. float: right;
  129. }
  130. }
  131. }
  132. * {
  133. box-sizing: border-box;
  134. &::-webkit-scrollbar {
  135. width: 6px;
  136. height: 6px;
  137. }
  138. &::-webkit-scrollbar-track-piece {
  139. background-color: rgba(255, 255, 255, 0.05);
  140. border-radius: 4px;
  141. }
  142. &::-webkit-scrollbar-thumb {
  143. background-color: fade(@gray, 75);
  144. border-radius: 4px;
  145. outline: none;
  146. outline-offset: 0px;
  147. border: none;
  148. }
  149. }
  150. #appBody {
  151. .el-popper.is-light {
  152. border: 1px solid rgba(4, 12, 11);
  153. }
  154. }
  155. // 横向菜单
  156. .el-menu--horizontal {
  157. .el-menu-item {
  158. background: transparent !important;
  159. }
  160. .el-menu-item:hover {
  161. background: linear-gradient(
  162. to top,
  163. rgba(5, 187, 76, 0.5),
  164. rgba(5, 187, 76, 0)
  165. ) !important;
  166. }
  167. }
  168. // 纵向菜单
  169. .el-menu--vertical {
  170. .el-menu {
  171. background: rgb(4, 12, 11);
  172. .el-menu-item,
  173. .el-sub-menu__title {
  174. color: #fff;
  175. }
  176. .el-menu-item:hover,
  177. .el-sub-menu__title:hover {
  178. background: linear-gradient(
  179. to top,
  180. rgba(5, 187, 76, 0.5),
  181. rgba(5, 187, 76, 0)
  182. );
  183. transition: 0.2s;
  184. }
  185. }
  186. }
  187. body {
  188. margin: 0;
  189. background: #fff;
  190. color: #fff;
  191. // background-image: url("./assets/background.png");
  192. background: rgb(4, 12, 11);
  193. background-size: cover;
  194. font-size: @fontsize;
  195. font-family: @defalut-font-family;
  196. }
  197. @menuWidth: 5.37vh;
  198. @headerHeight: 4.63vh;
  199. .main {
  200. width: 100vw;
  201. height: 100%;
  202. display: flex;
  203. flex-wrap: wrap;
  204. overflow: hidden;
  205. .menuIconBox {
  206. width: 100%;
  207. height: 63px;
  208. display: flex;
  209. justify-content: center;
  210. align-items: center;
  211. cursor: pointer;
  212. transition: 0.25s;
  213. .menuIcon {
  214. font-size: 20px;
  215. color: #fff;
  216. transition: 0.25s;
  217. }
  218. &:hover .menuIcon {
  219. font-size: 32px;
  220. color: #fff;
  221. cursor: pointer;
  222. transition: 0.25s;
  223. }
  224. }
  225. .el-menu--collapse .el-sub-menu.is-active i {
  226. color: #05bb4c;
  227. }
  228. .el-menu {
  229. border-color: rgb(4, 12, 11);
  230. .el-menu-item,
  231. .el-sub-menu__title {
  232. color: #fff;
  233. }
  234. .el-menu-item:hover,
  235. .el-sub-menu__title:hover {
  236. background: linear-gradient(
  237. to top,
  238. rgba(5, 187, 76, 0.5),
  239. rgba(5, 187, 76, 0)
  240. );
  241. transition: 0.2s;
  242. }
  243. .el-menu-item.is-active {
  244. color: #05bb4c;
  245. }
  246. .el-sub-menu {
  247. .el-menu {
  248. background: rgb(4, 12, 11);
  249. }
  250. }
  251. }
  252. .header-body {
  253. // background: radial-gradient(closest-corner at 22% 40%, #2d5a47, #040d0a, #040d0a);
  254. flex: 0 0 100%;
  255. width: 100%;
  256. display: flex;
  257. flex-direction: row;
  258. height: @headerHeight;
  259. border-bottom: 1px solid #142b29;
  260. .header-title {
  261. margin: auto;
  262. color: #fff;
  263. }
  264. .header-menu-body {
  265. flex-grow: 1;
  266. }
  267. }
  268. .menu-body {
  269. position: absolute;
  270. flex: 0 0 @menuWidth;
  271. width: @menuWidth;
  272. height: calc(100vh - @headerHeight);
  273. top: @headerHeight;
  274. background-color: fade(#192a26, 75%);
  275. z-index: 3000;
  276. opacity: 0;
  277. transition: opacity 0.2s;
  278. transition-timing-function: ease-in;
  279. transform: translate(-@menuWidth);
  280. &:hover,
  281. &.hover {
  282. opacity: 1;
  283. transition: opacity 0.2s;
  284. transition-timing-function: ease-out;
  285. transform: translate(0);
  286. }
  287. }
  288. .main-body {
  289. flex: 0 0 calc(100vw);
  290. max-width: calc(100vw);
  291. height: calc(100vh - @headerHeight);
  292. padding: 1.481vh;
  293. // transition: flex 0.1s, margin-left 0.1s;
  294. // transition-timing-function: ease-in-out;
  295. // &.show-menu {
  296. // flex: 0 0 calc(100vw - @menuWidth);
  297. // margin-left: @menuWidth;
  298. // transition: flex 0.1s, margin-left 0.1s;
  299. // transition-timing-function: ease-in-out;
  300. // }
  301. }
  302. .el-table__body tr.current-row > td {
  303. color: #fff;
  304. background: rgba(66, 66, 66, 0.66) !important;
  305. }
  306. .el-transfer-panel {
  307. width: 450px !important;
  308. height: 73vh;
  309. background-color: #111d1c !important;
  310. border: 1px solid #999999 !important;
  311. .el-transfer-panel__body {
  312. height: 100% !important;
  313. .el-transfer-panel__list {
  314. height: 100% !important;
  315. }
  316. }
  317. }
  318. .el-transfer-panel .el-transfer-panel__header {
  319. background-color: #111d1c !important;
  320. color: #05bb4c !important;
  321. .el-checkbox .el-checkbox__label {
  322. color: #05bb4c !important;
  323. }
  324. }
  325. .el-button--primary.is-disabled,
  326. .el-button--primary.is-disabled:active,
  327. .el-button--primary.is-disabled:focus,
  328. .el-button--primary.is-disabled:hover {
  329. background-color: #05bb4c;
  330. border-color: #05bb4c;
  331. }
  332. }
  333. .el-tree-node__content {
  334. height: 40px !important;
  335. }
  336. .el-tree-node__label {
  337. font-size: 18px !important;
  338. }
  339. .el-pagination.is-background .el-pager li:not(.disabled).active {
  340. background-color: #05bb4c !important;
  341. display: flex;
  342. }
  343. .userBox {
  344. .loginoption {
  345. font-size: 16px;
  346. width: 150px;
  347. background-color: #292929;
  348. border: none;
  349. color: rgb(220, 220, 220);
  350. }
  351. }
  352. .loginBoxPopover {
  353. background: rgb(4, 12, 11) !important;
  354. }
  355. </style>
  356. <style lang="less" scoped>
  357. .currentHeader {
  358. display: flex;
  359. justify-content: start;
  360. align-content: center;
  361. .l,
  362. .r {
  363. height: 100%;
  364. }
  365. .l {
  366. width: 20%;
  367. display: flex;
  368. justify-content: center;
  369. align-items: center;
  370. font-size: 18px;
  371. }
  372. .r {
  373. width: 80%;
  374. }
  375. .el-menu {
  376. border-color: rgb(4, 12, 11);
  377. .el-menu-item:hover {
  378. background: linear-gradient(
  379. to top,
  380. rgba(5, 187, 76, 0.5),
  381. rgba(5, 187, 76, 0)
  382. );
  383. }
  384. }
  385. .userBox {
  386. height: 60px;
  387. position: absolute;
  388. right: 20px;
  389. display: flex;
  390. justify-content: center;
  391. align-items: center;
  392. }
  393. }
  394. </style>