sidebar.scss 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727
  1. /* $sideBarWidth: vertical 模式下主体内容距离网页文档左侧的距离 */
  2. @mixin merge-style($sideBarWidth) {
  3. $menuActiveText: #7a80b4;
  4. @media screen and (width >= 150px) and (width <= 420px) {
  5. .app-main-nofixed-header {
  6. overflow-y: hidden;
  7. }
  8. }
  9. @media screen and (width >= 420px) {
  10. .app-main-nofixed-header {
  11. overflow: hidden;
  12. }
  13. }
  14. /* 修复 windows 下双滚动条问题 https://github.com/pure-admin/vue-pure-admin/pull/936#issuecomment-1968125992 */
  15. .el-popper.pure-scrollbar {
  16. overflow: hidden;
  17. }
  18. /* popper menu 超出内容区可滚动 */
  19. .pure-scrollbar {
  20. max-height: calc(100vh - calc(50px * 2.5));
  21. overflow: hidden auto;
  22. }
  23. .sub-menu-icon {
  24. margin-right: 5px;
  25. font-size: 18px;
  26. svg {
  27. width: 18px;
  28. height: 18px;
  29. }
  30. }
  31. .set-icon,
  32. .fullscreen-icon {
  33. display: flex;
  34. align-items: center;
  35. justify-content: center;
  36. width: 40px;
  37. height: 48px;
  38. cursor: pointer;
  39. }
  40. .main-container {
  41. position: relative;
  42. height: 100vh;
  43. min-height: 100%;
  44. margin-left: $sideBarWidth;
  45. background: #f0f2f5;
  46. /* main-content 属性动画 */
  47. transition: margin-left var(--pure-transition-duration);
  48. .el-scrollbar__wrap {
  49. height: 100%;
  50. overflow: auto;
  51. }
  52. }
  53. .fixed-header {
  54. position: fixed;
  55. top: 0;
  56. right: 0;
  57. z-index: 998;
  58. width: calc(100% - #{$sideBarWidth});
  59. /* fixed-header 属性左上角动画 */
  60. transition: width var(--pure-transition-duration);
  61. }
  62. .main-hidden {
  63. margin-left: 0 !important;
  64. .fixed-header {
  65. width: 100% !important;
  66. + .app-main {
  67. padding-top: 37px !important;
  68. }
  69. }
  70. }
  71. .sidebar-container {
  72. position: fixed;
  73. top: 0;
  74. bottom: 0;
  75. left: 0;
  76. z-index: 1001;
  77. width: $sideBarWidth !important;
  78. height: 100%;
  79. overflow: visible;
  80. font-size: 0;
  81. background: $menuBg;
  82. border-right: 1px solid var(--pure-border-color);
  83. /* 展开动画 */
  84. transition: width var(--pure-transition-duration);
  85. .scrollbar-wrapper {
  86. overflow-x: hidden !important;
  87. }
  88. .el-scrollbar__bar.is-vertical {
  89. right: 0;
  90. }
  91. &.has-logo {
  92. .el-scrollbar.pc {
  93. /* logo: 48px、leftCollapse: 40px、leftCollapse-shadow: 4px */
  94. height: calc(100% - 92px);
  95. }
  96. /* logo: 48px */
  97. .el-scrollbar.mobile {
  98. height: calc(100% - 48px);
  99. }
  100. }
  101. &.no-logo {
  102. .el-scrollbar.pc {
  103. /* leftCollapse: 40px、leftCollapse-shadow: 4px */
  104. height: calc(100% - 44px);
  105. }
  106. .el-scrollbar.mobile {
  107. height: 100%;
  108. }
  109. }
  110. .is-horizontal {
  111. display: none;
  112. }
  113. a {
  114. display: flex;
  115. flex-wrap: wrap;
  116. width: 100%;
  117. }
  118. .el-menu {
  119. height: 100%;
  120. background-color: transparent !important;
  121. border: none;
  122. }
  123. .el-menu-item,
  124. .el-sub-menu__title {
  125. height: 50px;
  126. color: $menuText;
  127. background-color: transparent !important;
  128. &:hover {
  129. color: $menuTitleHover !important;
  130. }
  131. div,
  132. span {
  133. height: 50px;
  134. line-height: 50px;
  135. }
  136. }
  137. .submenu-title-noDropdown,
  138. .el-sub-menu__title {
  139. &:hover {
  140. background-color: transparent;
  141. }
  142. }
  143. .is-active > .el-sub-menu__title,
  144. .is-active.submenu-title-noDropdown {
  145. color: $subMenuActiveText !important;
  146. i {
  147. color: $subMenuActiveText !important;
  148. }
  149. }
  150. .is-active {
  151. color: $subMenuActiveText !important;
  152. transition: color 0.3s;
  153. }
  154. .el-menu-item.is-active.nest-menu > * {
  155. z-index: 1;
  156. color: #fff;
  157. }
  158. .el-menu-item.is-active.nest-menu::before {
  159. position: absolute;
  160. inset: 0 8px;
  161. margin: 4px 0;
  162. clear: both;
  163. content: "";
  164. background: var(--el-color-primary) !important;
  165. border-radius: 3px;
  166. }
  167. .el-menu .el-menu--inline .el-sub-menu__title,
  168. & .el-sub-menu .el-menu-item {
  169. min-width: $sideBarWidth !important;
  170. font-size: 14px;
  171. background-color: $subMenuBg !important;
  172. }
  173. /* 有子集的激活菜单左侧小竖条 */
  174. .el-menu--collapse
  175. .is-active.outer-most.el-sub-menu
  176. > .el-sub-menu__title::before {
  177. position: absolute;
  178. top: 0;
  179. left: 0;
  180. width: 2px;
  181. height: 100%;
  182. clear: both;
  183. content: "";
  184. background-color: $menuActiveBefore;
  185. transition: all var(--pure-transition-duration) ease-in-out;
  186. transform: translateY(0);
  187. }
  188. .el-menu--collapse .outer-most.el-sub-menu > .el-sub-menu__title::before {
  189. position: absolute;
  190. top: 50%;
  191. display: block;
  192. width: 3px;
  193. height: 0;
  194. content: "";
  195. transform: translateY(-50%);
  196. }
  197. /* 无子集的激活菜单背景 */
  198. .is-active.submenu-title-noDropdown.outer-most > * {
  199. z-index: 1;
  200. color: #fff;
  201. }
  202. .is-active.submenu-title-noDropdown.outer-most::before {
  203. position: absolute;
  204. inset: 0 8px;
  205. margin: 4px 0;
  206. clear: both;
  207. content: "";
  208. background: var(--el-color-primary) !important;
  209. border-radius: 3px;
  210. }
  211. }
  212. /* vertical 菜单折叠 */
  213. .el-menu--vertical {
  214. .el-menu--popup {
  215. background-color: $subMenuBg !important;
  216. .el-menu-item {
  217. span {
  218. font-size: 14px;
  219. }
  220. }
  221. }
  222. & > .el-menu {
  223. i {
  224. margin-right: 20px;
  225. }
  226. }
  227. .is-active > .el-sub-menu__title,
  228. .is-active.submenu-title-noDropdown {
  229. color: $subMenuActiveText !important;
  230. i {
  231. color: $subMenuActiveText !important;
  232. }
  233. }
  234. /* 子菜单中还有子菜单 */
  235. .el-menu .el-sub-menu__title {
  236. min-width: $sideBarWidth !important;
  237. font-size: 14px;
  238. background-color: $subMenuBg !important;
  239. }
  240. .el-menu-item,
  241. .el-sub-menu__title {
  242. height: 50px;
  243. line-height: 50px;
  244. color: $menuText;
  245. background-color: $subMenuBg;
  246. &:hover {
  247. color: $menuTitleHover !important;
  248. }
  249. }
  250. .is-active {
  251. color: $subMenuActiveText !important;
  252. transition: color 0.3s;
  253. }
  254. .el-menu-item.is-active.nest-menu > * {
  255. z-index: 1;
  256. color: #fff;
  257. }
  258. .el-menu-item.is-active.nest-menu::before {
  259. position: absolute;
  260. inset: 0 8px;
  261. clear: both;
  262. content: "";
  263. background: var(--el-color-primary) !important;
  264. border-radius: 3px;
  265. }
  266. .el-menu-item,
  267. .el-sub-menu {
  268. .iconfont {
  269. font-size: 18px;
  270. }
  271. .el-menu-tooltip__trigger {
  272. width: 54px;
  273. padding: 0;
  274. }
  275. }
  276. }
  277. /* horizontal 菜单 */
  278. .el-menu--horizontal {
  279. & > .el-sub-menu .el-sub-menu__icon-arrow {
  280. position: static !important;
  281. margin-top: 0;
  282. }
  283. /* 无子菜单时激活 border-bottom */
  284. a > .is-active.submenu-title-noDropdown {
  285. border-bottom: 2px solid var(--el-menu-active-color);
  286. }
  287. .el-menu--popup {
  288. background-color: $subMenuBg !important;
  289. a > .is-active.submenu-title-noDropdown {
  290. border-bottom: none;
  291. }
  292. .el-menu-item {
  293. color: $menuText;
  294. background-color: $subMenuBg;
  295. span {
  296. font-size: 14px;
  297. }
  298. }
  299. .el-sub-menu__title {
  300. color: $menuText;
  301. }
  302. }
  303. /* 子菜单中还有子菜单 */
  304. .el-menu .el-sub-menu__title {
  305. min-width: $sideBarWidth !important;
  306. font-size: 14px;
  307. background-color: $subMenuBg !important;
  308. &:hover {
  309. color: $menuTitleHover !important;
  310. }
  311. }
  312. .is-active > .el-sub-menu__title,
  313. .is-active.submenu-title-noDropdown {
  314. color: $subMenuActiveText !important;
  315. i {
  316. color: $subMenuActiveText !important;
  317. }
  318. }
  319. .nest-menu .el-sub-menu > .el-sub-menu__title,
  320. .el-menu-item {
  321. &:hover {
  322. color: $menuTitleHover !important;
  323. }
  324. }
  325. .el-menu-item.is-active {
  326. color: $subMenuActiveText !important;
  327. transition: color 0.3s;
  328. }
  329. .el-menu-item.is-active.nest-menu > * {
  330. z-index: 1;
  331. color: #fff;
  332. }
  333. .el-menu-item.is-active.nest-menu::before {
  334. position: absolute;
  335. inset: 0 5px;
  336. clear: both;
  337. content: "";
  338. background: var(--el-color-primary) !important;
  339. border-radius: 3px;
  340. }
  341. }
  342. .horizontal-header {
  343. display: flex;
  344. align-items: center;
  345. justify-content: space-around;
  346. width: 100%;
  347. height: 48px;
  348. background: $menuBg;
  349. .horizontal-header-left {
  350. display: flex;
  351. align-items: center;
  352. width: auto;
  353. min-width: 200px;
  354. height: 100%;
  355. padding-left: 10px;
  356. cursor: pointer;
  357. transition: all var(--pure-transition-duration) ease;
  358. img {
  359. display: inline-block;
  360. height: 32px;
  361. }
  362. span {
  363. display: inline-block;
  364. height: 32px;
  365. margin: 2px 0 0 12px;
  366. overflow: hidden;
  367. font-size: 18px;
  368. font-weight: 600;
  369. line-height: 32px;
  370. color: $subMenuActiveText;
  371. text-overflow: ellipsis;
  372. white-space: nowrap;
  373. }
  374. }
  375. .horizontal-header-menu {
  376. flex: 1;
  377. align-items: center;
  378. min-width: 0;
  379. height: 100%;
  380. }
  381. .horizontal-header-right {
  382. display: flex;
  383. align-items: center;
  384. justify-content: flex-end;
  385. min-width: 340px;
  386. color: $subMenuActiveText;
  387. /* 搜索 */
  388. .search-container,
  389. /* 国际化 */
  390. .globalization,
  391. /* 全屏 */
  392. .fullscreen-icon,
  393. /* 消息通知 */
  394. .dropdown-badge,
  395. /* 用户名 */
  396. .el-dropdown-link,
  397. /* 设置 */
  398. .set-icon {
  399. &:hover {
  400. background: $menuHover;
  401. }
  402. }
  403. .dropdown-badge {
  404. height: 48px;
  405. color: $subMenuActiveText;
  406. }
  407. .globalization {
  408. width: 40px;
  409. height: 48px;
  410. padding: 11px;
  411. color: $subMenuActiveText;
  412. cursor: pointer;
  413. outline: none;
  414. }
  415. .el-dropdown-link {
  416. display: flex;
  417. align-items: center;
  418. justify-content: space-around;
  419. height: 48px;
  420. padding: 10px;
  421. color: $subMenuActiveText;
  422. cursor: pointer;
  423. p {
  424. font-size: 14px;
  425. }
  426. img {
  427. width: 22px;
  428. height: 22px;
  429. border-radius: 50%;
  430. }
  431. }
  432. }
  433. .el-menu {
  434. width: 100% !important;
  435. height: 100%;
  436. background-color: transparent;
  437. border: none;
  438. }
  439. .el-menu-item,
  440. .el-sub-menu__title {
  441. padding-right: var(--el-menu-base-level-padding);
  442. color: $menuText;
  443. &:hover {
  444. color: $menuTitleHover !important;
  445. }
  446. }
  447. .submenu-title-noDropdown,
  448. .el-sub-menu__title {
  449. height: 48px;
  450. line-height: 48px;
  451. background: $menuBg;
  452. svg {
  453. position: static !important;
  454. }
  455. }
  456. .is-active > .el-sub-menu__title,
  457. .is-active.submenu-title-noDropdown {
  458. color: $subMenuActiveText !important;
  459. i {
  460. color: $subMenuActiveText !important;
  461. }
  462. }
  463. .is-active {
  464. color: $subMenuActiveText !important;
  465. transition: color 0.3s;
  466. }
  467. }
  468. .el-menu--collapse .el-menu .el-sub-menu {
  469. min-width: $sideBarWidth !important;
  470. }
  471. /* 手机端 */
  472. .mobile {
  473. .fixed-header {
  474. width: 100% !important;
  475. transition: width var(--pure-transition-duration);
  476. }
  477. .main-container {
  478. margin-left: 0 !important;
  479. }
  480. .sidebar-container {
  481. width: $sideBarWidth;
  482. transition: transform var(--pure-transition-duration);
  483. }
  484. &.hideSidebar {
  485. .sidebar-container {
  486. pointer-events: none;
  487. transition-duration: 0.3s;
  488. transform: translate3d(-$sideBarWidth, 0, 0);
  489. }
  490. }
  491. }
  492. }
  493. body[layout="vertical"] {
  494. $sideBarWidth: 210px;
  495. @include merge-style($sideBarWidth);
  496. .el-menu--collapse {
  497. width: 54px;
  498. }
  499. .sidebar-logo-container {
  500. background: $sidebarLogo;
  501. }
  502. .hideSidebar {
  503. .fixed-header {
  504. width: calc(100% - 54px);
  505. transition: width var(--pure-transition-duration);
  506. }
  507. .sidebar-container {
  508. width: 54px !important;
  509. transition: width var(--pure-transition-duration);
  510. .is-active.submenu-title-noDropdown.outer-most {
  511. background: transparent !important;
  512. }
  513. }
  514. .main-container {
  515. margin-left: 54px;
  516. }
  517. /* 菜单折叠 */
  518. .el-menu--collapse {
  519. .el-sub-menu {
  520. & > .el-sub-menu__title {
  521. & > span {
  522. width: 100%;
  523. height: 100%;
  524. text-align: center;
  525. visibility: visible;
  526. }
  527. }
  528. }
  529. .submenu-title-noDropdown {
  530. background: transparent !important;
  531. }
  532. .el-sub-menu__title {
  533. padding: 0;
  534. }
  535. }
  536. .sub-menu-icon {
  537. margin-right: 0;
  538. }
  539. }
  540. /* 搜索 */
  541. .search-container,
  542. /* 国际化 */
  543. .globalization,
  544. /* 全屏 */
  545. .fullscreen-icon,
  546. /* 消息通知 */
  547. .dropdown-badge,
  548. /* 用户名 */
  549. .el-dropdown-link,
  550. /* 设置 */
  551. .set-icon {
  552. &:hover {
  553. background: #f6f6f6;
  554. }
  555. }
  556. }
  557. body[layout="horizontal"] {
  558. $sideBarWidth: 0;
  559. @include merge-style($sideBarWidth);
  560. .fixed-header,
  561. .main-container {
  562. transition: none !important;
  563. }
  564. .fixed-header {
  565. width: 100%;
  566. }
  567. }
  568. body[layout="mix"] {
  569. $sideBarWidth: 210px;
  570. @include merge-style($sideBarWidth);
  571. .el-menu--collapse {
  572. width: 54px;
  573. }
  574. .el-menu {
  575. --el-menu-hover-bg-color: transparent !important;
  576. }
  577. .hideSidebar {
  578. .fixed-header {
  579. width: calc(100% - 54px);
  580. transition: width var(--pure-transition-duration);
  581. }
  582. .sidebar-container {
  583. width: 54px !important;
  584. transition: width var(--pure-transition-duration);
  585. .is-active.submenu-title-noDropdown.outer-most {
  586. background: transparent !important;
  587. }
  588. }
  589. .main-container {
  590. margin-left: 54px;
  591. }
  592. /* 菜单折叠 */
  593. .el-menu--collapse {
  594. .el-sub-menu {
  595. & > .el-sub-menu__title {
  596. padding: 0;
  597. & > span {
  598. width: 100%;
  599. height: 100%;
  600. text-align: center;
  601. visibility: visible;
  602. }
  603. }
  604. }
  605. }
  606. }
  607. }