sidebar.scss 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. @import "../layout/theme/default-vars.scss";
  2. @mixin merge-style(
  3. // vertical模式下主体内容距离网页文档左侧的距离
  4. $sideBarWidth
  5. ) {
  6. $menuActiveText: #7a80b4;
  7. @media screen and (min-width: 150px) and (max-width: 420px) {
  8. .app-main-nofixed-header {
  9. overflow-y: hidden;
  10. }
  11. }
  12. @media screen and (min-width: 420px) {
  13. .app-main-nofixed-header {
  14. overflow: hidden;
  15. }
  16. }
  17. .el-menu-item,
  18. .el-sub-menu__title {
  19. &:hover {
  20. color: $menuTitleHover !important;
  21. }
  22. }
  23. .el-sub-menu__icon-arrow {
  24. position: absolute;
  25. }
  26. .main-container {
  27. height: 100vh;
  28. min-height: 100%;
  29. transition: margin-left 0.28s;
  30. margin-left: $sideBarWidth;
  31. position: relative;
  32. @media screen and (min-width: 150px) and (max-width: 420px) {
  33. .el-scrollbar__view {
  34. overflow-y: hidden;
  35. }
  36. }
  37. @media screen and (min-width: 420px) {
  38. .el-scrollbar__view {
  39. overflow: hidden;
  40. }
  41. }
  42. }
  43. .fixed-header {
  44. position: fixed;
  45. top: 0;
  46. right: 0;
  47. z-index: 1000;
  48. width: calc(100% - 210px);
  49. transition: width 0.28s;
  50. }
  51. .main-hidden {
  52. margin-left: 0 !important;
  53. .fixed-header {
  54. width: 100% !important;
  55. + .app-main {
  56. padding-top: 37px;
  57. }
  58. }
  59. }
  60. .el-popper.is-light {
  61. border: none !important;
  62. }
  63. .sidebar-container {
  64. transition: width 0.28s;
  65. width: $sideBarWidth !important;
  66. background: $menuBg;
  67. height: 100%;
  68. position: fixed;
  69. font-size: 0;
  70. top: 0;
  71. bottom: 0;
  72. left: 0;
  73. z-index: 1001;
  74. overflow: hidden;
  75. box-shadow: 0 0 1px #888;
  76. .scrollbar-wrapper {
  77. overflow-x: hidden !important;
  78. }
  79. .horizontal-collapse-transition {
  80. transition: 0s width ease-in-out, 0s padding-left ease-in-out,
  81. 0s padding-right ease-in-out;
  82. }
  83. .el-scrollbar__bar.is-vertical {
  84. right: 0;
  85. }
  86. .el-scrollbar {
  87. height: 100%;
  88. }
  89. &.has-logo {
  90. .el-scrollbar {
  91. height: calc(100% - 50px);
  92. }
  93. }
  94. .is-horizontal {
  95. display: none;
  96. }
  97. a {
  98. display: inline-block;
  99. display: flex;
  100. padding-left: 10px;
  101. flex-wrap: wrap;
  102. width: 100%;
  103. }
  104. .el-menu {
  105. border: none;
  106. height: 100%;
  107. background-color: transparent !important;
  108. }
  109. .el-menu-item,
  110. .el-sub-menu__title {
  111. color: $menuText;
  112. }
  113. // menu hover
  114. .submenu-title-noDropdown,
  115. .el-sub-menu__title {
  116. &:hover {
  117. background-color: $menuHover !important;
  118. }
  119. }
  120. .is-active > .el-sub-menu__title,
  121. .is-active.submenu-title-noDropdown {
  122. color: $subMenuActiveText !important;
  123. i {
  124. color: $subMenuActiveText !important;
  125. }
  126. }
  127. .is-active {
  128. transition: color 0.3s;
  129. color: $subMenuActiveText !important;
  130. }
  131. .el-menu .el-menu--inline .el-sub-menu__title,
  132. & .el-sub-menu .el-menu-item {
  133. font-size: 12px;
  134. min-width: $sideBarWidth !important;
  135. background-color: $subMenuBg !important;
  136. &:hover {
  137. background-color: $subMenuHover !important;
  138. }
  139. }
  140. }
  141. .horizontal-header {
  142. display: flex;
  143. justify-content: space-around;
  144. background: $menuBg;
  145. width: 100%;
  146. height: 62px;
  147. align-items: center;
  148. .horizontal-header-left {
  149. display: flex;
  150. height: 100%;
  151. width: auto;
  152. min-width: 200px;
  153. align-items: center;
  154. padding-left: 10px;
  155. cursor: pointer;
  156. transition: all 0.2s ease;
  157. &:hover {
  158. background: $menuHover;
  159. }
  160. i {
  161. font-size: 30px;
  162. color: #1890ff;
  163. margin-right: 4px;
  164. }
  165. h4 {
  166. font-size: 16px;
  167. font-weight: 700;
  168. color: $navTextColor;
  169. transition: all 0.5s;
  170. }
  171. }
  172. .horizontal-header-menu {
  173. height: 100%;
  174. min-width: 0;
  175. flex: 1;
  176. align-items: center;
  177. }
  178. .horizontal-header-right {
  179. display: flex;
  180. min-width: 280px;
  181. align-items: center;
  182. color: $navTextColor;
  183. justify-content: flex-end;
  184. .screen-full {
  185. cursor: pointer;
  186. &:hover {
  187. background: $menuHover;
  188. }
  189. }
  190. .globalization {
  191. height: 62px;
  192. width: 40px;
  193. padding: 11px;
  194. cursor: pointer;
  195. color: $navTextColor;
  196. &:hover {
  197. background: $menuHover;
  198. }
  199. }
  200. .el-dropdown-link {
  201. width: 100px;
  202. height: 62px;
  203. padding: 10px;
  204. display: flex;
  205. align-items: center;
  206. justify-content: space-around;
  207. cursor: pointer;
  208. color: $navTextColor;
  209. &:hover {
  210. background: $menuHover;
  211. }
  212. p {
  213. font-size: 14px;
  214. }
  215. img {
  216. width: 22px;
  217. height: 22px;
  218. border-radius: 50%;
  219. }
  220. }
  221. .el-icon-setting {
  222. height: 62px;
  223. width: 40px;
  224. padding: 11px;
  225. display: flex;
  226. cursor: pointer;
  227. align-items: center;
  228. &:hover {
  229. background: $menuHover;
  230. }
  231. }
  232. }
  233. .el-menu {
  234. border: none;
  235. height: 100%;
  236. background-color: transparent;
  237. width: 100% !important;
  238. }
  239. .el-menu-item,
  240. .el-sub-menu__title {
  241. color: $menuText;
  242. }
  243. .submenu-title-noDropdown,
  244. .el-sub-menu__title {
  245. height: 60px;
  246. background: $menuBg;
  247. &:hover {
  248. background-color: $menuHover !important;
  249. }
  250. }
  251. .is-active > .el-sub-menu__title,
  252. .is-active.submenu-title-noDropdown {
  253. color: $subMenuActiveText !important;
  254. border-bottom-color: #409eff;
  255. i {
  256. color: $subMenuActiveText !important;
  257. }
  258. }
  259. .is-active {
  260. transition: color 0.3s;
  261. color: $subMenuActiveText !important;
  262. border-bottom-color: #409eff;
  263. }
  264. }
  265. // vertical菜单折叠
  266. .el-menu--vertical {
  267. .el-menu--popup {
  268. background-color: $subMenuBg !important;
  269. .el-menu-item {
  270. color: $menuText;
  271. background-color: $subMenuBg;
  272. span {
  273. font-size: 12px;
  274. margin-left: 10px;
  275. }
  276. &:hover {
  277. background-color: $subMenuHover;
  278. }
  279. }
  280. .el-sub-menu__title {
  281. color: $menuText;
  282. span {
  283. margin-left: 10px;
  284. }
  285. }
  286. }
  287. & > .el-menu {
  288. i {
  289. margin-right: 16px;
  290. }
  291. }
  292. .is-active > .el-sub-menu__title,
  293. .is-active.submenu-title-noDropdown {
  294. color: $subMenuActiveText !important;
  295. i {
  296. color: $subMenuActiveText !important;
  297. }
  298. }
  299. // 子菜单中还有子菜单
  300. .el-menu .el-sub-menu__title {
  301. font-size: 12px;
  302. min-width: $sideBarWidth !important;
  303. background-color: $subMenuBg !important;
  304. &:hover {
  305. background-color: $menuHover !important;
  306. }
  307. }
  308. .is-active {
  309. transition: color 0.3s;
  310. color: $subMenuActiveText !important;
  311. }
  312. .nest-menu .el-sub-menu > .el-sub-menu__title,
  313. .el-menu-item {
  314. &:hover {
  315. background-color: $menuHover !important;
  316. }
  317. }
  318. .el-menu-item,
  319. .el-sub-menu {
  320. i {
  321. width: 20px;
  322. text-align: center;
  323. font-size: 16px;
  324. }
  325. i.fa {
  326. margin-right: 5px;
  327. font-size: 16px;
  328. }
  329. }
  330. }
  331. // horizontal菜单折叠
  332. .el-menu--horizontal {
  333. .el-menu--popup {
  334. background-color: $subMenuBg !important;
  335. .el-menu-item {
  336. color: $menuText;
  337. background-color: $subMenuBg;
  338. span {
  339. font-size: 12px;
  340. margin-left: 10px;
  341. }
  342. &:hover {
  343. background-color: $subMenuHover;
  344. }
  345. }
  346. .el-sub-menu__title {
  347. color: $menuText;
  348. span {
  349. margin-left: 10px;
  350. }
  351. }
  352. }
  353. // 无子菜单时激活border-bottom
  354. .router-link-exact-active > .submenu-title-noDropdown {
  355. height: 60px;
  356. border-bottom: 2px solid var(--el-menu-active-color);
  357. }
  358. // 子菜单中还有子菜单
  359. .el-menu .el-sub-menu__title {
  360. font-size: 12px;
  361. min-width: $sideBarWidth !important;
  362. background-color: $subMenuBg !important;
  363. &:hover {
  364. background-color: $menuHover !important;
  365. }
  366. }
  367. & > .el-menu {
  368. i {
  369. margin-right: 16px;
  370. }
  371. }
  372. .is-active > .el-sub-menu__title,
  373. .is-active.submenu-title-noDropdown {
  374. color: $subMenuActiveText !important;
  375. i {
  376. color: $subMenuActiveText !important;
  377. }
  378. }
  379. .is-active {
  380. transition: color 0.3s;
  381. color: $subMenuActiveText !important;
  382. }
  383. .nest-menu .el-sub-menu > .el-sub-menu__title,
  384. .el-menu-item {
  385. &:hover {
  386. background-color: $menuHover !important;
  387. }
  388. }
  389. }
  390. .el-scrollbar__wrap {
  391. overflow: auto;
  392. height: 100%;
  393. }
  394. .el-menu--collapse .el-menu .el-sub-menu {
  395. min-width: $sideBarWidth !important;
  396. }
  397. // 有子菜单
  398. .el-menu--collapse
  399. .is-active.outer-most.el-sub-menu
  400. > .el-sub-menu__title::before {
  401. position: absolute;
  402. top: 0;
  403. left: 5px;
  404. width: 3px;
  405. height: 100%;
  406. background-color: #1890ff !important;
  407. content: "";
  408. clear: both;
  409. -webkit-transition: all 0.2s ease-in-out;
  410. transition: all 0.2s ease-in-out;
  411. -webkit-transform: translateY(0);
  412. transform: translateY(0);
  413. }
  414. // 无子菜单
  415. .el-menu--collapse .is-active.submenu-title-noDropdown.outer-most::before {
  416. position: absolute;
  417. top: 0;
  418. left: 5px;
  419. width: 3px;
  420. height: 100%;
  421. background-color: #1890ff !important;
  422. content: "";
  423. clear: both;
  424. -webkit-transition: all 0.2s ease-in-out;
  425. transition: all 0.2s ease-in-out;
  426. -webkit-transform: translateY(0);
  427. transform: translateY(0);
  428. }
  429. .el-menu--collapse .outer-most.el-sub-menu > .el-sub-menu__title::before,
  430. .el-menu--collapse .submenu-title-noDropdown.outer-most::before {
  431. content: "";
  432. display: block;
  433. position: absolute;
  434. height: 0;
  435. width: 3px;
  436. -webkit-transform: translateY(-50%);
  437. transform: translateY(-50%);
  438. top: 50%;
  439. }
  440. // 手机端
  441. .mobile {
  442. .fixed-header {
  443. width: 100% !important;
  444. transition: width 0.28s;
  445. }
  446. .main-container {
  447. margin-left: 0;
  448. }
  449. .sidebar-container {
  450. transition: transform 0.28s;
  451. width: $sideBarWidth;
  452. }
  453. &.hideSidebar {
  454. .sidebar-container {
  455. pointer-events: none;
  456. transition-duration: 0.3s;
  457. transform: translate3d(-$sideBarWidth, 0, 0);
  458. }
  459. }
  460. }
  461. .withoutAnimation {
  462. .main-container,
  463. .sidebar-container {
  464. transition: none;
  465. }
  466. }
  467. }
  468. body[layout="vertical"] {
  469. $sideBarWidth: 210px;
  470. @include merge-style($sideBarWidth);
  471. .sidebar-logo-container {
  472. background: $sidebarLogo;
  473. }
  474. .hideSidebar {
  475. .fixed-header {
  476. width: calc(100% - 54px);
  477. transition: width 0.28s;
  478. }
  479. .sidebar-container {
  480. width: 54px !important;
  481. }
  482. .main-container {
  483. margin-left: 0;
  484. }
  485. .submenu-title-noDropdown {
  486. padding: 0 !important;
  487. position: relative;
  488. .el-tooltip {
  489. padding: 0 !important;
  490. }
  491. }
  492. .el-sub-menu {
  493. overflow: hidden;
  494. & > .el-sub-menu__title {
  495. .el-sub-menu__icon-arrow {
  496. display: none;
  497. }
  498. }
  499. }
  500. .el-menu--collapse {
  501. margin-left: -5px; //需优化的地方
  502. .el-sub-menu {
  503. & > .el-sub-menu__title {
  504. & > span {
  505. height: 0;
  506. width: 0;
  507. overflow: hidden;
  508. visibility: hidden;
  509. display: inline-block;
  510. }
  511. }
  512. }
  513. }
  514. }
  515. }
  516. body[layout="horizontal"] {
  517. $sideBarWidth: 0;
  518. @include merge-style($sideBarWidth);
  519. .fixed-header {
  520. width: 100%;
  521. transition: none !important;
  522. }
  523. }
  524. // vertical模式下不隐藏标签页
  525. body[layout="vertical"][data-show-tag="false"] {
  526. .fixed-header + .app-main {
  527. padding-top: 85px;
  528. }
  529. }
  530. // vertical模式下隐藏标签页
  531. body[layout="vertical"][data-show-tag="true"] {
  532. .fixed-header + .app-main {
  533. padding-top: 48px;
  534. }
  535. }
  536. // horizontal模式下不隐藏标签页
  537. body[layout="horizontal"][data-show-tag="false"] {
  538. .fixed-header + .app-main {
  539. padding-top: 98px;
  540. }
  541. }
  542. // horizontal模式下隐藏标签页
  543. body[layout="horizontal"][data-show-tag="true"] {
  544. .fixed-header {
  545. box-shadow: 0 1px 4px rgb(0 21 41 / 8%);
  546. }
  547. .fixed-header + .app-main {
  548. padding-top: 62px;
  549. }
  550. }