BaseLayout.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <script setup lang="ts">
  2. import HeaderLayout from './HeaderLayout.vue'
  3. import SideBar from './SideBar.vue'
  4. import FooterLayout from './FooterLayout.vue'
  5. import PageHeader from '@/components/PageHeader/PageHeader.vue'
  6. import zh_CN from 'ant-design-vue/es/locale/zh_CN'
  7. import zh_TW from 'ant-design-vue/es/locale/zh_TW'
  8. import en_US from 'ant-design-vue/es/locale/en_US'
  9. import {computed, ref} from 'vue'
  10. import _ from 'lodash'
  11. import gettext from '@/gettext'
  12. const drawer_visible = ref(false)
  13. const collapsed = ref(collapse())
  14. addEventListener('resize', _.throttle(() => {
  15. collapsed.value = collapse()
  16. }, 50))
  17. function getClientWidth() {
  18. return document.body.clientWidth
  19. }
  20. function collapse() {
  21. return getClientWidth() < 1280
  22. }
  23. const lang = computed(() => {
  24. switch (gettext.current) {
  25. case 'zh_CN':
  26. return zh_CN
  27. case 'zh_TW':
  28. return zh_TW
  29. default:
  30. return en_US
  31. }
  32. })
  33. </script>
  34. <template>
  35. <a-config-provider :locale="lang" :autoInsertSpaceInButton="false">
  36. <a-layout style="min-height: 100%;">
  37. <div class="drawer-sidebar">
  38. <a-drawer
  39. :closable="false"
  40. v-model:visible="drawer_visible"
  41. placement="left"
  42. @close="drawer_visible=false"
  43. width="256"
  44. >
  45. <side-bar/>
  46. </a-drawer>
  47. </div>
  48. <a-layout-sider
  49. v-model:collapsed="collapsed"
  50. :collapsible="true"
  51. :style="{zIndex: 11}"
  52. theme="light"
  53. class="layout-sider"
  54. >
  55. <side-bar/>
  56. </a-layout-sider>
  57. <a-layout>
  58. <a-layout-header :style="{position: 'fixed', zIndex: 10, width:'100%'}">
  59. <header-layout @clickUnFold="drawer_visible=true"/>
  60. </a-layout-header>
  61. <a-layout-content>
  62. <page-header/>
  63. <div class="router-view">
  64. <router-view v-slot="{ Component, route }">
  65. <transition name="slide-fade">
  66. <component :is="Component" :key="route.path"/>
  67. </transition>
  68. </router-view>
  69. </div>
  70. </a-layout-content>
  71. <a-layout-footer>
  72. <footer-layout/>
  73. </a-layout-footer>
  74. </a-layout>
  75. </a-layout>
  76. </a-config-provider>
  77. </template>
  78. <style lang="less" scoped>
  79. .layout-sider {
  80. @media (max-width: 600px) {
  81. display: none;
  82. }
  83. }
  84. .drawer-sidebar {
  85. @media (min-width: 600px) {
  86. display: none;
  87. }
  88. }
  89. </style>
  90. <style lang="less">
  91. .layout-sider .sidebar {
  92. //position: fixed;
  93. //width: 200px;
  94. ul.ant-menu-inline.ant-menu-root {
  95. height: calc(100vh - 120px);
  96. overflow-y: auto;
  97. overflow-x: hidden;
  98. .ant-menu-item {
  99. width: unset;
  100. }
  101. }
  102. ul.ant-menu-inline-collapsed {
  103. height: calc(100vh - 200px);
  104. overflow-y: auto;
  105. overflow-x: hidden;
  106. }
  107. }
  108. </style>
  109. <style lang="less">
  110. .slide-fade-enter-active {
  111. transition: all .3s ease-in-out;
  112. }
  113. .slide-fade-leave-active {
  114. transition: all .3s cubic-bezier(1.0, 0.5, 0.8, 1.0);
  115. }
  116. .slide-fade-enter-from, .slide-fade-enter-to, .slide-fade-leave-to
  117. /* .slide-fade-leave-active for below version 2.1.8 */ {
  118. transform: translateX(10px);
  119. opacity: 0;
  120. }
  121. body {
  122. overflow: unset !important;
  123. }
  124. .dark {
  125. h1, h2, h3, h4, h5, h6, p {
  126. color: #fafafa !important;
  127. }
  128. .ant-checkbox-indeterminate {
  129. .ant-checkbox-inner {
  130. background-color: transparent !important;
  131. }
  132. }
  133. .ant-menu {
  134. background: unset !important;
  135. }
  136. .ant-layout-header {
  137. background-color: #1f1f1f !important;
  138. }
  139. .ant-card {
  140. background-color: #1f1f1f !important;
  141. }
  142. .ant-layout-sider {
  143. background-color: rgb(20, 20, 20) !important;
  144. .ant-layout-sider-trigger {
  145. background-color: rgb(20, 20, 20) !important;
  146. }
  147. .ant-menu {
  148. border-right: 0 !important;
  149. }
  150. &.ant-layout-sider-has-trigger {
  151. padding-bottom: 0;
  152. }
  153. box-shadow: 2px 0 8px rgba(29, 35, 41, 0.05);
  154. }
  155. }
  156. .ant-layout-header {
  157. padding: 0 !important;
  158. background-color: #fff !important;
  159. }
  160. .ant-layout-sider {
  161. background-color: #ffffff;
  162. &.ant-layout-sider-has-trigger {
  163. padding-bottom: 0;
  164. }
  165. box-shadow: 2px 0 8px rgba(29, 35, 41, 0.05);
  166. }
  167. .ant-drawer-body {
  168. .sidebar .logo {
  169. box-shadow: 0 1px 0 0 #e8e8e8;
  170. }
  171. .ant-menu-inline, .ant-menu-vertical, .ant-menu-vertical-left {
  172. border-right: 0 !important;
  173. }
  174. }
  175. .ant-table-small {
  176. font-size: 13px;
  177. }
  178. .ant-card-bordered {
  179. }
  180. .header-notice-wrapper .ant-tabs-content {
  181. max-height: 250px;
  182. }
  183. .header-notice-wrapper .ant-tabs-tabpane-active {
  184. overflow-y: scroll;
  185. }
  186. .ant-layout-footer {
  187. @media (max-width: 320px) {
  188. padding: 10px;
  189. }
  190. }
  191. .ant-layout-content {
  192. margin: 64px 0;
  193. min-height: auto;
  194. .router-view {
  195. padding: 20px;
  196. @media (max-width: 512px) {
  197. padding: 20px 0;
  198. }
  199. position: relative;
  200. }
  201. }
  202. .ant-layout-footer {
  203. text-align: center;
  204. }
  205. </style>