sidebar.scss 16 KB

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