BaseLayout.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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() < 768
  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/>
  65. </div>
  66. </a-layout-content>
  67. <a-layout-footer>
  68. <footer-layout/>
  69. </a-layout-footer>
  70. </a-layout>
  71. </a-layout>
  72. </a-config-provider>
  73. </template>
  74. <style lang="less" scoped>
  75. .layout-sider {
  76. @media (max-width: 600px) {
  77. display: none;
  78. }
  79. }
  80. .drawer-sidebar {
  81. @media (min-width: 600px) {
  82. display: none;
  83. }
  84. }
  85. </style>
  86. <style lang="less">
  87. .layout-sider .sidebar {
  88. //position: fixed;
  89. //width: 200px;
  90. ul.ant-menu-inline.ant-menu-root {
  91. height: calc(100vh - 120px);
  92. overflow-y: auto;
  93. overflow-x: hidden;
  94. .ant-menu-item {
  95. width: unset;
  96. }
  97. }
  98. ul.ant-menu-inline-collapsed {
  99. height: calc(100vh - 200px);
  100. overflow-y: auto;
  101. overflow-x: hidden;
  102. }
  103. }
  104. </style>
  105. <style lang="less">
  106. body {
  107. overflow: unset !important;
  108. }
  109. .dark {
  110. h1, h2, h3, h4, h5, h6, p {
  111. color: #fafafa !important;
  112. }
  113. .ant-checkbox-indeterminate {
  114. .ant-checkbox-inner {
  115. background-color: transparent !important;
  116. }
  117. }
  118. .ant-menu {
  119. background: unset !important;
  120. }
  121. .ant-layout-header {
  122. background-color: #1f1f1f !important;
  123. }
  124. .ant-card {
  125. background-color: #1f1f1f !important;
  126. }
  127. .ant-layout-sider {
  128. background-color: rgb(20, 20, 20) !important;
  129. .ant-layout-sider-trigger {
  130. background-color: rgb(20, 20, 20) !important;
  131. }
  132. .ant-menu {
  133. border-right: 0 !important;
  134. }
  135. &.ant-layout-sider-has-trigger {
  136. padding-bottom: 0;
  137. }
  138. box-shadow: 2px 0 8px rgba(29, 35, 41, 0.05);
  139. }
  140. }
  141. .ant-layout-header {
  142. padding: 0 !important;
  143. background-color: #fff !important;
  144. }
  145. .ant-layout-sider {
  146. background-color: #ffffff;
  147. &.ant-layout-sider-has-trigger {
  148. padding-bottom: 0;
  149. }
  150. box-shadow: 2px 0 8px rgba(29, 35, 41, 0.05);
  151. }
  152. .ant-drawer-body {
  153. .sidebar .logo {
  154. box-shadow: 0 1px 0 0 #e8e8e8;
  155. }
  156. .ant-menu-inline, .ant-menu-vertical, .ant-menu-vertical-left {
  157. border-right: 0 !important;
  158. }
  159. }
  160. .ant-table-small {
  161. font-size: 13px;
  162. }
  163. .ant-card-bordered {
  164. }
  165. .header-notice-wrapper .ant-tabs-content {
  166. max-height: 250px;
  167. }
  168. .header-notice-wrapper .ant-tabs-tabpane-active {
  169. overflow-y: scroll;
  170. }
  171. .ant-layout-footer {
  172. @media (max-width: 320px) {
  173. padding: 10px;
  174. }
  175. }
  176. .ant-layout-content {
  177. margin: 64px 0;
  178. min-height: auto;
  179. .router-view {
  180. padding: 20px;
  181. @media (max-width: 512px) {
  182. padding: 20px 0;
  183. }
  184. position: relative;
  185. }
  186. }
  187. .ant-layout-footer {
  188. text-align: center;
  189. }
  190. </style>