sidebar.scss 11 KB

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