sidebar.scss 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  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. .main-container {
  18. height: 100vh;
  19. min-height: 100%;
  20. transition: margin-left 0.28s;
  21. margin-left: $sideBarWidth;
  22. position: relative;
  23. background: #f0f2f5;
  24. @media screen and (min-width: 150px) and (max-width: 420px) {
  25. .app-main .el-scrollbar__view:first-child {
  26. overflow-y: hidden;
  27. }
  28. }
  29. @media screen and (min-width: 420px) {
  30. .app-main .el-scrollbar__view:first-child {
  31. overflow: hidden;
  32. }
  33. }
  34. }
  35. .fixed-header {
  36. position: fixed;
  37. top: 0;
  38. right: 0;
  39. z-index: 1000;
  40. width: calc(100% - 210px);
  41. transition: width 0.28s;
  42. }
  43. .main-hidden {
  44. margin-left: 0 !important;
  45. .fixed-header {
  46. width: 100% !important;
  47. + .app-main {
  48. padding-top: 37px !important;
  49. }
  50. }
  51. }
  52. .el-popper.is-light {
  53. border: none !important;
  54. }
  55. .sidebar-container {
  56. transition: width 0.28s;
  57. width: $sideBarWidth !important;
  58. background: $menuBg;
  59. height: 100%;
  60. position: fixed;
  61. font-size: 0;
  62. top: 0;
  63. bottom: 0;
  64. left: 0;
  65. z-index: 1001;
  66. overflow: hidden;
  67. box-shadow: 0 0 1px #888;
  68. .scrollbar-wrapper {
  69. overflow-x: hidden !important;
  70. }
  71. .horizontal-collapse-transition {
  72. transition: 0s width ease-in-out, 0s padding-left ease-in-out,
  73. 0s padding-right ease-in-out;
  74. }
  75. .el-scrollbar__bar.is-vertical {
  76. right: 0;
  77. }
  78. .el-scrollbar {
  79. height: 100%;
  80. }
  81. &.has-logo {
  82. .el-scrollbar {
  83. height: calc(100% - 50px);
  84. }
  85. }
  86. .is-horizontal {
  87. display: none;
  88. }
  89. a {
  90. display: inline-block;
  91. display: flex;
  92. padding-left: 10px;
  93. flex-wrap: wrap;
  94. width: 100%;
  95. }
  96. .el-menu {
  97. border: none;
  98. height: 100%;
  99. background-color: transparent !important;
  100. }
  101. .el-menu-item,
  102. .el-sub-menu__title {
  103. color: $menuText;
  104. padding: 0 20px 0 40px;
  105. &:hover {
  106. color: $menuTitleHover !important;
  107. }
  108. }
  109. // menu hover
  110. .submenu-title-noDropdown,
  111. .el-sub-menu__title {
  112. &:hover {
  113. background-color: transparent;
  114. }
  115. }
  116. .is-active > .el-sub-menu__title,
  117. .is-active.submenu-title-noDropdown {
  118. color: $subMenuActiveText !important;
  119. i {
  120. color: $subMenuActiveText !important;
  121. }
  122. }
  123. .is-active {
  124. transition: color 0.3s;
  125. color: $subMenuActiveText !important;
  126. }
  127. .el-menu .el-menu--inline .el-sub-menu__title,
  128. & .el-sub-menu .el-menu-item {
  129. font-size: 12px;
  130. min-width: $sideBarWidth !important;
  131. background-color: $subMenuBg !important;
  132. }
  133. // 无子集的激活菜单背景
  134. .is-active.submenu-title-noDropdown.outer-most {
  135. background: $subMenuActiveBg;
  136. }
  137. // 有子集的激活菜单背景
  138. .is-active.nest-menu {
  139. background: $subMenuActiveBg !important;
  140. }
  141. }
  142. .horizontal-header {
  143. display: flex;
  144. justify-content: space-around;
  145. background: $menuBg;
  146. width: 100%;
  147. height: 62px;
  148. align-items: center;
  149. .horizontal-header-left {
  150. display: flex;
  151. height: 100%;
  152. width: auto;
  153. min-width: 200px;
  154. align-items: center;
  155. padding-left: 10px;
  156. cursor: pointer;
  157. transition: all 0.2s ease;
  158. i {
  159. font-size: 30px;
  160. color: #1890ff;
  161. margin-right: 4px;
  162. }
  163. h4 {
  164. font-size: 16px;
  165. font-weight: 700;
  166. color: $subMenuActiveText;
  167. transition: all 0.5s;
  168. }
  169. }
  170. .horizontal-header-menu {
  171. height: 100%;
  172. min-width: 0;
  173. flex: 1;
  174. align-items: center;
  175. }
  176. .horizontal-header-right {
  177. display: flex;
  178. min-width: 280px;
  179. align-items: center;
  180. color: $subMenuActiveText;
  181. justify-content: flex-end;
  182. .screen-full {
  183. cursor: pointer;
  184. &:hover {
  185. background: $menuHover;
  186. }
  187. }
  188. .globalization {
  189. height: 62px;
  190. width: 40px;
  191. padding: 11px;
  192. cursor: pointer;
  193. color: $subMenuActiveText;
  194. &:hover {
  195. background: $menuHover;
  196. }
  197. }
  198. .el-dropdown-link {
  199. width: 100px;
  200. height: 62px;
  201. padding: 10px;
  202. display: flex;
  203. align-items: center;
  204. justify-content: space-around;
  205. cursor: pointer;
  206. color: $subMenuActiveText;
  207. &:hover {
  208. background: $menuHover;
  209. }
  210. p {
  211. font-size: 14px;
  212. }
  213. img {
  214. width: 22px;
  215. height: 22px;
  216. border-radius: 50%;
  217. }
  218. }
  219. .el-icon-setting {
  220. height: 62px;
  221. width: 40px;
  222. padding: 12px;
  223. display: flex;
  224. cursor: pointer;
  225. align-items: center;
  226. &:hover {
  227. background: $menuHover;
  228. }
  229. }
  230. }
  231. .el-menu {
  232. border: none;
  233. height: 100%;
  234. background-color: transparent;
  235. width: 100% !important;
  236. }
  237. .el-menu-item,
  238. .el-sub-menu__title {
  239. color: $menuText;
  240. &:hover {
  241. color: $menuTitleHover !important;
  242. }
  243. }
  244. .submenu-title-noDropdown,
  245. .el-sub-menu__title {
  246. height: 60px;
  247. background: $menuBg;
  248. }
  249. .is-active > .el-sub-menu__title,
  250. .is-active.submenu-title-noDropdown {
  251. color: $subMenuActiveText !important;
  252. border-bottom-color: #409eff;
  253. i {
  254. color: $subMenuActiveText !important;
  255. }
  256. }
  257. .is-active {
  258. transition: color 0.3s;
  259. color: $subMenuActiveText !important;
  260. border-bottom-color: #409eff;
  261. }
  262. }
  263. // vertical菜单折叠
  264. .el-menu--vertical {
  265. .el-menu--popup {
  266. background-color: $subMenuBg !important;
  267. .el-menu-item {
  268. span {
  269. font-size: 12px;
  270. margin-left: 10px;
  271. }
  272. }
  273. .el-sub-menu__title {
  274. color: $menuText;
  275. span {
  276. margin-left: 10px;
  277. }
  278. }
  279. }
  280. & > .el-menu {
  281. i {
  282. margin-right: 20px;
  283. }
  284. }
  285. .is-active > .el-sub-menu__title,
  286. .is-active.submenu-title-noDropdown {
  287. color: $subMenuActiveText !important;
  288. i {
  289. color: $subMenuActiveText !important;
  290. }
  291. }
  292. // 子菜单中还有子菜单
  293. .el-menu .el-sub-menu__title {
  294. font-size: 12px;
  295. min-width: $sideBarWidth !important;
  296. background-color: $subMenuBg !important;
  297. }
  298. .el-menu-item,
  299. .el-sub-menu__title {
  300. color: $menuText;
  301. background-color: $subMenuBg;
  302. &:hover {
  303. color: $menuTitleHover !important;
  304. }
  305. }
  306. .is-active {
  307. transition: color 0.3s;
  308. color: $subMenuActiveText !important;
  309. }
  310. .el-menu-item.is-active.nest-menu {
  311. background: $subMenuActiveBg !important;
  312. }
  313. .el-menu-item,
  314. .el-sub-menu {
  315. i {
  316. width: 20px;
  317. text-align: center;
  318. font-size: 16px;
  319. }
  320. i.fa {
  321. margin-right: 5px;
  322. font-size: 16px;
  323. }
  324. }
  325. }
  326. // horizontal菜单
  327. .el-menu--horizontal {
  328. & > .el-sub-menu .el-sub-menu__icon-arrow {
  329. position: static !important;
  330. margin-top: 0;
  331. }
  332. .el-menu--popup {
  333. background-color: $subMenuBg !important;
  334. .el-menu-item {
  335. color: $menuText;
  336. background-color: $subMenuBg;
  337. span {
  338. font-size: 12px;
  339. margin-left: 10px;
  340. }
  341. }
  342. .el-sub-menu__title {
  343. color: $menuText;
  344. span {
  345. margin-left: 10px;
  346. }
  347. }
  348. }
  349. // 无子菜单时激活border-bottom
  350. .router-link-exact-active > .submenu-title-noDropdown {
  351. height: 60px;
  352. border-bottom: 2px solid var(--el-menu-active-color);
  353. }
  354. // 子菜单中还有子菜单
  355. .el-menu .el-sub-menu__title {
  356. font-size: 12px;
  357. min-width: $sideBarWidth !important;
  358. background-color: $subMenuBg !important;
  359. &:hover {
  360. color: $menuTitleHover !important;
  361. }
  362. }
  363. & > .el-menu {
  364. i {
  365. margin-right: 16px;
  366. }
  367. }
  368. .is-active > .el-sub-menu__title,
  369. .is-active.submenu-title-noDropdown {
  370. color: $subMenuActiveText !important;
  371. i {
  372. color: $subMenuActiveText !important;
  373. }
  374. }
  375. .nest-menu .el-sub-menu > .el-sub-menu__title,
  376. .el-menu-item {
  377. &:hover {
  378. color: $menuTitleHover !important;
  379. }
  380. }
  381. // 有子集的激活菜单背景
  382. .is-active.nest-menu {
  383. background: $subMenuActiveBg !important;
  384. }
  385. .el-menu-item.is-active {
  386. transition: color 0.3s;
  387. color: $subMenuActiveText !important;
  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: $menuActiveBefore;
  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: $menuActiveBefore;
  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 !important;
  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: 54px;
  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. // 菜单折叠
  501. .el-menu--collapse {
  502. margin-left: -5px;
  503. .el-sub-menu {
  504. & > .el-sub-menu__title {
  505. & > span {
  506. height: 0;
  507. width: 0;
  508. overflow: hidden;
  509. visibility: hidden;
  510. display: inline-block;
  511. }
  512. }
  513. }
  514. .submenu-title-noDropdown {
  515. background: transparent !important;
  516. }
  517. }
  518. }
  519. }
  520. body[layout="horizontal"] {
  521. $sideBarWidth: 0;
  522. @include merge-style($sideBarWidth);
  523. .fixed-header {
  524. width: 100%;
  525. transition: none !important;
  526. }
  527. }