BaseLayout.vue 4.9 KB

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